babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/webRequest" {
  4967. /**
  4968. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4969. */
  4970. export class WebRequest {
  4971. private _xhr;
  4972. /**
  4973. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4974. * i.e. when loading files, where the server/service expects an Authorization header
  4975. */
  4976. static CustomRequestHeaders: {
  4977. [key: string]: string;
  4978. };
  4979. /**
  4980. * Add callback functions in this array to update all the requests before they get sent to the network
  4981. */
  4982. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4983. private _injectCustomRequestHeaders;
  4984. /**
  4985. * Gets or sets a function to be called when loading progress changes
  4986. */
  4987. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4988. /**
  4989. * Returns client's state
  4990. */
  4991. readonly readyState: number;
  4992. /**
  4993. * Returns client's status
  4994. */
  4995. readonly status: number;
  4996. /**
  4997. * Returns client's status as a text
  4998. */
  4999. readonly statusText: string;
  5000. /**
  5001. * Returns client's response
  5002. */
  5003. readonly response: any;
  5004. /**
  5005. * Returns client's response url
  5006. */
  5007. readonly responseURL: string;
  5008. /**
  5009. * Returns client's response as text
  5010. */
  5011. readonly responseText: string;
  5012. /**
  5013. * Gets or sets the expected response type
  5014. */
  5015. responseType: XMLHttpRequestResponseType;
  5016. /** @hidden */
  5017. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5018. /** @hidden */
  5019. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5020. /**
  5021. * Cancels any network activity
  5022. */
  5023. abort(): void;
  5024. /**
  5025. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5026. * @param body defines an optional request body
  5027. */
  5028. send(body?: Document | BodyInit | null): void;
  5029. /**
  5030. * Sets the request method, request URL
  5031. * @param method defines the method to use (GET, POST, etc..)
  5032. * @param url defines the url to connect with
  5033. */
  5034. open(method: string, url: string): void;
  5035. }
  5036. }
  5037. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5038. /**
  5039. * Class used to evalaute queries containing `and` and `or` operators
  5040. */
  5041. export class AndOrNotEvaluator {
  5042. /**
  5043. * Evaluate a query
  5044. * @param query defines the query to evaluate
  5045. * @param evaluateCallback defines the callback used to filter result
  5046. * @returns true if the query matches
  5047. */
  5048. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5049. private static _HandleParenthesisContent;
  5050. private static _SimplifyNegation;
  5051. }
  5052. }
  5053. declare module "babylonjs/Misc/tags" {
  5054. /**
  5055. * Class used to store custom tags
  5056. */
  5057. export class Tags {
  5058. /**
  5059. * Adds support for tags on the given object
  5060. * @param obj defines the object to use
  5061. */
  5062. static EnableFor(obj: any): void;
  5063. /**
  5064. * Removes tags support
  5065. * @param obj defines the object to use
  5066. */
  5067. static DisableFor(obj: any): void;
  5068. /**
  5069. * Gets a boolean indicating if the given object has tags
  5070. * @param obj defines the object to use
  5071. * @returns a boolean
  5072. */
  5073. static HasTags(obj: any): boolean;
  5074. /**
  5075. * Gets the tags available on a given object
  5076. * @param obj defines the object to use
  5077. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5078. * @returns the tags
  5079. */
  5080. static GetTags(obj: any, asString?: boolean): any;
  5081. /**
  5082. * Adds tags to an object
  5083. * @param obj defines the object to use
  5084. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5085. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5086. */
  5087. static AddTagsTo(obj: any, tagsString: string): void;
  5088. /**
  5089. * @hidden
  5090. */
  5091. static _AddTagTo(obj: any, tag: string): void;
  5092. /**
  5093. * Removes specific tags from a specific object
  5094. * @param obj defines the object to use
  5095. * @param tagsString defines the tags to remove
  5096. */
  5097. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _RemoveTagFrom(obj: any, tag: string): void;
  5102. /**
  5103. * Defines if tags hosted on an object match a given query
  5104. * @param obj defines the object to use
  5105. * @param tagsQuery defines the tag query
  5106. * @returns a boolean
  5107. */
  5108. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5109. }
  5110. }
  5111. declare module "babylonjs/Materials/materialDefines" {
  5112. /**
  5113. * Manages the defines for the Material
  5114. */
  5115. export class MaterialDefines {
  5116. private _keys;
  5117. private _isDirty;
  5118. /** @hidden */
  5119. _renderId: number;
  5120. /** @hidden */
  5121. _areLightsDirty: boolean;
  5122. /** @hidden */
  5123. _areAttributesDirty: boolean;
  5124. /** @hidden */
  5125. _areTexturesDirty: boolean;
  5126. /** @hidden */
  5127. _areFresnelDirty: boolean;
  5128. /** @hidden */
  5129. _areMiscDirty: boolean;
  5130. /** @hidden */
  5131. _areImageProcessingDirty: boolean;
  5132. /** @hidden */
  5133. _normals: boolean;
  5134. /** @hidden */
  5135. _uvs: boolean;
  5136. /** @hidden */
  5137. _needNormals: boolean;
  5138. /** @hidden */
  5139. _needUVs: boolean;
  5140. /**
  5141. * Specifies if the material needs to be re-calculated
  5142. */
  5143. readonly isDirty: boolean;
  5144. /**
  5145. * Marks the material to indicate that it has been re-calculated
  5146. */
  5147. markAsProcessed(): void;
  5148. /**
  5149. * Marks the material to indicate that it needs to be re-calculated
  5150. */
  5151. markAsUnprocessed(): void;
  5152. /**
  5153. * Marks the material to indicate all of its defines need to be re-calculated
  5154. */
  5155. markAllAsDirty(): void;
  5156. /**
  5157. * Marks the material to indicate that image processing needs to be re-calculated
  5158. */
  5159. markAsImageProcessingDirty(): void;
  5160. /**
  5161. * Marks the material to indicate the lights need to be re-calculated
  5162. */
  5163. markAsLightDirty(): void;
  5164. /**
  5165. * Marks the attribute state as changed
  5166. */
  5167. markAsAttributesDirty(): void;
  5168. /**
  5169. * Marks the texture state as changed
  5170. */
  5171. markAsTexturesDirty(): void;
  5172. /**
  5173. * Marks the fresnel state as changed
  5174. */
  5175. markAsFresnelDirty(): void;
  5176. /**
  5177. * Marks the misc state as changed
  5178. */
  5179. markAsMiscDirty(): void;
  5180. /**
  5181. * Rebuilds the material defines
  5182. */
  5183. rebuild(): void;
  5184. /**
  5185. * Specifies if two material defines are equal
  5186. * @param other - A material define instance to compare to
  5187. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5188. */
  5189. isEqual(other: MaterialDefines): boolean;
  5190. /**
  5191. * Clones this instance's defines to another instance
  5192. * @param other - material defines to clone values to
  5193. */
  5194. cloneTo(other: MaterialDefines): void;
  5195. /**
  5196. * Resets the material define values
  5197. */
  5198. reset(): void;
  5199. /**
  5200. * Converts the material define values to a string
  5201. * @returns - String of material define information
  5202. */
  5203. toString(): string;
  5204. }
  5205. }
  5206. declare module "babylonjs/Misc/performanceMonitor" {
  5207. /**
  5208. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5209. */
  5210. export class PerformanceMonitor {
  5211. private _enabled;
  5212. private _rollingFrameTime;
  5213. private _lastFrameTimeMs;
  5214. /**
  5215. * constructor
  5216. * @param frameSampleSize The number of samples required to saturate the sliding window
  5217. */
  5218. constructor(frameSampleSize?: number);
  5219. /**
  5220. * Samples current frame
  5221. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5222. */
  5223. sampleFrame(timeMs?: number): void;
  5224. /**
  5225. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5226. */
  5227. readonly averageFrameTime: number;
  5228. /**
  5229. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5230. */
  5231. readonly averageFrameTimeVariance: number;
  5232. /**
  5233. * Returns the frame time of the most recent frame
  5234. */
  5235. readonly instantaneousFrameTime: number;
  5236. /**
  5237. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFPS: number;
  5240. /**
  5241. * Returns the average framerate in frames per second using the most recent frame time
  5242. */
  5243. readonly instantaneousFPS: number;
  5244. /**
  5245. * Returns true if enough samples have been taken to completely fill the sliding window
  5246. */
  5247. readonly isSaturated: boolean;
  5248. /**
  5249. * Enables contributions to the sliding window sample set
  5250. */
  5251. enable(): void;
  5252. /**
  5253. * Disables contributions to the sliding window sample set
  5254. * Samples will not be interpolated over the disabled period
  5255. */
  5256. disable(): void;
  5257. /**
  5258. * Returns true if sampling is enabled
  5259. */
  5260. readonly isEnabled: boolean;
  5261. /**
  5262. * Resets performance monitor
  5263. */
  5264. reset(): void;
  5265. }
  5266. /**
  5267. * RollingAverage
  5268. *
  5269. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5270. */
  5271. export class RollingAverage {
  5272. /**
  5273. * Current average
  5274. */
  5275. average: number;
  5276. /**
  5277. * Current variance
  5278. */
  5279. variance: number;
  5280. protected _samples: Array<number>;
  5281. protected _sampleCount: number;
  5282. protected _pos: number;
  5283. protected _m2: number;
  5284. /**
  5285. * constructor
  5286. * @param length The number of samples required to saturate the sliding window
  5287. */
  5288. constructor(length: number);
  5289. /**
  5290. * Adds a sample to the sample set
  5291. * @param v The sample value
  5292. */
  5293. add(v: number): void;
  5294. /**
  5295. * Returns previously added values or null if outside of history or outside the sliding window domain
  5296. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5297. * @return Value previously recorded with add() or null if outside of range
  5298. */
  5299. history(i: number): number;
  5300. /**
  5301. * Returns true if enough samples have been taken to completely fill the sliding window
  5302. * @return true if sample-set saturated
  5303. */
  5304. isSaturated(): boolean;
  5305. /**
  5306. * Resets the rolling average (equivalent to 0 samples taken so far)
  5307. */
  5308. reset(): void;
  5309. /**
  5310. * Wraps a value around the sample range boundaries
  5311. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5312. * @return Wrapped position in sample range
  5313. */
  5314. protected _wrapPosition(i: number): number;
  5315. }
  5316. }
  5317. declare module "babylonjs/Misc/stringDictionary" {
  5318. import { Nullable } from "babylonjs/types";
  5319. /**
  5320. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5321. * The underlying implementation relies on an associative array to ensure the best performances.
  5322. * The value can be anything including 'null' but except 'undefined'
  5323. */
  5324. export class StringDictionary<T> {
  5325. /**
  5326. * This will clear this dictionary and copy the content from the 'source' one.
  5327. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5328. * @param source the dictionary to take the content from and copy to this dictionary
  5329. */
  5330. copyFrom(source: StringDictionary<T>): void;
  5331. /**
  5332. * Get a value based from its key
  5333. * @param key the given key to get the matching value from
  5334. * @return the value if found, otherwise undefined is returned
  5335. */
  5336. get(key: string): T | undefined;
  5337. /**
  5338. * Get a value from its key or add it if it doesn't exist.
  5339. * This method will ensure you that a given key/data will be present in the dictionary.
  5340. * @param key the given key to get the matching value from
  5341. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5342. * The factory will only be invoked if there's no data for the given key.
  5343. * @return the value corresponding to the key.
  5344. */
  5345. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5346. /**
  5347. * Get a value from its key if present in the dictionary otherwise add it
  5348. * @param key the key to get the value from
  5349. * @param val if there's no such key/value pair in the dictionary add it with this value
  5350. * @return the value corresponding to the key
  5351. */
  5352. getOrAdd(key: string, val: T): T;
  5353. /**
  5354. * Check if there's a given key in the dictionary
  5355. * @param key the key to check for
  5356. * @return true if the key is present, false otherwise
  5357. */
  5358. contains(key: string): boolean;
  5359. /**
  5360. * Add a new key and its corresponding value
  5361. * @param key the key to add
  5362. * @param value the value corresponding to the key
  5363. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5364. */
  5365. add(key: string, value: T): boolean;
  5366. /**
  5367. * Update a specific value associated to a key
  5368. * @param key defines the key to use
  5369. * @param value defines the value to store
  5370. * @returns true if the value was updated (or false if the key was not found)
  5371. */
  5372. set(key: string, value: T): boolean;
  5373. /**
  5374. * Get the element of the given key and remove it from the dictionary
  5375. * @param key defines the key to search
  5376. * @returns the value associated with the key or null if not found
  5377. */
  5378. getAndRemove(key: string): Nullable<T>;
  5379. /**
  5380. * Remove a key/value from the dictionary.
  5381. * @param key the key to remove
  5382. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5383. */
  5384. remove(key: string): boolean;
  5385. /**
  5386. * Clear the whole content of the dictionary
  5387. */
  5388. clear(): void;
  5389. /**
  5390. * Gets the current count
  5391. */
  5392. readonly count: number;
  5393. /**
  5394. * Execute a callback on each key/val of the dictionary.
  5395. * Note that you can remove any element in this dictionary in the callback implementation
  5396. * @param callback the callback to execute on a given key/value pair
  5397. */
  5398. forEach(callback: (key: string, val: T) => void): void;
  5399. /**
  5400. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5401. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5404. * @returns the first item
  5405. */
  5406. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5407. private _count;
  5408. private _data;
  5409. }
  5410. }
  5411. declare module "babylonjs/Misc/promise" {
  5412. /**
  5413. * Helper class that provides a small promise polyfill
  5414. */
  5415. export class PromisePolyfill {
  5416. /**
  5417. * Static function used to check if the polyfill is required
  5418. * If this is the case then the function will inject the polyfill to window.Promise
  5419. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5420. */
  5421. static Apply(force?: boolean): void;
  5422. }
  5423. }
  5424. declare module "babylonjs/Meshes/buffer" {
  5425. import { Nullable, DataArray } from "babylonjs/types";
  5426. /**
  5427. * Class used to store data that will be store in GPU memory
  5428. */
  5429. export class Buffer {
  5430. private _engine;
  5431. private _buffer;
  5432. /** @hidden */
  5433. _data: Nullable<DataArray>;
  5434. private _updatable;
  5435. private _instanced;
  5436. /**
  5437. * Gets the byte stride.
  5438. */
  5439. readonly byteStride: number;
  5440. /**
  5441. * Constructor
  5442. * @param engine the engine
  5443. * @param data the data to use for this buffer
  5444. * @param updatable whether the data is updatable
  5445. * @param stride the stride (optional)
  5446. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5447. * @param instanced whether the buffer is instanced (optional)
  5448. * @param useBytes set to true if the stride in in bytes (optional)
  5449. */
  5450. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5451. /**
  5452. * Create a new VertexBuffer based on the current buffer
  5453. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5454. * @param offset defines offset in the buffer (0 by default)
  5455. * @param size defines the size in floats of attributes (position is 3 for instance)
  5456. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5457. * @param instanced defines if the vertex buffer contains indexed data
  5458. * @param useBytes defines if the offset and stride are in bytes
  5459. * @returns the new vertex buffer
  5460. */
  5461. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5462. /**
  5463. * Gets a boolean indicating if the Buffer is updatable?
  5464. * @returns true if the buffer is updatable
  5465. */
  5466. isUpdatable(): boolean;
  5467. /**
  5468. * Gets current buffer's data
  5469. * @returns a DataArray or null
  5470. */
  5471. getData(): Nullable<DataArray>;
  5472. /**
  5473. * Gets underlying native buffer
  5474. * @returns underlying native buffer
  5475. */
  5476. getBuffer(): Nullable<WebGLBuffer>;
  5477. /**
  5478. * Gets the stride in float32 units (i.e. byte stride / 4).
  5479. * May not be an integer if the byte stride is not divisible by 4.
  5480. * DEPRECATED. Use byteStride instead.
  5481. * @returns the stride in float32 units
  5482. */
  5483. getStrideSize(): number;
  5484. /**
  5485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5486. * @param data defines the data to store
  5487. */
  5488. create(data?: Nullable<DataArray>): void;
  5489. /** @hidden */
  5490. _rebuild(): void;
  5491. /**
  5492. * Update current buffer data
  5493. * @param data defines the data to store
  5494. */
  5495. update(data: DataArray): void;
  5496. /**
  5497. * Updates the data directly.
  5498. * @param data the new data
  5499. * @param offset the new offset
  5500. * @param vertexCount the vertex count (optional)
  5501. * @param useBytes set to true if the offset is in bytes
  5502. */
  5503. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5504. /**
  5505. * Release all resources
  5506. */
  5507. dispose(): void;
  5508. }
  5509. /**
  5510. * Specialized buffer used to store vertex data
  5511. */
  5512. export class VertexBuffer {
  5513. /** @hidden */
  5514. _buffer: Buffer;
  5515. private _kind;
  5516. private _size;
  5517. private _ownsBuffer;
  5518. private _instanced;
  5519. private _instanceDivisor;
  5520. /**
  5521. * The byte type.
  5522. */
  5523. static readonly BYTE: number;
  5524. /**
  5525. * The unsigned byte type.
  5526. */
  5527. static readonly UNSIGNED_BYTE: number;
  5528. /**
  5529. * The short type.
  5530. */
  5531. static readonly SHORT: number;
  5532. /**
  5533. * The unsigned short type.
  5534. */
  5535. static readonly UNSIGNED_SHORT: number;
  5536. /**
  5537. * The integer type.
  5538. */
  5539. static readonly INT: number;
  5540. /**
  5541. * The unsigned integer type.
  5542. */
  5543. static readonly UNSIGNED_INT: number;
  5544. /**
  5545. * The float type.
  5546. */
  5547. static readonly FLOAT: number;
  5548. /**
  5549. * Gets or sets the instance divisor when in instanced mode
  5550. */
  5551. instanceDivisor: number;
  5552. /**
  5553. * Gets the byte stride.
  5554. */
  5555. readonly byteStride: number;
  5556. /**
  5557. * Gets the byte offset.
  5558. */
  5559. readonly byteOffset: number;
  5560. /**
  5561. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5562. */
  5563. readonly normalized: boolean;
  5564. /**
  5565. * Gets the data type of each component in the array.
  5566. */
  5567. readonly type: number;
  5568. /**
  5569. * Constructor
  5570. * @param engine the engine
  5571. * @param data the data to use for this vertex buffer
  5572. * @param kind the vertex buffer kind
  5573. * @param updatable whether the data is updatable
  5574. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5575. * @param stride the stride (optional)
  5576. * @param instanced whether the buffer is instanced (optional)
  5577. * @param offset the offset of the data (optional)
  5578. * @param size the number of components (optional)
  5579. * @param type the type of the component (optional)
  5580. * @param normalized whether the data contains normalized data (optional)
  5581. * @param useBytes set to true if stride and offset are in bytes (optional)
  5582. */
  5583. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5584. /** @hidden */
  5585. _rebuild(): void;
  5586. /**
  5587. * Returns the kind of the VertexBuffer (string)
  5588. * @returns a string
  5589. */
  5590. getKind(): string;
  5591. /**
  5592. * Gets a boolean indicating if the VertexBuffer is updatable?
  5593. * @returns true if the buffer is updatable
  5594. */
  5595. isUpdatable(): boolean;
  5596. /**
  5597. * Gets current buffer's data
  5598. * @returns a DataArray or null
  5599. */
  5600. getData(): Nullable<DataArray>;
  5601. /**
  5602. * Gets underlying native buffer
  5603. * @returns underlying native buffer
  5604. */
  5605. getBuffer(): Nullable<WebGLBuffer>;
  5606. /**
  5607. * Gets the stride in float32 units (i.e. byte stride / 4).
  5608. * May not be an integer if the byte stride is not divisible by 4.
  5609. * DEPRECATED. Use byteStride instead.
  5610. * @returns the stride in float32 units
  5611. */
  5612. getStrideSize(): number;
  5613. /**
  5614. * Returns the offset as a multiple of the type byte length.
  5615. * DEPRECATED. Use byteOffset instead.
  5616. * @returns the offset in bytes
  5617. */
  5618. getOffset(): number;
  5619. /**
  5620. * Returns the number of components per vertex attribute (integer)
  5621. * @returns the size in float
  5622. */
  5623. getSize(): number;
  5624. /**
  5625. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5626. * @returns true if this buffer is instanced
  5627. */
  5628. getIsInstanced(): boolean;
  5629. /**
  5630. * Returns the instancing divisor, zero for non-instanced (integer).
  5631. * @returns a number
  5632. */
  5633. getInstanceDivisor(): number;
  5634. /**
  5635. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5636. * @param data defines the data to store
  5637. */
  5638. create(data?: DataArray): void;
  5639. /**
  5640. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5641. * This function will create a new buffer if the current one is not updatable
  5642. * @param data defines the data to store
  5643. */
  5644. update(data: DataArray): void;
  5645. /**
  5646. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5647. * Returns the directly updated WebGLBuffer.
  5648. * @param data the new data
  5649. * @param offset the new offset
  5650. * @param useBytes set to true if the offset is in bytes
  5651. */
  5652. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5653. /**
  5654. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5655. */
  5656. dispose(): void;
  5657. /**
  5658. * Enumerates each value of this vertex buffer as numbers.
  5659. * @param count the number of values to enumerate
  5660. * @param callback the callback function called for each value
  5661. */
  5662. forEach(count: number, callback: (value: number, index: number) => void): void;
  5663. /**
  5664. * Positions
  5665. */
  5666. static readonly PositionKind: string;
  5667. /**
  5668. * Normals
  5669. */
  5670. static readonly NormalKind: string;
  5671. /**
  5672. * Tangents
  5673. */
  5674. static readonly TangentKind: string;
  5675. /**
  5676. * Texture coordinates
  5677. */
  5678. static readonly UVKind: string;
  5679. /**
  5680. * Texture coordinates 2
  5681. */
  5682. static readonly UV2Kind: string;
  5683. /**
  5684. * Texture coordinates 3
  5685. */
  5686. static readonly UV3Kind: string;
  5687. /**
  5688. * Texture coordinates 4
  5689. */
  5690. static readonly UV4Kind: string;
  5691. /**
  5692. * Texture coordinates 5
  5693. */
  5694. static readonly UV5Kind: string;
  5695. /**
  5696. * Texture coordinates 6
  5697. */
  5698. static readonly UV6Kind: string;
  5699. /**
  5700. * Colors
  5701. */
  5702. static readonly ColorKind: string;
  5703. /**
  5704. * Matrix indices (for bones)
  5705. */
  5706. static readonly MatricesIndicesKind: string;
  5707. /**
  5708. * Matrix weights (for bones)
  5709. */
  5710. static readonly MatricesWeightsKind: string;
  5711. /**
  5712. * Additional matrix indices (for bones)
  5713. */
  5714. static readonly MatricesIndicesExtraKind: string;
  5715. /**
  5716. * Additional matrix weights (for bones)
  5717. */
  5718. static readonly MatricesWeightsExtraKind: string;
  5719. /**
  5720. * Deduces the stride given a kind.
  5721. * @param kind The kind string to deduce
  5722. * @returns The deduced stride
  5723. */
  5724. static DeduceStride(kind: string): number;
  5725. /**
  5726. * Gets the byte length of the given type.
  5727. * @param type the type
  5728. * @returns the number of bytes
  5729. */
  5730. static GetTypeByteLength(type: number): number;
  5731. /**
  5732. * Enumerates each value of the given parameters as numbers.
  5733. * @param data the data to enumerate
  5734. * @param byteOffset the byte offset of the data
  5735. * @param byteStride the byte stride of the data
  5736. * @param componentCount the number of components per element
  5737. * @param componentType the type of the component
  5738. * @param count the total number of components
  5739. * @param normalized whether the data is normalized
  5740. * @param callback the callback function called for each value
  5741. */
  5742. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5743. private static _GetFloatValue;
  5744. }
  5745. }
  5746. declare module "babylonjs/Maths/sphericalPolynomial" {
  5747. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5748. /**
  5749. * Class representing spherical polynomial coefficients to the 3rd degree
  5750. */
  5751. export class SphericalPolynomial {
  5752. /**
  5753. * The x coefficients of the spherical polynomial
  5754. */
  5755. x: Vector3;
  5756. /**
  5757. * The y coefficients of the spherical polynomial
  5758. */
  5759. y: Vector3;
  5760. /**
  5761. * The z coefficients of the spherical polynomial
  5762. */
  5763. z: Vector3;
  5764. /**
  5765. * The xx coefficients of the spherical polynomial
  5766. */
  5767. xx: Vector3;
  5768. /**
  5769. * The yy coefficients of the spherical polynomial
  5770. */
  5771. yy: Vector3;
  5772. /**
  5773. * The zz coefficients of the spherical polynomial
  5774. */
  5775. zz: Vector3;
  5776. /**
  5777. * The xy coefficients of the spherical polynomial
  5778. */
  5779. xy: Vector3;
  5780. /**
  5781. * The yz coefficients of the spherical polynomial
  5782. */
  5783. yz: Vector3;
  5784. /**
  5785. * The zx coefficients of the spherical polynomial
  5786. */
  5787. zx: Vector3;
  5788. /**
  5789. * Adds an ambient color to the spherical polynomial
  5790. * @param color the color to add
  5791. */
  5792. addAmbient(color: Color3): void;
  5793. /**
  5794. * Scales the spherical polynomial by the given amount
  5795. * @param scale the amount to scale
  5796. */
  5797. scale(scale: number): void;
  5798. /**
  5799. * Gets the spherical polynomial from harmonics
  5800. * @param harmonics the spherical harmonics
  5801. * @returns the spherical polynomial
  5802. */
  5803. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5804. /**
  5805. * Constructs a spherical polynomial from an array.
  5806. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5807. * @returns the spherical polynomial
  5808. */
  5809. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5810. }
  5811. /**
  5812. * Class representing spherical harmonics coefficients to the 3rd degree
  5813. */
  5814. export class SphericalHarmonics {
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. lL22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scale(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Gets the spherical harmonics from polynomial
  5887. * @param polynomial the spherical polynomial
  5888. * @returns the spherical harmonics
  5889. */
  5890. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5891. /**
  5892. * Constructs a spherical harmonics from an array.
  5893. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5894. * @returns the spherical harmonics
  5895. */
  5896. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5897. }
  5898. }
  5899. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5900. import { Nullable } from "babylonjs/types";
  5901. /**
  5902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5903. */
  5904. export interface CubeMapInfo {
  5905. /**
  5906. * The pixel array for the front face.
  5907. * This is stored in format, left to right, up to down format.
  5908. */
  5909. front: Nullable<ArrayBufferView>;
  5910. /**
  5911. * The pixel array for the back face.
  5912. * This is stored in format, left to right, up to down format.
  5913. */
  5914. back: Nullable<ArrayBufferView>;
  5915. /**
  5916. * The pixel array for the left face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. left: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the right face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. right: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the up face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. up: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the down face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. down: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The size of the cubemap stored.
  5937. *
  5938. * Each faces will be size * size pixels.
  5939. */
  5940. size: number;
  5941. /**
  5942. * The format of the texture.
  5943. *
  5944. * RGBA, RGB.
  5945. */
  5946. format: number;
  5947. /**
  5948. * The type of the texture data.
  5949. *
  5950. * UNSIGNED_INT, FLOAT.
  5951. */
  5952. type: number;
  5953. /**
  5954. * Specifies whether the texture is in gamma space.
  5955. */
  5956. gammaSpace: boolean;
  5957. }
  5958. /**
  5959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5960. */
  5961. export class PanoramaToCubeMapTools {
  5962. private static FACE_FRONT;
  5963. private static FACE_BACK;
  5964. private static FACE_RIGHT;
  5965. private static FACE_LEFT;
  5966. private static FACE_DOWN;
  5967. private static FACE_UP;
  5968. /**
  5969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5970. *
  5971. * @param float32Array The source data.
  5972. * @param inputWidth The width of the input panorama.
  5973. * @param inputHeight The height of the input panorama.
  5974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5975. * @return The cubemap data
  5976. */
  5977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5978. private static CreateCubemapTexture;
  5979. private static CalcProjectionSpherical;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5983. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5985. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5986. /**
  5987. * Helper class dealing with the extraction of spherical polynomial dataArray
  5988. * from a cube map.
  5989. */
  5990. export class CubeMapToSphericalPolynomialTools {
  5991. private static FileFaces;
  5992. /**
  5993. * Converts a texture to the according Spherical Polynomial data.
  5994. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5995. *
  5996. * @param texture The texture to extract the information from.
  5997. * @return The Spherical Polynomial data.
  5998. */
  5999. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6000. /**
  6001. * Converts a cubemap to the according Spherical Polynomial data.
  6002. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6003. *
  6004. * @param cubeInfo The Cube map to extract the information from.
  6005. * @return The Spherical Polynomial data.
  6006. */
  6007. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6008. }
  6009. }
  6010. declare module "babylonjs/Engines/engineStore" {
  6011. import { Nullable } from "babylonjs/types";
  6012. import { Engine } from "babylonjs/Engines/engine";
  6013. import { Scene } from "babylonjs/scene";
  6014. /**
  6015. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6016. * during the life time of the application.
  6017. */
  6018. export class EngineStore {
  6019. /** Gets the list of created engines */
  6020. static Instances: import("babylonjs/Engines/engine").Engine[];
  6021. /**
  6022. * Gets the latest created engine
  6023. */
  6024. static readonly LastCreatedEngine: Nullable<Engine>;
  6025. /**
  6026. * Gets the latest created scene
  6027. */
  6028. static readonly LastCreatedScene: Nullable<Scene>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6032. /**
  6033. * Define options used to create a render target texture
  6034. */
  6035. export class RenderTargetCreationOptions {
  6036. /**
  6037. * Specifies is mipmaps must be generated
  6038. */
  6039. generateMipMaps?: boolean;
  6040. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6041. generateDepthBuffer?: boolean;
  6042. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6043. generateStencilBuffer?: boolean;
  6044. /** Defines texture type (int by default) */
  6045. type?: number;
  6046. /** Defines sampling mode (trilinear by default) */
  6047. samplingMode?: number;
  6048. /** Defines format (RGBA by default) */
  6049. format?: number;
  6050. }
  6051. }
  6052. declare module "babylonjs/States/alphaCullingState" {
  6053. /**
  6054. * @hidden
  6055. **/
  6056. export class _AlphaState {
  6057. private _isAlphaBlendDirty;
  6058. private _isBlendFunctionParametersDirty;
  6059. private _isBlendEquationParametersDirty;
  6060. private _isBlendConstantsDirty;
  6061. private _alphaBlend;
  6062. private _blendFunctionParameters;
  6063. private _blendEquationParameters;
  6064. private _blendConstants;
  6065. /**
  6066. * Initializes the state.
  6067. */
  6068. constructor();
  6069. readonly isDirty: boolean;
  6070. alphaBlend: boolean;
  6071. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6072. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6073. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6074. reset(): void;
  6075. apply(gl: WebGLRenderingContext): void;
  6076. }
  6077. }
  6078. declare module "babylonjs/States/depthCullingState" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _DepthCullingState {
  6084. private _isDepthTestDirty;
  6085. private _isDepthMaskDirty;
  6086. private _isDepthFuncDirty;
  6087. private _isCullFaceDirty;
  6088. private _isCullDirty;
  6089. private _isZOffsetDirty;
  6090. private _isFrontFaceDirty;
  6091. private _depthTest;
  6092. private _depthMask;
  6093. private _depthFunc;
  6094. private _cull;
  6095. private _cullFace;
  6096. private _zOffset;
  6097. private _frontFace;
  6098. /**
  6099. * Initializes the state.
  6100. */
  6101. constructor();
  6102. readonly isDirty: boolean;
  6103. zOffset: number;
  6104. cullFace: Nullable<number>;
  6105. cull: Nullable<boolean>;
  6106. depthFunc: Nullable<number>;
  6107. depthMask: boolean;
  6108. depthTest: boolean;
  6109. frontFace: Nullable<number>;
  6110. reset(): void;
  6111. apply(gl: WebGLRenderingContext): void;
  6112. }
  6113. }
  6114. declare module "babylonjs/States/stencilState" {
  6115. /**
  6116. * @hidden
  6117. **/
  6118. export class _StencilState {
  6119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6120. static readonly ALWAYS: number;
  6121. /** Passed to stencilOperation to specify that stencil value must be kept */
  6122. static readonly KEEP: number;
  6123. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6124. static readonly REPLACE: number;
  6125. private _isStencilTestDirty;
  6126. private _isStencilMaskDirty;
  6127. private _isStencilFuncDirty;
  6128. private _isStencilOpDirty;
  6129. private _stencilTest;
  6130. private _stencilMask;
  6131. private _stencilFunc;
  6132. private _stencilFuncRef;
  6133. private _stencilFuncMask;
  6134. private _stencilOpStencilFail;
  6135. private _stencilOpDepthFail;
  6136. private _stencilOpStencilDepthPass;
  6137. readonly isDirty: boolean;
  6138. stencilFunc: number;
  6139. stencilFuncRef: number;
  6140. stencilFuncMask: number;
  6141. stencilOpStencilFail: number;
  6142. stencilOpDepthFail: number;
  6143. stencilOpStencilDepthPass: number;
  6144. stencilMask: number;
  6145. stencilTest: boolean;
  6146. constructor();
  6147. reset(): void;
  6148. apply(gl: WebGLRenderingContext): void;
  6149. }
  6150. }
  6151. declare module "babylonjs/States/index" {
  6152. export * from "babylonjs/States/alphaCullingState";
  6153. export * from "babylonjs/States/depthCullingState";
  6154. export * from "babylonjs/States/stencilState";
  6155. }
  6156. declare module "babylonjs/Instrumentation/timeToken" {
  6157. import { Nullable } from "babylonjs/types";
  6158. /**
  6159. * @hidden
  6160. **/
  6161. export class _TimeToken {
  6162. _startTimeQuery: Nullable<WebGLQuery>;
  6163. _endTimeQuery: Nullable<WebGLQuery>;
  6164. _timeElapsedQuery: Nullable<WebGLQuery>;
  6165. _timeElapsedQueryEnded: boolean;
  6166. }
  6167. }
  6168. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6169. import { Nullable } from "babylonjs/types";
  6170. /**
  6171. * Internal interface used to track InternalTexture already bound to the GL context
  6172. */
  6173. export interface IInternalTextureTracker {
  6174. /**
  6175. * Gets or set the previous tracker in the list
  6176. */
  6177. previous: Nullable<IInternalTextureTracker>;
  6178. /**
  6179. * Gets or set the next tracker in the list
  6180. */
  6181. next: Nullable<IInternalTextureTracker>;
  6182. }
  6183. /**
  6184. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6185. */
  6186. export class DummyInternalTextureTracker {
  6187. /**
  6188. * Gets or set the previous tracker in the list
  6189. */
  6190. previous: Nullable<IInternalTextureTracker>;
  6191. /**
  6192. * Gets or set the next tracker in the list
  6193. */
  6194. next: Nullable<IInternalTextureTracker>;
  6195. }
  6196. }
  6197. declare module "babylonjs/Materials/Textures/internalTexture" {
  6198. import { Observable } from "babylonjs/Misc/observable";
  6199. import { Nullable, int } from "babylonjs/types";
  6200. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6201. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6202. import { Engine } from "babylonjs/Engines/engine";
  6203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6204. /**
  6205. * Class used to store data associated with WebGL texture data for the engine
  6206. * This class should not be used directly
  6207. */
  6208. export class InternalTexture implements IInternalTextureTracker {
  6209. /** hidden */
  6210. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6211. /**
  6212. * The source of the texture data is unknown
  6213. */
  6214. static DATASOURCE_UNKNOWN: number;
  6215. /**
  6216. * Texture data comes from an URL
  6217. */
  6218. static DATASOURCE_URL: number;
  6219. /**
  6220. * Texture data is only used for temporary storage
  6221. */
  6222. static DATASOURCE_TEMP: number;
  6223. /**
  6224. * Texture data comes from raw data (ArrayBuffer)
  6225. */
  6226. static DATASOURCE_RAW: number;
  6227. /**
  6228. * Texture content is dynamic (video or dynamic texture)
  6229. */
  6230. static DATASOURCE_DYNAMIC: number;
  6231. /**
  6232. * Texture content is generated by rendering to it
  6233. */
  6234. static DATASOURCE_RENDERTARGET: number;
  6235. /**
  6236. * Texture content is part of a multi render target process
  6237. */
  6238. static DATASOURCE_MULTIRENDERTARGET: number;
  6239. /**
  6240. * Texture data comes from a cube data file
  6241. */
  6242. static DATASOURCE_CUBE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data
  6245. */
  6246. static DATASOURCE_CUBERAW: number;
  6247. /**
  6248. * Texture data come from a prefiltered cube data file
  6249. */
  6250. static DATASOURCE_CUBEPREFILTERED: number;
  6251. /**
  6252. * Texture content is raw 3D data
  6253. */
  6254. static DATASOURCE_RAW3D: number;
  6255. /**
  6256. * Texture content is a depth texture
  6257. */
  6258. static DATASOURCE_DEPTHTEXTURE: number;
  6259. /**
  6260. * Texture data comes from a raw cube data encoded with RGBD
  6261. */
  6262. static DATASOURCE_CUBERAW_RGBD: number;
  6263. /**
  6264. * Defines if the texture is ready
  6265. */
  6266. isReady: boolean;
  6267. /**
  6268. * Defines if the texture is a cube texture
  6269. */
  6270. isCube: boolean;
  6271. /**
  6272. * Defines if the texture contains 3D data
  6273. */
  6274. is3D: boolean;
  6275. /**
  6276. * Gets the URL used to load this texture
  6277. */
  6278. url: string;
  6279. /**
  6280. * Gets the sampling mode of the texture
  6281. */
  6282. samplingMode: number;
  6283. /**
  6284. * Gets a boolean indicating if the texture needs mipmaps generation
  6285. */
  6286. generateMipMaps: boolean;
  6287. /**
  6288. * Gets the number of samples used by the texture (WebGL2+ only)
  6289. */
  6290. samples: number;
  6291. /**
  6292. * Gets the type of the texture (int, float...)
  6293. */
  6294. type: number;
  6295. /**
  6296. * Gets the format of the texture (RGB, RGBA...)
  6297. */
  6298. format: number;
  6299. /**
  6300. * Observable called when the texture is loaded
  6301. */
  6302. onLoadedObservable: Observable<InternalTexture>;
  6303. /**
  6304. * Gets the width of the texture
  6305. */
  6306. width: number;
  6307. /**
  6308. * Gets the height of the texture
  6309. */
  6310. height: number;
  6311. /**
  6312. * Gets the depth of the texture
  6313. */
  6314. depth: number;
  6315. /**
  6316. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6317. */
  6318. baseWidth: number;
  6319. /**
  6320. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6321. */
  6322. baseHeight: number;
  6323. /**
  6324. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6325. */
  6326. baseDepth: number;
  6327. /**
  6328. * Gets a boolean indicating if the texture is inverted on Y axis
  6329. */
  6330. invertY: boolean;
  6331. /**
  6332. * Gets or set the previous tracker in the list
  6333. */
  6334. previous: Nullable<IInternalTextureTracker>;
  6335. /**
  6336. * Gets or set the next tracker in the list
  6337. */
  6338. next: Nullable<IInternalTextureTracker>;
  6339. /** @hidden */
  6340. _invertVScale: boolean;
  6341. /** @hidden */
  6342. _initialSlot: number;
  6343. /** @hidden */
  6344. _designatedSlot: number;
  6345. /** @hidden */
  6346. _dataSource: number;
  6347. /** @hidden */
  6348. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6349. /** @hidden */
  6350. _bufferView: Nullable<ArrayBufferView>;
  6351. /** @hidden */
  6352. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6353. /** @hidden */
  6354. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6355. /** @hidden */
  6356. _size: number;
  6357. /** @hidden */
  6358. _extension: string;
  6359. /** @hidden */
  6360. _files: Nullable<string[]>;
  6361. /** @hidden */
  6362. _workingCanvas: HTMLCanvasElement;
  6363. /** @hidden */
  6364. _workingContext: CanvasRenderingContext2D;
  6365. /** @hidden */
  6366. _framebuffer: Nullable<WebGLFramebuffer>;
  6367. /** @hidden */
  6368. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6369. /** @hidden */
  6370. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6371. /** @hidden */
  6372. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6373. /** @hidden */
  6374. _attachments: Nullable<number[]>;
  6375. /** @hidden */
  6376. _cachedCoordinatesMode: Nullable<number>;
  6377. /** @hidden */
  6378. _cachedWrapU: Nullable<number>;
  6379. /** @hidden */
  6380. _cachedWrapV: Nullable<number>;
  6381. /** @hidden */
  6382. _cachedWrapR: Nullable<number>;
  6383. /** @hidden */
  6384. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6385. /** @hidden */
  6386. _isDisabled: boolean;
  6387. /** @hidden */
  6388. _compression: Nullable<string>;
  6389. /** @hidden */
  6390. _generateStencilBuffer: boolean;
  6391. /** @hidden */
  6392. _generateDepthBuffer: boolean;
  6393. /** @hidden */
  6394. _comparisonFunction: number;
  6395. /** @hidden */
  6396. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6397. /** @hidden */
  6398. _lodGenerationScale: number;
  6399. /** @hidden */
  6400. _lodGenerationOffset: number;
  6401. /** @hidden */
  6402. _lodTextureHigh: BaseTexture;
  6403. /** @hidden */
  6404. _lodTextureMid: BaseTexture;
  6405. /** @hidden */
  6406. _lodTextureLow: BaseTexture;
  6407. /** @hidden */
  6408. _isRGBD: boolean;
  6409. /** @hidden */
  6410. _webGLTexture: Nullable<WebGLTexture>;
  6411. /** @hidden */
  6412. _references: number;
  6413. private _engine;
  6414. /**
  6415. * Gets the Engine the texture belongs to.
  6416. * @returns The babylon engine
  6417. */
  6418. getEngine(): Engine;
  6419. /**
  6420. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6421. */
  6422. readonly dataSource: number;
  6423. /**
  6424. * Creates a new InternalTexture
  6425. * @param engine defines the engine to use
  6426. * @param dataSource defines the type of data that will be used
  6427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6428. */
  6429. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6430. /**
  6431. * Increments the number of references (ie. the number of Texture that point to it)
  6432. */
  6433. incrementReferences(): void;
  6434. /**
  6435. * Change the size of the texture (not the size of the content)
  6436. * @param width defines the new width
  6437. * @param height defines the new height
  6438. * @param depth defines the new depth (1 by default)
  6439. */
  6440. updateSize(width: int, height: int, depth?: int): void;
  6441. /** @hidden */
  6442. _rebuild(): void;
  6443. /** @hidden */
  6444. _swapAndDie(target: InternalTexture): void;
  6445. /**
  6446. * Dispose the current allocated resources
  6447. */
  6448. dispose(): void;
  6449. }
  6450. }
  6451. declare module "babylonjs/Animations/easing" {
  6452. /**
  6453. * This represents the main contract an easing function should follow.
  6454. * Easing functions are used throughout the animation system.
  6455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6456. */
  6457. export interface IEasingFunction {
  6458. /**
  6459. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6460. * of the easing function.
  6461. * The link below provides some of the most common examples of easing functions.
  6462. * @see https://easings.net/
  6463. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6464. * @returns the corresponding value on the curve defined by the easing function
  6465. */
  6466. ease(gradient: number): number;
  6467. }
  6468. /**
  6469. * Base class used for every default easing function.
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class EasingFunction implements IEasingFunction {
  6473. /**
  6474. * Interpolation follows the mathematical formula associated with the easing function.
  6475. */
  6476. static readonly EASINGMODE_EASEIN: number;
  6477. /**
  6478. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6479. */
  6480. static readonly EASINGMODE_EASEOUT: number;
  6481. /**
  6482. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6483. */
  6484. static readonly EASINGMODE_EASEINOUT: number;
  6485. private _easingMode;
  6486. /**
  6487. * Sets the easing mode of the current function.
  6488. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6489. */
  6490. setEasingMode(easingMode: number): void;
  6491. /**
  6492. * Gets the current easing mode.
  6493. * @returns the easing mode
  6494. */
  6495. getEasingMode(): number;
  6496. /**
  6497. * @hidden
  6498. */
  6499. easeInCore(gradient: number): number;
  6500. /**
  6501. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6502. * of the easing function.
  6503. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6504. * @returns the corresponding value on the curve defined by the easing function
  6505. */
  6506. ease(gradient: number): number;
  6507. }
  6508. /**
  6509. * Easing function with a circle shape (see link below).
  6510. * @see https://easings.net/#easeInCirc
  6511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6512. */
  6513. export class CircleEase extends EasingFunction implements IEasingFunction {
  6514. /** @hidden */
  6515. easeInCore(gradient: number): number;
  6516. }
  6517. /**
  6518. * Easing function with a ease back shape (see link below).
  6519. * @see https://easings.net/#easeInBack
  6520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6521. */
  6522. export class BackEase extends EasingFunction implements IEasingFunction {
  6523. /** Defines the amplitude of the function */
  6524. amplitude: number;
  6525. /**
  6526. * Instantiates a back ease easing
  6527. * @see https://easings.net/#easeInBack
  6528. * @param amplitude Defines the amplitude of the function
  6529. */
  6530. constructor(
  6531. /** Defines the amplitude of the function */
  6532. amplitude?: number);
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a bouncing shape (see link below).
  6538. * @see https://easings.net/#easeInBounce
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class BounceEase extends EasingFunction implements IEasingFunction {
  6542. /** Defines the number of bounces */
  6543. bounces: number;
  6544. /** Defines the amplitude of the bounce */
  6545. bounciness: number;
  6546. /**
  6547. * Instantiates a bounce easing
  6548. * @see https://easings.net/#easeInBounce
  6549. * @param bounces Defines the number of bounces
  6550. * @param bounciness Defines the amplitude of the bounce
  6551. */
  6552. constructor(
  6553. /** Defines the number of bounces */
  6554. bounces?: number,
  6555. /** Defines the amplitude of the bounce */
  6556. bounciness?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 3 shape (see link below).
  6562. * @see https://easings.net/#easeInCubic
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class CubicEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with an elastic shape (see link below).
  6571. * @see https://easings.net/#easeInElastic
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6575. /** Defines the number of oscillations*/
  6576. oscillations: number;
  6577. /** Defines the amplitude of the oscillations*/
  6578. springiness: number;
  6579. /**
  6580. * Instantiates an elastic easing function
  6581. * @see https://easings.net/#easeInElastic
  6582. * @param oscillations Defines the number of oscillations
  6583. * @param springiness Defines the amplitude of the oscillations
  6584. */
  6585. constructor(
  6586. /** Defines the number of oscillations*/
  6587. oscillations?: number,
  6588. /** Defines the amplitude of the oscillations*/
  6589. springiness?: number);
  6590. /** @hidden */
  6591. easeInCore(gradient: number): number;
  6592. }
  6593. /**
  6594. * Easing function with an exponential shape (see link below).
  6595. * @see https://easings.net/#easeInExpo
  6596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6597. */
  6598. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6599. /** Defines the exponent of the function */
  6600. exponent: number;
  6601. /**
  6602. * Instantiates an exponential easing function
  6603. * @see https://easings.net/#easeInExpo
  6604. * @param exponent Defines the exponent of the function
  6605. */
  6606. constructor(
  6607. /** Defines the exponent of the function */
  6608. exponent?: number);
  6609. /** @hidden */
  6610. easeInCore(gradient: number): number;
  6611. }
  6612. /**
  6613. * Easing function with a power shape (see link below).
  6614. * @see https://easings.net/#easeInQuad
  6615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6616. */
  6617. export class PowerEase extends EasingFunction implements IEasingFunction {
  6618. /** Defines the power of the function */
  6619. power: number;
  6620. /**
  6621. * Instantiates an power base easing function
  6622. * @see https://easings.net/#easeInQuad
  6623. * @param power Defines the power of the function
  6624. */
  6625. constructor(
  6626. /** Defines the power of the function */
  6627. power?: number);
  6628. /** @hidden */
  6629. easeInCore(gradient: number): number;
  6630. }
  6631. /**
  6632. * Easing function with a power of 2 shape (see link below).
  6633. * @see https://easings.net/#easeInQuad
  6634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6635. */
  6636. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6637. /** @hidden */
  6638. easeInCore(gradient: number): number;
  6639. }
  6640. /**
  6641. * Easing function with a power of 4 shape (see link below).
  6642. * @see https://easings.net/#easeInQuart
  6643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6644. */
  6645. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 5 shape (see link below).
  6651. * @see https://easings.net/#easeInQuint
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a sin shape (see link below).
  6660. * @see https://easings.net/#easeInSine
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class SineEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a bezier shape (see link below).
  6669. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6673. /** Defines the x component of the start tangent in the bezier curve */
  6674. x1: number;
  6675. /** Defines the y component of the start tangent in the bezier curve */
  6676. y1: number;
  6677. /** Defines the x component of the end tangent in the bezier curve */
  6678. x2: number;
  6679. /** Defines the y component of the end tangent in the bezier curve */
  6680. y2: number;
  6681. /**
  6682. * Instantiates a bezier function
  6683. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6684. * @param x1 Defines the x component of the start tangent in the bezier curve
  6685. * @param y1 Defines the y component of the start tangent in the bezier curve
  6686. * @param x2 Defines the x component of the end tangent in the bezier curve
  6687. * @param y2 Defines the y component of the end tangent in the bezier curve
  6688. */
  6689. constructor(
  6690. /** Defines the x component of the start tangent in the bezier curve */
  6691. x1?: number,
  6692. /** Defines the y component of the start tangent in the bezier curve */
  6693. y1?: number,
  6694. /** Defines the x component of the end tangent in the bezier curve */
  6695. x2?: number,
  6696. /** Defines the y component of the end tangent in the bezier curve */
  6697. y2?: number);
  6698. /** @hidden */
  6699. easeInCore(gradient: number): number;
  6700. }
  6701. }
  6702. declare module "babylonjs/Animations/animationKey" {
  6703. /**
  6704. * Defines an interface which represents an animation key frame
  6705. */
  6706. export interface IAnimationKey {
  6707. /**
  6708. * Frame of the key frame
  6709. */
  6710. frame: number;
  6711. /**
  6712. * Value at the specifies key frame
  6713. */
  6714. value: any;
  6715. /**
  6716. * The input tangent for the cubic hermite spline
  6717. */
  6718. inTangent?: any;
  6719. /**
  6720. * The output tangent for the cubic hermite spline
  6721. */
  6722. outTangent?: any;
  6723. /**
  6724. * The animation interpolation type
  6725. */
  6726. interpolation?: AnimationKeyInterpolation;
  6727. }
  6728. /**
  6729. * Enum for the animation key frame interpolation type
  6730. */
  6731. export enum AnimationKeyInterpolation {
  6732. /**
  6733. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6734. */
  6735. STEP = 1
  6736. }
  6737. }
  6738. declare module "babylonjs/Animations/animationRange" {
  6739. /**
  6740. * Represents the range of an animation
  6741. */
  6742. export class AnimationRange {
  6743. /**The name of the animation range**/
  6744. name: string;
  6745. /**The starting frame of the animation */
  6746. from: number;
  6747. /**The ending frame of the animation*/
  6748. to: number;
  6749. /**
  6750. * Initializes the range of an animation
  6751. * @param name The name of the animation range
  6752. * @param from The starting frame of the animation
  6753. * @param to The ending frame of the animation
  6754. */
  6755. constructor(
  6756. /**The name of the animation range**/
  6757. name: string,
  6758. /**The starting frame of the animation */
  6759. from: number,
  6760. /**The ending frame of the animation*/
  6761. to: number);
  6762. /**
  6763. * Makes a copy of the animation range
  6764. * @returns A copy of the animation range
  6765. */
  6766. clone(): AnimationRange;
  6767. }
  6768. }
  6769. declare module "babylonjs/Animations/animationEvent" {
  6770. /**
  6771. * Composed of a frame, and an action function
  6772. */
  6773. export class AnimationEvent {
  6774. /** The frame for which the event is triggered **/
  6775. frame: number;
  6776. /** The event to perform when triggered **/
  6777. action: (currentFrame: number) => void;
  6778. /** Specifies if the event should be triggered only once**/
  6779. onlyOnce?: boolean | undefined;
  6780. /**
  6781. * Specifies if the animation event is done
  6782. */
  6783. isDone: boolean;
  6784. /**
  6785. * Initializes the animation event
  6786. * @param frame The frame for which the event is triggered
  6787. * @param action The event to perform when triggered
  6788. * @param onlyOnce Specifies if the event should be triggered only once
  6789. */
  6790. constructor(
  6791. /** The frame for which the event is triggered **/
  6792. frame: number,
  6793. /** The event to perform when triggered **/
  6794. action: (currentFrame: number) => void,
  6795. /** Specifies if the event should be triggered only once**/
  6796. onlyOnce?: boolean | undefined);
  6797. /** @hidden */
  6798. _clone(): AnimationEvent;
  6799. }
  6800. }
  6801. declare module "babylonjs/Behaviors/behavior" {
  6802. import { Nullable } from "babylonjs/types";
  6803. /**
  6804. * Interface used to define a behavior
  6805. */
  6806. export interface Behavior<T> {
  6807. /** gets or sets behavior's name */
  6808. name: string;
  6809. /**
  6810. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6811. */
  6812. init(): void;
  6813. /**
  6814. * Called when the behavior is attached to a target
  6815. * @param target defines the target where the behavior is attached to
  6816. */
  6817. attach(target: T): void;
  6818. /**
  6819. * Called when the behavior is detached from its target
  6820. */
  6821. detach(): void;
  6822. }
  6823. /**
  6824. * Interface implemented by classes supporting behaviors
  6825. */
  6826. export interface IBehaviorAware<T> {
  6827. /**
  6828. * Attach a behavior
  6829. * @param behavior defines the behavior to attach
  6830. * @returns the current host
  6831. */
  6832. addBehavior(behavior: Behavior<T>): T;
  6833. /**
  6834. * Remove a behavior from the current object
  6835. * @param behavior defines the behavior to detach
  6836. * @returns the current host
  6837. */
  6838. removeBehavior(behavior: Behavior<T>): T;
  6839. /**
  6840. * Gets a behavior using its name to search
  6841. * @param name defines the name to search
  6842. * @returns the behavior or null if not found
  6843. */
  6844. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6845. }
  6846. }
  6847. declare module "babylonjs/Collisions/intersectionInfo" {
  6848. import { Nullable } from "babylonjs/types";
  6849. /**
  6850. * @hidden
  6851. */
  6852. export class IntersectionInfo {
  6853. bu: Nullable<number>;
  6854. bv: Nullable<number>;
  6855. distance: number;
  6856. faceId: number;
  6857. subMeshId: number;
  6858. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6859. }
  6860. }
  6861. declare module "babylonjs/Culling/boundingSphere" {
  6862. import { DeepImmutable } from "babylonjs/types";
  6863. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6864. /**
  6865. * Class used to store bounding sphere information
  6866. */
  6867. export class BoundingSphere {
  6868. /**
  6869. * Gets the center of the bounding sphere in local space
  6870. */
  6871. readonly center: Vector3;
  6872. /**
  6873. * Radius of the bounding sphere in local space
  6874. */
  6875. radius: number;
  6876. /**
  6877. * Gets the center of the bounding sphere in world space
  6878. */
  6879. readonly centerWorld: Vector3;
  6880. /**
  6881. * Radius of the bounding sphere in world space
  6882. */
  6883. radiusWorld: number;
  6884. /**
  6885. * Gets the minimum vector in local space
  6886. */
  6887. readonly minimum: Vector3;
  6888. /**
  6889. * Gets the maximum vector in local space
  6890. */
  6891. readonly maximum: Vector3;
  6892. private _worldMatrix;
  6893. private static readonly TmpVector3;
  6894. /**
  6895. * Creates a new bounding sphere
  6896. * @param min defines the minimum vector (in local space)
  6897. * @param max defines the maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6901. /**
  6902. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6903. * @param min defines the new minimum vector (in local space)
  6904. * @param max defines the new maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6908. /**
  6909. * Scale the current bounding sphere by applying a scale factor
  6910. * @param factor defines the scale factor to apply
  6911. * @returns the current bounding box
  6912. */
  6913. scale(factor: number): BoundingSphere;
  6914. /**
  6915. * Gets the world matrix of the bounding box
  6916. * @returns a matrix
  6917. */
  6918. getWorldMatrix(): DeepImmutable<Matrix>;
  6919. /** @hidden */
  6920. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6921. /**
  6922. * Tests if the bounding sphere is intersecting the frustum planes
  6923. * @param frustumPlanes defines the frustum planes to test
  6924. * @returns true if there is an intersection
  6925. */
  6926. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6927. /**
  6928. * Tests if the bounding sphere center is in between the frustum planes.
  6929. * Used for optimistic fast inclusion.
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if the sphere center is in between the frustum planes
  6932. */
  6933. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a point is inside the bounding sphere
  6936. * @param point defines the point to test
  6937. * @returns true if the point is inside the bounding sphere
  6938. */
  6939. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6940. /**
  6941. * Checks if two sphere intersct
  6942. * @param sphere0 sphere 0
  6943. * @param sphere1 sphere 1
  6944. * @returns true if the speres intersect
  6945. */
  6946. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6947. }
  6948. }
  6949. declare module "babylonjs/Culling/boundingBox" {
  6950. import { DeepImmutable } from "babylonjs/types";
  6951. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6952. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6953. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6954. /**
  6955. * Class used to store bounding box information
  6956. */
  6957. export class BoundingBox implements ICullable {
  6958. /**
  6959. * Gets the 8 vectors representing the bounding box in local space
  6960. */
  6961. readonly vectors: Vector3[];
  6962. /**
  6963. * Gets the center of the bounding box in local space
  6964. */
  6965. readonly center: Vector3;
  6966. /**
  6967. * Gets the center of the bounding box in world space
  6968. */
  6969. readonly centerWorld: Vector3;
  6970. /**
  6971. * Gets the extend size in local space
  6972. */
  6973. readonly extendSize: Vector3;
  6974. /**
  6975. * Gets the extend size in world space
  6976. */
  6977. readonly extendSizeWorld: Vector3;
  6978. /**
  6979. * Gets the OBB (object bounding box) directions
  6980. */
  6981. readonly directions: Vector3[];
  6982. /**
  6983. * Gets the 8 vectors representing the bounding box in world space
  6984. */
  6985. readonly vectorsWorld: Vector3[];
  6986. /**
  6987. * Gets the minimum vector in world space
  6988. */
  6989. readonly minimumWorld: Vector3;
  6990. /**
  6991. * Gets the maximum vector in world space
  6992. */
  6993. readonly maximumWorld: Vector3;
  6994. /**
  6995. * Gets the minimum vector in local space
  6996. */
  6997. readonly minimum: Vector3;
  6998. /**
  6999. * Gets the maximum vector in local space
  7000. */
  7001. readonly maximum: Vector3;
  7002. private _worldMatrix;
  7003. private static readonly TmpVector3;
  7004. /**
  7005. * @hidden
  7006. */
  7007. _tag: number;
  7008. /**
  7009. * Creates a new bounding box
  7010. * @param min defines the minimum vector (in local space)
  7011. * @param max defines the maximum vector (in local space)
  7012. * @param worldMatrix defines the new world matrix
  7013. */
  7014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7015. /**
  7016. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7017. * @param min defines the new minimum vector (in local space)
  7018. * @param max defines the new maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Scale the current bounding box by applying a scale factor
  7024. * @param factor defines the scale factor to apply
  7025. * @returns the current bounding box
  7026. */
  7027. scale(factor: number): BoundingBox;
  7028. /**
  7029. * Gets the world matrix of the bounding box
  7030. * @returns a matrix
  7031. */
  7032. getWorldMatrix(): DeepImmutable<Matrix>;
  7033. /** @hidden */
  7034. _update(world: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Tests if the bounding box is intersecting the frustum planes
  7037. * @param frustumPlanes defines the frustum planes to test
  7038. * @returns true if there is an intersection
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7041. /**
  7042. * Tests if the bounding box is entirely inside the frustum planes
  7043. * @param frustumPlanes defines the frustum planes to test
  7044. * @returns true if there is an inclusion
  7045. */
  7046. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7047. /**
  7048. * Tests if a point is inside the bounding box
  7049. * @param point defines the point to test
  7050. * @returns true if the point is inside the bounding box
  7051. */
  7052. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7053. /**
  7054. * Tests if the bounding box intersects with a bounding sphere
  7055. * @param sphere defines the sphere to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7059. /**
  7060. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7061. * @param min defines the min vector to use
  7062. * @param max defines the max vector to use
  7063. * @returns true if there is an intersection
  7064. */
  7065. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if two bounding boxes are intersections
  7068. * @param box0 defines the first box to test
  7069. * @param box1 defines the second box to test
  7070. * @returns true if there is an intersection
  7071. */
  7072. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7073. /**
  7074. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7075. * @param minPoint defines the minimum vector of the bounding box
  7076. * @param maxPoint defines the maximum vector of the bounding box
  7077. * @param sphereCenter defines the sphere center
  7078. * @param sphereRadius defines the sphere radius
  7079. * @returns true if there is an intersection
  7080. */
  7081. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7082. /**
  7083. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7084. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7085. * @param frustumPlanes defines the frustum planes to test
  7086. * @return true if there is an inclusion
  7087. */
  7088. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /**
  7090. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7091. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7092. * @param frustumPlanes defines the frustum planes to test
  7093. * @return true if there is an intersection
  7094. */
  7095. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7096. }
  7097. }
  7098. declare module "babylonjs/Collisions/collider" {
  7099. import { Nullable, IndicesArray } from "babylonjs/types";
  7100. import { Vector3, Plane } from "babylonjs/Maths/math";
  7101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. collisionMask: number;
  7145. /**
  7146. * Gets the plane normal used to compute the sliding response (in local space)
  7147. */
  7148. readonly slidePlaneNormal: Vector3;
  7149. /** @hidden */
  7150. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7151. /** @hidden */
  7152. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7153. /** @hidden */
  7154. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7155. /** @hidden */
  7156. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7157. /** @hidden */
  7158. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7159. /** @hidden */
  7160. _getResponse(pos: Vector3, vel: Vector3): void;
  7161. }
  7162. }
  7163. declare module "babylonjs/Culling/boundingInfo" {
  7164. import { DeepImmutable } from "babylonjs/types";
  7165. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7166. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7167. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7168. import { Collider } from "babylonjs/Collisions/collider";
  7169. /**
  7170. * Interface for cullable objects
  7171. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7172. */
  7173. export interface ICullable {
  7174. /**
  7175. * Checks if the object or part of the object is in the frustum
  7176. * @param frustumPlanes Camera near/planes
  7177. * @returns true if the object is in frustum otherwise false
  7178. */
  7179. isInFrustum(frustumPlanes: Plane[]): boolean;
  7180. /**
  7181. * Checks if a cullable object (mesh...) is in the camera frustum
  7182. * Unlike isInFrustum this cheks the full bounding box
  7183. * @param frustumPlanes Camera near/planes
  7184. * @returns true if the object is in frustum otherwise false
  7185. */
  7186. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7187. }
  7188. /**
  7189. * Info for a bounding data of a mesh
  7190. */
  7191. export class BoundingInfo implements ICullable {
  7192. /**
  7193. * Bounding box for the mesh
  7194. */
  7195. readonly boundingBox: BoundingBox;
  7196. /**
  7197. * Bounding sphere for the mesh
  7198. */
  7199. readonly boundingSphere: BoundingSphere;
  7200. private _isLocked;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * Constructs bounding info
  7204. * @param minimum min vector of the bounding box/sphere
  7205. * @param maximum max vector of the bounding box/sphere
  7206. * @param worldMatrix defines the new world matrix
  7207. */
  7208. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7209. /**
  7210. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7211. * @param min defines the new minimum vector (in local space)
  7212. * @param max defines the new maximum vector (in local space)
  7213. * @param worldMatrix defines the new world matrix
  7214. */
  7215. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7216. /**
  7217. * min vector of the bounding box/sphere
  7218. */
  7219. readonly minimum: Vector3;
  7220. /**
  7221. * max vector of the bounding box/sphere
  7222. */
  7223. readonly maximum: Vector3;
  7224. /**
  7225. * If the info is locked and won't be updated to avoid perf overhead
  7226. */
  7227. isLocked: boolean;
  7228. /**
  7229. * Updates the bounding sphere and box
  7230. * @param world world matrix to be used to update
  7231. */
  7232. update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7235. * @param center New center of the bounding info
  7236. * @param extend New extend of the bounding info
  7237. * @returns the current bounding info
  7238. */
  7239. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7240. /**
  7241. * Scale the current bounding info by applying a scale factor
  7242. * @param factor defines the scale factor to apply
  7243. * @returns the current bounding info
  7244. */
  7245. scale(factor: number): BoundingInfo;
  7246. /**
  7247. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7248. * @param frustumPlanes defines the frustum to test
  7249. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7250. * @returns true if the bounding info is in the frustum planes
  7251. */
  7252. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7253. /**
  7254. * Gets the world distance between the min and max points of the bounding box
  7255. */
  7256. readonly diagonalLength: number;
  7257. /**
  7258. * Checks if a cullable object (mesh...) is in the camera frustum
  7259. * Unlike isInFrustum this cheks the full bounding box
  7260. * @param frustumPlanes Camera near/planes
  7261. * @returns true if the object is in frustum otherwise false
  7262. */
  7263. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7264. /** @hidden */
  7265. _checkCollision(collider: Collider): boolean;
  7266. /**
  7267. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7268. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7269. * @param point the point to check intersection with
  7270. * @returns if the point intersects
  7271. */
  7272. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7273. /**
  7274. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7275. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7276. * @param boundingInfo the bounding info to check intersection with
  7277. * @param precise if the intersection should be done using OBB
  7278. * @returns if the bounding info intersects
  7279. */
  7280. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7281. }
  7282. }
  7283. declare module "babylonjs/Misc/smartArray" {
  7284. /**
  7285. * Defines an array and its length.
  7286. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7287. */
  7288. export interface ISmartArrayLike<T> {
  7289. /**
  7290. * The data of the array.
  7291. */
  7292. data: Array<T>;
  7293. /**
  7294. * The active length of the array.
  7295. */
  7296. length: number;
  7297. }
  7298. /**
  7299. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7300. */
  7301. export class SmartArray<T> implements ISmartArrayLike<T> {
  7302. /**
  7303. * The full set of data from the array.
  7304. */
  7305. data: Array<T>;
  7306. /**
  7307. * The active length of the array.
  7308. */
  7309. length: number;
  7310. protected _id: number;
  7311. /**
  7312. * Instantiates a Smart Array.
  7313. * @param capacity defines the default capacity of the array.
  7314. */
  7315. constructor(capacity: number);
  7316. /**
  7317. * Pushes a value at the end of the active data.
  7318. * @param value defines the object to push in the array.
  7319. */
  7320. push(value: T): void;
  7321. /**
  7322. * Iterates over the active data and apply the lambda to them.
  7323. * @param func defines the action to apply on each value.
  7324. */
  7325. forEach(func: (content: T) => void): void;
  7326. /**
  7327. * Sorts the full sets of data.
  7328. * @param compareFn defines the comparison function to apply.
  7329. */
  7330. sort(compareFn: (a: T, b: T) => number): void;
  7331. /**
  7332. * Resets the active data to an empty array.
  7333. */
  7334. reset(): void;
  7335. /**
  7336. * Releases all the data from the array as well as the array.
  7337. */
  7338. dispose(): void;
  7339. /**
  7340. * Concats the active data with a given array.
  7341. * @param array defines the data to concatenate with.
  7342. */
  7343. concat(array: any): void;
  7344. /**
  7345. * Returns the position of a value in the active data.
  7346. * @param value defines the value to find the index for
  7347. * @returns the index if found in the active data otherwise -1
  7348. */
  7349. indexOf(value: T): number;
  7350. /**
  7351. * Returns whether an element is part of the active data.
  7352. * @param value defines the value to look for
  7353. * @returns true if found in the active data otherwise false
  7354. */
  7355. contains(value: T): boolean;
  7356. private static _GlobalId;
  7357. }
  7358. /**
  7359. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7360. * The data in this array can only be present once
  7361. */
  7362. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7363. private _duplicateId;
  7364. /**
  7365. * Pushes a value at the end of the active data.
  7366. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7367. * @param value defines the object to push in the array.
  7368. */
  7369. push(value: T): void;
  7370. /**
  7371. * Pushes a value at the end of the active data.
  7372. * If the data is already present, it won t be added again
  7373. * @param value defines the object to push in the array.
  7374. * @returns true if added false if it was already present
  7375. */
  7376. pushNoDuplicate(value: T): boolean;
  7377. /**
  7378. * Resets the active data to an empty array.
  7379. */
  7380. reset(): void;
  7381. /**
  7382. * Concats the active data with a given array.
  7383. * This ensures no dupplicate will be present in the result.
  7384. * @param array defines the data to concatenate with.
  7385. */
  7386. concatWithNoDuplicate(array: any): void;
  7387. }
  7388. }
  7389. declare module "babylonjs/Materials/multiMaterial" {
  7390. import { Nullable } from "babylonjs/types";
  7391. import { Scene } from "babylonjs/scene";
  7392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7393. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7395. import { Material } from "babylonjs/Materials/material";
  7396. /**
  7397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7398. * separate meshes. This can be use to improve performances.
  7399. * @see http://doc.babylonjs.com/how_to/multi_materials
  7400. */
  7401. export class MultiMaterial extends Material {
  7402. private _subMaterials;
  7403. /**
  7404. * Gets or Sets the list of Materials used within the multi material.
  7405. * They need to be ordered according to the submeshes order in the associated mesh
  7406. */
  7407. subMaterials: Nullable<Material>[];
  7408. /**
  7409. * Function used to align with Node.getChildren()
  7410. * @returns the list of Materials used within the multi material
  7411. */
  7412. getChildren(): Nullable<Material>[];
  7413. /**
  7414. * Instantiates a new Multi Material
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. * @param name Define the name in the scene
  7419. * @param scene Define the scene the material belongs to
  7420. */
  7421. constructor(name: string, scene: Scene);
  7422. private _hookArray;
  7423. /**
  7424. * Get one of the submaterial by its index in the submaterials array
  7425. * @param index The index to look the sub material at
  7426. * @returns The Material if the index has been defined
  7427. */
  7428. getSubMaterial(index: number): Nullable<Material>;
  7429. /**
  7430. * Get the list of active textures for the whole sub materials list.
  7431. * @returns All the textures that will be used during the rendering
  7432. */
  7433. getActiveTextures(): BaseTexture[];
  7434. /**
  7435. * Gets the current class name of the material e.g. "MultiMaterial"
  7436. * Mainly use in serialization.
  7437. * @returns the class name
  7438. */
  7439. getClassName(): string;
  7440. /**
  7441. * Checks if the material is ready to render the requested sub mesh
  7442. * @param mesh Define the mesh the submesh belongs to
  7443. * @param subMesh Define the sub mesh to look readyness for
  7444. * @param useInstances Define whether or not the material is used with instances
  7445. * @returns true if ready, otherwise false
  7446. */
  7447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7448. /**
  7449. * Clones the current material and its related sub materials
  7450. * @param name Define the name of the newly cloned material
  7451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7452. * @returns the cloned material
  7453. */
  7454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7455. /**
  7456. * Serializes the materials into a JSON representation.
  7457. * @returns the JSON representation
  7458. */
  7459. serialize(): any;
  7460. /**
  7461. * Dispose the material and release its associated resources
  7462. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7463. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7464. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7465. */
  7466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7467. /**
  7468. * Creates a MultiMaterial from parsed MultiMaterial data.
  7469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7470. * @param scene defines the hosting scene
  7471. * @returns a new MultiMaterial
  7472. */
  7473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7474. }
  7475. }
  7476. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7477. /**
  7478. * Class used to represent data loading progression
  7479. */
  7480. export class SceneLoaderFlags {
  7481. private static _ForceFullSceneLoadingForIncremental;
  7482. private static _ShowLoadingScreen;
  7483. private static _CleanBoneMatrixWeights;
  7484. private static _loggingLevel;
  7485. /**
  7486. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7487. */
  7488. static ForceFullSceneLoadingForIncremental: boolean;
  7489. /**
  7490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7491. */
  7492. static ShowLoadingScreen: boolean;
  7493. /**
  7494. * Defines the current logging level (while loading the scene)
  7495. * @ignorenaming
  7496. */
  7497. static loggingLevel: number;
  7498. /**
  7499. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7500. */
  7501. static CleanBoneMatrixWeights: boolean;
  7502. }
  7503. }
  7504. declare module "babylonjs/Meshes/transformNode" {
  7505. import { DeepImmutable } from "babylonjs/types";
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Camera } from "babylonjs/Cameras/camera";
  7509. import { Scene } from "babylonjs/scene";
  7510. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7511. import { Node } from "babylonjs/node";
  7512. import { Bone } from "babylonjs/Bones/bone";
  7513. /**
  7514. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7515. * @see https://doc.babylonjs.com/how_to/transformnode
  7516. */
  7517. export class TransformNode extends Node {
  7518. /**
  7519. * Object will not rotate to face the camera
  7520. */
  7521. static BILLBOARDMODE_NONE: number;
  7522. /**
  7523. * Object will rotate to face the camera but only on the x axis
  7524. */
  7525. static BILLBOARDMODE_X: number;
  7526. /**
  7527. * Object will rotate to face the camera but only on the y axis
  7528. */
  7529. static BILLBOARDMODE_Y: number;
  7530. /**
  7531. * Object will rotate to face the camera but only on the z axis
  7532. */
  7533. static BILLBOARDMODE_Z: number;
  7534. /**
  7535. * Object will rotate to face the camera
  7536. */
  7537. static BILLBOARDMODE_ALL: number;
  7538. private _forward;
  7539. private _forwardInverted;
  7540. private _up;
  7541. private _right;
  7542. private _rightInverted;
  7543. private _position;
  7544. private _rotation;
  7545. private _rotationQuaternion;
  7546. protected _scaling: Vector3;
  7547. protected _isDirty: boolean;
  7548. private _transformToBoneReferal;
  7549. /**
  7550. * Set the billboard mode. Default is 0.
  7551. *
  7552. * | Value | Type | Description |
  7553. * | --- | --- | --- |
  7554. * | 0 | BILLBOARDMODE_NONE | |
  7555. * | 1 | BILLBOARDMODE_X | |
  7556. * | 2 | BILLBOARDMODE_Y | |
  7557. * | 4 | BILLBOARDMODE_Z | |
  7558. * | 7 | BILLBOARDMODE_ALL | |
  7559. *
  7560. */
  7561. billboardMode: number;
  7562. /**
  7563. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7564. */
  7565. scalingDeterminant: number;
  7566. /**
  7567. * Sets the distance of the object to max, often used by skybox
  7568. */
  7569. infiniteDistance: boolean;
  7570. /**
  7571. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7572. * By default the system will update normals to compensate
  7573. */
  7574. ignoreNonUniformScaling: boolean;
  7575. /** @hidden */
  7576. _poseMatrix: Matrix;
  7577. /** @hidden */
  7578. _localMatrix: Matrix;
  7579. private _absolutePosition;
  7580. private _pivotMatrix;
  7581. private _pivotMatrixInverse;
  7582. protected _postMultiplyPivotMatrix: boolean;
  7583. private _tempMatrix;
  7584. private _tempMatrix2;
  7585. protected _isWorldMatrixFrozen: boolean;
  7586. /** @hidden */
  7587. _indexInSceneTransformNodesArray: number;
  7588. /**
  7589. * An event triggered after the world matrix is updated
  7590. */
  7591. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7592. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7593. /**
  7594. * Gets a string identifying the name of the class
  7595. * @returns "TransformNode" string
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7600. */
  7601. position: Vector3;
  7602. /**
  7603. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7604. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7605. */
  7606. rotation: Vector3;
  7607. /**
  7608. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7609. */
  7610. scaling: Vector3;
  7611. /**
  7612. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7614. */
  7615. rotationQuaternion: Nullable<Quaternion>;
  7616. /**
  7617. * The forward direction of that transform in world space.
  7618. */
  7619. readonly forward: Vector3;
  7620. /**
  7621. * The up direction of that transform in world space.
  7622. */
  7623. readonly up: Vector3;
  7624. /**
  7625. * The right direction of that transform in world space.
  7626. */
  7627. readonly right: Vector3;
  7628. /**
  7629. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7630. * @param matrix the matrix to copy the pose from
  7631. * @returns this TransformNode.
  7632. */
  7633. updatePoseMatrix(matrix: Matrix): TransformNode;
  7634. /**
  7635. * Returns the mesh Pose matrix.
  7636. * @returns the pose matrix
  7637. */
  7638. getPoseMatrix(): Matrix;
  7639. /** @hidden */
  7640. _isSynchronized(): boolean;
  7641. /** @hidden */
  7642. _initCache(): void;
  7643. /**
  7644. * Flag the transform node as dirty (Forcing it to update everything)
  7645. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7646. * @returns this transform node
  7647. */
  7648. markAsDirty(property: string): TransformNode;
  7649. /**
  7650. * Returns the current mesh absolute position.
  7651. * Returns a Vector3.
  7652. */
  7653. readonly absolutePosition: Vector3;
  7654. /**
  7655. * Sets a new matrix to apply before all other transformation
  7656. * @param matrix defines the transform matrix
  7657. * @returns the current TransformNode
  7658. */
  7659. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7660. /**
  7661. * Sets a new pivot matrix to the current node
  7662. * @param matrix defines the new pivot matrix to use
  7663. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7664. * @returns the current TransformNode
  7665. */
  7666. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7667. /**
  7668. * Returns the mesh pivot matrix.
  7669. * Default : Identity.
  7670. * @returns the matrix
  7671. */
  7672. getPivotMatrix(): Matrix;
  7673. /**
  7674. * Prevents the World matrix to be computed any longer.
  7675. * @returns the TransformNode.
  7676. */
  7677. freezeWorldMatrix(): TransformNode;
  7678. /**
  7679. * Allows back the World matrix computation.
  7680. * @returns the TransformNode.
  7681. */
  7682. unfreezeWorldMatrix(): this;
  7683. /**
  7684. * True if the World matrix has been frozen.
  7685. */
  7686. readonly isWorldMatrixFrozen: boolean;
  7687. /**
  7688. * Retuns the mesh absolute position in the World.
  7689. * @returns a Vector3.
  7690. */
  7691. getAbsolutePosition(): Vector3;
  7692. /**
  7693. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7694. * @param absolutePosition the absolute position to set
  7695. * @returns the TransformNode.
  7696. */
  7697. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7698. /**
  7699. * Sets the mesh position in its local space.
  7700. * @param vector3 the position to set in localspace
  7701. * @returns the TransformNode.
  7702. */
  7703. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7704. /**
  7705. * Returns the mesh position in the local space from the current World matrix values.
  7706. * @returns a new Vector3.
  7707. */
  7708. getPositionExpressedInLocalSpace(): Vector3;
  7709. /**
  7710. * Translates the mesh along the passed Vector3 in its local space.
  7711. * @param vector3 the distance to translate in localspace
  7712. * @returns the TransformNode.
  7713. */
  7714. locallyTranslate(vector3: Vector3): TransformNode;
  7715. private static _lookAtVectorCache;
  7716. /**
  7717. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7718. * @param targetPoint the position (must be in same space as current mesh) to look at
  7719. * @param yawCor optional yaw (y-axis) correction in radians
  7720. * @param pitchCor optional pitch (x-axis) correction in radians
  7721. * @param rollCor optional roll (z-axis) correction in radians
  7722. * @param space the choosen space of the target
  7723. * @returns the TransformNode.
  7724. */
  7725. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7726. /**
  7727. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7728. * This Vector3 is expressed in the World space.
  7729. * @param localAxis axis to rotate
  7730. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7731. */
  7732. getDirection(localAxis: Vector3): Vector3;
  7733. /**
  7734. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7735. * localAxis is expressed in the mesh local space.
  7736. * result is computed in the Wordl space from the mesh World matrix.
  7737. * @param localAxis axis to rotate
  7738. * @param result the resulting transformnode
  7739. * @returns this TransformNode.
  7740. */
  7741. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7742. /**
  7743. * Sets this transform node rotation to the given local axis.
  7744. * @param localAxis the axis in local space
  7745. * @param yawCor optional yaw (y-axis) correction in radians
  7746. * @param pitchCor optional pitch (x-axis) correction in radians
  7747. * @param rollCor optional roll (z-axis) correction in radians
  7748. * @returns this TransformNode
  7749. */
  7750. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7751. /**
  7752. * Sets a new pivot point to the current node
  7753. * @param point defines the new pivot point to use
  7754. * @param space defines if the point is in world or local space (local by default)
  7755. * @returns the current TransformNode
  7756. */
  7757. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7758. /**
  7759. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7760. * @returns the pivot point
  7761. */
  7762. getPivotPoint(): Vector3;
  7763. /**
  7764. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7765. * @param result the vector3 to store the result
  7766. * @returns this TransformNode.
  7767. */
  7768. getPivotPointToRef(result: Vector3): TransformNode;
  7769. /**
  7770. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7771. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7772. */
  7773. getAbsolutePivotPoint(): Vector3;
  7774. /**
  7775. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7776. * @param result vector3 to store the result
  7777. * @returns this TransformNode.
  7778. */
  7779. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7780. /**
  7781. * Defines the passed node as the parent of the current node.
  7782. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7783. * @param node the node ot set as the parent
  7784. * @returns this TransformNode.
  7785. */
  7786. setParent(node: Nullable<Node>): TransformNode;
  7787. private _nonUniformScaling;
  7788. /**
  7789. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7790. */
  7791. readonly nonUniformScaling: boolean;
  7792. /** @hidden */
  7793. _updateNonUniformScalingState(value: boolean): boolean;
  7794. /**
  7795. * Attach the current TransformNode to another TransformNode associated with a bone
  7796. * @param bone Bone affecting the TransformNode
  7797. * @param affectedTransformNode TransformNode associated with the bone
  7798. * @returns this object
  7799. */
  7800. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7801. /**
  7802. * Detach the transform node if its associated with a bone
  7803. * @returns this object
  7804. */
  7805. detachFromBone(): TransformNode;
  7806. private static _rotationAxisCache;
  7807. /**
  7808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7809. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7811. * The passed axis is also normalized.
  7812. * @param axis the axis to rotate around
  7813. * @param amount the amount to rotate in radians
  7814. * @param space Space to rotate in (Default: local)
  7815. * @returns the TransformNode.
  7816. */
  7817. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7821. * The passed axis is also normalized. .
  7822. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7823. * @param point the point to rotate around
  7824. * @param axis the axis to rotate around
  7825. * @param amount the amount to rotate in radians
  7826. * @returns the TransformNode
  7827. */
  7828. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7829. /**
  7830. * Translates the mesh along the axis vector for the passed distance in the given space.
  7831. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7832. * @param axis the axis to translate in
  7833. * @param distance the distance to translate
  7834. * @param space Space to rotate in (Default: local)
  7835. * @returns the TransformNode.
  7836. */
  7837. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7838. /**
  7839. * Adds a rotation step to the mesh current rotation.
  7840. * x, y, z are Euler angles expressed in radians.
  7841. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7842. * This means this rotation is made in the mesh local space only.
  7843. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7844. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7845. * ```javascript
  7846. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7847. * ```
  7848. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7849. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7850. * @param x Rotation to add
  7851. * @param y Rotation to add
  7852. * @param z Rotation to add
  7853. * @returns the TransformNode.
  7854. */
  7855. addRotation(x: number, y: number, z: number): TransformNode;
  7856. /**
  7857. * Computes the world matrix of the node
  7858. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7859. * @returns the world matrix
  7860. */
  7861. computeWorldMatrix(force?: boolean): Matrix;
  7862. protected _afterComputeWorldMatrix(): void;
  7863. /**
  7864. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7865. * @param func callback function to add
  7866. *
  7867. * @returns the TransformNode.
  7868. */
  7869. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7870. /**
  7871. * Removes a registered callback function.
  7872. * @param func callback function to remove
  7873. * @returns the TransformNode.
  7874. */
  7875. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7876. /**
  7877. * Gets the position of the current mesh in camera space
  7878. * @param camera defines the camera to use
  7879. * @returns a position
  7880. */
  7881. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7882. /**
  7883. * Returns the distance from the mesh to the active camera
  7884. * @param camera defines the camera to use
  7885. * @returns the distance
  7886. */
  7887. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7888. /**
  7889. * Clone the current transform node
  7890. * @param name Name of the new clone
  7891. * @param newParent New parent for the clone
  7892. * @param doNotCloneChildren Do not clone children hierarchy
  7893. * @returns the new transform node
  7894. */
  7895. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7896. /**
  7897. * Serializes the objects information.
  7898. * @param currentSerializationObject defines the object to serialize in
  7899. * @returns the serialized object
  7900. */
  7901. serialize(currentSerializationObject?: any): any;
  7902. /**
  7903. * Returns a new TransformNode object parsed from the source provided.
  7904. * @param parsedTransformNode is the source.
  7905. * @param scene the scne the object belongs to
  7906. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7907. * @returns a new TransformNode object parsed from the source provided.
  7908. */
  7909. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7910. /**
  7911. * Get all child-transformNodes of this node
  7912. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7913. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7914. * @returns an array of TransformNode
  7915. */
  7916. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7917. /**
  7918. * Releases resources associated with this transform node.
  7919. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7920. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7921. */
  7922. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7923. }
  7924. }
  7925. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7926. /**
  7927. * Class used to override all child animations of a given target
  7928. */
  7929. export class AnimationPropertiesOverride {
  7930. /**
  7931. * Gets or sets a value indicating if animation blending must be used
  7932. */
  7933. enableBlending: boolean;
  7934. /**
  7935. * Gets or sets the blending speed to use when enableBlending is true
  7936. */
  7937. blendingSpeed: number;
  7938. /**
  7939. * Gets or sets the default loop mode to use
  7940. */
  7941. loopMode: number;
  7942. }
  7943. }
  7944. declare module "babylonjs/Bones/bone" {
  7945. import { Skeleton } from "babylonjs/Bones/skeleton";
  7946. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7947. import { Nullable } from "babylonjs/types";
  7948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7950. import { Node } from "babylonjs/node";
  7951. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7952. /**
  7953. * Class used to store bone information
  7954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7955. */
  7956. export class Bone extends Node {
  7957. /**
  7958. * defines the bone name
  7959. */
  7960. name: string;
  7961. private static _tmpVecs;
  7962. private static _tmpQuat;
  7963. private static _tmpMats;
  7964. /**
  7965. * Gets the list of child bones
  7966. */
  7967. children: Bone[];
  7968. /** Gets the animations associated with this bone */
  7969. animations: import("babylonjs/Animations/animation").Animation[];
  7970. /**
  7971. * Gets or sets bone length
  7972. */
  7973. length: number;
  7974. /**
  7975. * @hidden Internal only
  7976. * Set this value to map this bone to a different index in the transform matrices
  7977. * Set this value to -1 to exclude the bone from the transform matrices
  7978. */
  7979. _index: Nullable<number>;
  7980. private _skeleton;
  7981. private _localMatrix;
  7982. private _restPose;
  7983. private _baseMatrix;
  7984. private _absoluteTransform;
  7985. private _invertedAbsoluteTransform;
  7986. private _parent;
  7987. private _scalingDeterminant;
  7988. private _worldTransform;
  7989. private _localScaling;
  7990. private _localRotation;
  7991. private _localPosition;
  7992. private _needToDecompose;
  7993. private _needToCompose;
  7994. /** @hidden */
  7995. _linkedTransformNode: Nullable<TransformNode>;
  7996. /** @hidden */
  7997. /** @hidden */
  7998. _matrix: Matrix;
  7999. /**
  8000. * Create a new bone
  8001. * @param name defines the bone name
  8002. * @param skeleton defines the parent skeleton
  8003. * @param parentBone defines the parent (can be null if the bone is the root)
  8004. * @param localMatrix defines the local matrix
  8005. * @param restPose defines the rest pose matrix
  8006. * @param baseMatrix defines the base matrix
  8007. * @param index defines index of the bone in the hiearchy
  8008. */
  8009. constructor(
  8010. /**
  8011. * defines the bone name
  8012. */
  8013. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8014. /**
  8015. * Gets the current object class name.
  8016. * @return the class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Gets the parent skeleton
  8021. * @returns a skeleton
  8022. */
  8023. getSkeleton(): Skeleton;
  8024. /**
  8025. * Gets parent bone
  8026. * @returns a bone or null if the bone is the root of the bone hierarchy
  8027. */
  8028. getParent(): Nullable<Bone>;
  8029. /**
  8030. * Returns an array containing the root bones
  8031. * @returns an array containing the root bones
  8032. */
  8033. getChildren(): Array<Bone>;
  8034. /**
  8035. * Sets the parent bone
  8036. * @param parent defines the parent (can be null if the bone is the root)
  8037. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8038. */
  8039. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8040. /**
  8041. * Gets the local matrix
  8042. * @returns a matrix
  8043. */
  8044. getLocalMatrix(): Matrix;
  8045. /**
  8046. * Gets the base matrix (initial matrix which remains unchanged)
  8047. * @returns a matrix
  8048. */
  8049. getBaseMatrix(): Matrix;
  8050. /**
  8051. * Gets the rest pose matrix
  8052. * @returns a matrix
  8053. */
  8054. getRestPose(): Matrix;
  8055. /**
  8056. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8057. */
  8058. getWorldMatrix(): Matrix;
  8059. /**
  8060. * Sets the local matrix to rest pose matrix
  8061. */
  8062. returnToRest(): void;
  8063. /**
  8064. * Gets the inverse of the absolute transform matrix.
  8065. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8066. * @returns a matrix
  8067. */
  8068. getInvertedAbsoluteTransform(): Matrix;
  8069. /**
  8070. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8071. * @returns a matrix
  8072. */
  8073. getAbsoluteTransform(): Matrix;
  8074. /**
  8075. * Links with the given transform node.
  8076. * The local matrix of this bone is copied from the transform node every frame.
  8077. * @param transformNode defines the transform node to link to
  8078. */
  8079. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8080. /** Gets or sets current position (in local space) */
  8081. position: Vector3;
  8082. /** Gets or sets current rotation (in local space) */
  8083. rotation: Vector3;
  8084. /** Gets or sets current rotation quaternion (in local space) */
  8085. rotationQuaternion: Quaternion;
  8086. /** Gets or sets current scaling (in local space) */
  8087. scaling: Vector3;
  8088. /**
  8089. * Gets the animation properties override
  8090. */
  8091. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8092. private _decompose;
  8093. private _compose;
  8094. /**
  8095. * Update the base and local matrices
  8096. * @param matrix defines the new base or local matrix
  8097. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8098. * @param updateLocalMatrix defines if the local matrix should be updated
  8099. */
  8100. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8101. /** @hidden */
  8102. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8103. /**
  8104. * Flag the bone as dirty (Forcing it to update everything)
  8105. */
  8106. markAsDirty(): void;
  8107. private _markAsDirtyAndCompose;
  8108. private _markAsDirtyAndDecompose;
  8109. /**
  8110. * Translate the bone in local or world space
  8111. * @param vec The amount to translate the bone
  8112. * @param space The space that the translation is in
  8113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8114. */
  8115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8116. /**
  8117. * Set the postion of the bone in local or world space
  8118. * @param position The position to set the bone
  8119. * @param space The space that the position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. */
  8122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8123. /**
  8124. * Set the absolute position of the bone (world space)
  8125. * @param position The position to set the bone
  8126. * @param mesh The mesh that this bone is attached to
  8127. */
  8128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Scale the bone on the x, y and z axes (in local space)
  8131. * @param x The amount to scale the bone on the x axis
  8132. * @param y The amount to scale the bone on the y axis
  8133. * @param z The amount to scale the bone on the z axis
  8134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8135. */
  8136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8137. /**
  8138. * Set the bone scaling in local space
  8139. * @param scale defines the scaling vector
  8140. */
  8141. setScale(scale: Vector3): void;
  8142. /**
  8143. * Gets the current scaling in local space
  8144. * @returns the current scaling vector
  8145. */
  8146. getScale(): Vector3;
  8147. /**
  8148. * Gets the current scaling in local space and stores it in a target vector
  8149. * @param result defines the target vector
  8150. */
  8151. getScaleToRef(result: Vector3): void;
  8152. /**
  8153. * Set the yaw, pitch, and roll of the bone in local or world space
  8154. * @param yaw The rotation of the bone on the y axis
  8155. * @param pitch The rotation of the bone on the x axis
  8156. * @param roll The rotation of the bone on the z axis
  8157. * @param space The space that the axes of rotation are in
  8158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8159. */
  8160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8161. /**
  8162. * Add a rotation to the bone on an axis in local or world space
  8163. * @param axis The axis to rotate the bone on
  8164. * @param amount The amount to rotate the bone
  8165. * @param space The space that the axis is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Set the rotation of the bone to a particular axis angle in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param angle The angle that the bone should be rotated to
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the euler rotation of the bone in local of world space
  8179. * @param rotation The euler rotation that the bone should be set to
  8180. * @param space The space that the rotation is in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. */
  8183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8184. /**
  8185. * Set the quaternion rotation of the bone in local of world space
  8186. * @param quat The quaternion rotation that the bone should be set to
  8187. * @param space The space that the rotation is in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. */
  8190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8191. /**
  8192. * Set the rotation matrix of the bone in local of world space
  8193. * @param rotMat The rotation matrix that the bone should be set to
  8194. * @param space The space that the rotation is in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. */
  8197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8198. private _rotateWithMatrix;
  8199. private _getNegativeRotationToRef;
  8200. /**
  8201. * Get the position of the bone in local or world space
  8202. * @param space The space that the returned position is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The position of the bone
  8205. */
  8206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the position of the bone to a vector3 in local or world space
  8209. * @param space The space that the returned position is in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 to copy the position to
  8212. */
  8213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8214. /**
  8215. * Get the absolute position of the bone (world space)
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The absolute position of the bone
  8218. */
  8219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Copy the absolute position of the bone (world space) to the result param
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @param result The vector3 to copy the absolute position to
  8224. */
  8225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8226. /**
  8227. * Compute the absolute transforms of this bone and its children
  8228. */
  8229. computeAbsoluteTransforms(): void;
  8230. /**
  8231. * Get the world direction from an axis that is in the local space of the bone
  8232. * @param localAxis The local direction that is used to compute the world direction
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @returns The world direction
  8235. */
  8236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8237. /**
  8238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8239. * @param localAxis The local direction that is used to compute the world direction
  8240. * @param mesh The mesh that this bone is attached to
  8241. * @param result The vector3 that the world direction will be copied to
  8242. */
  8243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8244. /**
  8245. * Get the euler rotation of the bone in local or world space
  8246. * @param space The space that the rotation should be in
  8247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8248. * @returns The euler rotation
  8249. */
  8250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8251. /**
  8252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8253. * @param space The space that the rotation should be in
  8254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8255. * @param result The vector3 that the rotation should be copied to
  8256. */
  8257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8258. /**
  8259. * Get the quaternion rotation of the bone in either local or world space
  8260. * @param space The space that the rotation should be in
  8261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8262. * @returns The quaternion rotation
  8263. */
  8264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8265. /**
  8266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8267. * @param space The space that the rotation should be in
  8268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8269. * @param result The quaternion that the rotation should be copied to
  8270. */
  8271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8272. /**
  8273. * Get the rotation matrix of the bone in local or world space
  8274. * @param space The space that the rotation should be in
  8275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8276. * @returns The rotation matrix
  8277. */
  8278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8279. /**
  8280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8281. * @param space The space that the rotation should be in
  8282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8283. * @param result The quaternion that the rotation should be copied to
  8284. */
  8285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8286. /**
  8287. * Get the world position of a point that is in the local space of the bone
  8288. * @param position The local position
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @returns The world position
  8291. */
  8292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8293. /**
  8294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8295. * @param position The local position
  8296. * @param mesh The mesh that this bone is attached to
  8297. * @param result The vector3 that the world position should be copied to
  8298. */
  8299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8300. /**
  8301. * Get the local position of a point that is in world space
  8302. * @param position The world position
  8303. * @param mesh The mesh that this bone is attached to
  8304. * @returns The local position
  8305. */
  8306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8307. /**
  8308. * Get the local position of a point that is in world space and copy it to the result param
  8309. * @param position The world position
  8310. * @param mesh The mesh that this bone is attached to
  8311. * @param result The vector3 that the local position should be copied to
  8312. */
  8313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8314. }
  8315. }
  8316. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8317. import { Nullable } from "babylonjs/types";
  8318. import { Scene } from "babylonjs/scene";
  8319. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8321. /**
  8322. * Class for creating a cube texture
  8323. */
  8324. export class CubeTexture extends BaseTexture {
  8325. private _delayedOnLoad;
  8326. /**
  8327. * The url of the texture
  8328. */
  8329. url: string;
  8330. /**
  8331. * Gets or sets the center of the bounding box associated with the cube texture.
  8332. * It must define where the camera used to render the texture was set
  8333. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8334. */
  8335. boundingBoxPosition: Vector3;
  8336. private _boundingBoxSize;
  8337. /**
  8338. * Gets or sets the size of the bounding box associated with the cube texture
  8339. * When defined, the cubemap will switch to local mode
  8340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8341. * @example https://www.babylonjs-playground.com/#RNASML
  8342. */
  8343. /**
  8344. * Returns the bounding box size
  8345. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8346. */
  8347. boundingBoxSize: Vector3;
  8348. protected _rotationY: number;
  8349. /**
  8350. * Sets texture matrix rotation angle around Y axis in radians.
  8351. */
  8352. /**
  8353. * Gets texture matrix rotation angle around Y axis radians.
  8354. */
  8355. rotationY: number;
  8356. /**
  8357. * Are mip maps generated for this texture or not.
  8358. */
  8359. readonly noMipmap: boolean;
  8360. private _noMipmap;
  8361. private _files;
  8362. private _extensions;
  8363. private _textureMatrix;
  8364. private _format;
  8365. private _createPolynomials;
  8366. /** @hidden */
  8367. _prefiltered: boolean;
  8368. /**
  8369. * Creates a cube texture from an array of image urls
  8370. * @param files defines an array of image urls
  8371. * @param scene defines the hosting scene
  8372. * @param noMipmap specifies if mip maps are not used
  8373. * @returns a cube texture
  8374. */
  8375. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8376. /**
  8377. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8378. * @param url defines the url of the prefiltered texture
  8379. * @param scene defines the scene the texture is attached to
  8380. * @param forcedExtension defines the extension of the file if different from the url
  8381. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8382. * @return the prefiltered texture
  8383. */
  8384. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8385. /**
  8386. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8387. * as prefiltered data.
  8388. * @param rootUrl defines the url of the texture or the root name of the six images
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8391. * @param noMipmap defines if mipmaps should be created or not
  8392. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8393. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8394. * @param onError defines a callback triggered in case of error during load
  8395. * @param format defines the internal format to use for the texture once loaded
  8396. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8397. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8398. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8401. * @return the cube texture
  8402. */
  8403. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8404. /**
  8405. * Get the current class name of the texture useful for serialization or dynamic coding.
  8406. * @returns "CubeTexture"
  8407. */
  8408. getClassName(): string;
  8409. /**
  8410. * Update the url (and optional buffer) of this texture if url was null during construction.
  8411. * @param url the url of the texture
  8412. * @param forcedExtension defines the extension to use
  8413. * @param onLoad callback called when the texture is loaded (defaults to null)
  8414. */
  8415. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8416. /**
  8417. * Delays loading of the cube texture
  8418. * @param forcedExtension defines the extension to use
  8419. */
  8420. delayLoad(forcedExtension?: string): void;
  8421. /**
  8422. * Returns the reflection texture matrix
  8423. * @returns the reflection texture matrix
  8424. */
  8425. getReflectionTextureMatrix(): Matrix;
  8426. /**
  8427. * Sets the reflection texture matrix
  8428. * @param value Reflection texture matrix
  8429. */
  8430. setReflectionTextureMatrix(value: Matrix): void;
  8431. /**
  8432. * Parses text to create a cube texture
  8433. * @param parsedTexture define the serialized text to read from
  8434. * @param scene defines the hosting scene
  8435. * @param rootUrl defines the root url of the cube texture
  8436. * @returns a cube texture
  8437. */
  8438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8439. /**
  8440. * Makes a clone, or deep copy, of the cube texture
  8441. * @returns a new cube texture
  8442. */
  8443. clone(): CubeTexture;
  8444. }
  8445. }
  8446. declare module "babylonjs/Shaders/postprocess.vertex" {
  8447. /** @hidden */
  8448. export var postprocessVertexShader: {
  8449. name: string;
  8450. shader: string;
  8451. };
  8452. }
  8453. declare module "babylonjs/Cameras/targetCamera" {
  8454. import { Nullable } from "babylonjs/types";
  8455. import { Camera } from "babylonjs/Cameras/camera";
  8456. import { Scene } from "babylonjs/scene";
  8457. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8458. /**
  8459. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8460. * This is the base of the follow, arc rotate cameras and Free camera
  8461. * @see http://doc.babylonjs.com/features/cameras
  8462. */
  8463. export class TargetCamera extends Camera {
  8464. private static _RigCamTransformMatrix;
  8465. private static _TargetTransformMatrix;
  8466. private static _TargetFocalPoint;
  8467. /**
  8468. * Define the current direction the camera is moving to
  8469. */
  8470. cameraDirection: Vector3;
  8471. /**
  8472. * Define the current rotation the camera is rotating to
  8473. */
  8474. cameraRotation: Vector2;
  8475. /**
  8476. * When set, the up vector of the camera will be updated by the rotation of the camera
  8477. */
  8478. updateUpVectorFromRotation: boolean;
  8479. private _tmpQuaternion;
  8480. /**
  8481. * Define the current rotation of the camera
  8482. */
  8483. rotation: Vector3;
  8484. /**
  8485. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8486. */
  8487. rotationQuaternion: Quaternion;
  8488. /**
  8489. * Define the current speed of the camera
  8490. */
  8491. speed: number;
  8492. /**
  8493. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8494. * around all axis.
  8495. */
  8496. noRotationConstraint: boolean;
  8497. /**
  8498. * Define the current target of the camera as an object or a position.
  8499. */
  8500. lockedTarget: any;
  8501. /** @hidden */
  8502. _currentTarget: Vector3;
  8503. /** @hidden */
  8504. _initialFocalDistance: number;
  8505. /** @hidden */
  8506. _viewMatrix: Matrix;
  8507. /** @hidden */
  8508. _camMatrix: Matrix;
  8509. /** @hidden */
  8510. _cameraTransformMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraRotationMatrix: Matrix;
  8513. /** @hidden */
  8514. _referencePoint: Vector3;
  8515. /** @hidden */
  8516. _transformedReferencePoint: Vector3;
  8517. protected _globalCurrentTarget: Vector3;
  8518. protected _globalCurrentUpVector: Vector3;
  8519. /** @hidden */
  8520. _reset: () => void;
  8521. private _defaultUp;
  8522. /**
  8523. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8524. * This is the base of the follow, arc rotate cameras and Free camera
  8525. * @see http://doc.babylonjs.com/features/cameras
  8526. * @param name Defines the name of the camera in the scene
  8527. * @param position Defines the start position of the camera in the scene
  8528. * @param scene Defines the scene the camera belongs to
  8529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8530. */
  8531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8532. /**
  8533. * Gets the position in front of the camera at a given distance.
  8534. * @param distance The distance from the camera we want the position to be
  8535. * @returns the position
  8536. */
  8537. getFrontPosition(distance: number): Vector3;
  8538. /** @hidden */
  8539. _getLockedTargetPosition(): Nullable<Vector3>;
  8540. private _storedPosition;
  8541. private _storedRotation;
  8542. private _storedRotationQuaternion;
  8543. /**
  8544. * Store current camera state of the camera (fov, position, rotation, etc..)
  8545. * @returns the camera
  8546. */
  8547. storeState(): Camera;
  8548. /**
  8549. * Restored camera state. You must call storeState() first
  8550. * @returns whether it was successful or not
  8551. * @hidden
  8552. */
  8553. _restoreStateValues(): boolean;
  8554. /** @hidden */
  8555. _initCache(): void;
  8556. /** @hidden */
  8557. _updateCache(ignoreParentClass?: boolean): void;
  8558. /** @hidden */
  8559. _isSynchronizedViewMatrix(): boolean;
  8560. /** @hidden */
  8561. _computeLocalCameraSpeed(): number;
  8562. /**
  8563. * Defines the target the camera should look at.
  8564. * This will automatically adapt alpha beta and radius to fit within the new target.
  8565. * @param target Defines the new target as a Vector or a mesh
  8566. */
  8567. setTarget(target: Vector3): void;
  8568. /**
  8569. * Return the current target position of the camera. This value is expressed in local space.
  8570. * @returns the target position
  8571. */
  8572. getTarget(): Vector3;
  8573. /** @hidden */
  8574. _decideIfNeedsToMove(): boolean;
  8575. /** @hidden */
  8576. _updatePosition(): void;
  8577. /** @hidden */
  8578. _checkInputs(): void;
  8579. protected _updateCameraRotationMatrix(): void;
  8580. /**
  8581. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8582. * @returns the current camera
  8583. */
  8584. private _rotateUpVectorWithCameraRotationMatrix;
  8585. private _cachedRotationZ;
  8586. private _cachedQuaternionRotationZ;
  8587. /** @hidden */
  8588. _getViewMatrix(): Matrix;
  8589. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8590. /**
  8591. * @hidden
  8592. */
  8593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8594. /**
  8595. * @hidden
  8596. */
  8597. _updateRigCameras(): void;
  8598. private _getRigCamPositionAndTarget;
  8599. /**
  8600. * Gets the current object class name.
  8601. * @return the class name
  8602. */
  8603. getClassName(): string;
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/cameraInputsManager" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { Camera } from "babylonjs/Cameras/camera";
  8609. /**
  8610. * @ignore
  8611. * This is a list of all the different input types that are available in the application.
  8612. * Fo instance: ArcRotateCameraGamepadInput...
  8613. */
  8614. export var CameraInputTypes: {};
  8615. /**
  8616. * This is the contract to implement in order to create a new input class.
  8617. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8618. */
  8619. export interface ICameraInput<TCamera extends Camera> {
  8620. /**
  8621. * Defines the camera the input is attached to.
  8622. */
  8623. camera: Nullable<TCamera>;
  8624. /**
  8625. * Gets the class name of the current intput.
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /**
  8630. * Get the friendly name associated with the input class.
  8631. * @returns the input friendly name
  8632. */
  8633. getSimpleName(): string;
  8634. /**
  8635. * Attach the input controls to a specific dom element to get the input from.
  8636. * @param element Defines the element the controls should be listened from
  8637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8638. */
  8639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current controls from the specified dom element.
  8642. * @param element Defines the element to stop listening the inputs from
  8643. */
  8644. detachControl(element: Nullable<HTMLElement>): void;
  8645. /**
  8646. * Update the current camera state depending on the inputs that have been used this frame.
  8647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8648. */
  8649. checkInputs?: () => void;
  8650. }
  8651. /**
  8652. * Represents a map of input types to input instance or input index to input instance.
  8653. */
  8654. export interface CameraInputsMap<TCamera extends Camera> {
  8655. /**
  8656. * Accessor to the input by input type.
  8657. */
  8658. [name: string]: ICameraInput<TCamera>;
  8659. /**
  8660. * Accessor to the input by input index.
  8661. */
  8662. [idx: number]: ICameraInput<TCamera>;
  8663. }
  8664. /**
  8665. * This represents the input manager used within a camera.
  8666. * It helps dealing with all the different kind of input attached to a camera.
  8667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8668. */
  8669. export class CameraInputsManager<TCamera extends Camera> {
  8670. /**
  8671. * Defines the list of inputs attahed to the camera.
  8672. */
  8673. attached: CameraInputsMap<TCamera>;
  8674. /**
  8675. * Defines the dom element the camera is collecting inputs from.
  8676. * This is null if the controls have not been attached.
  8677. */
  8678. attachedElement: Nullable<HTMLElement>;
  8679. /**
  8680. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8681. */
  8682. noPreventDefault: boolean;
  8683. /**
  8684. * Defined the camera the input manager belongs to.
  8685. */
  8686. camera: TCamera;
  8687. /**
  8688. * Update the current camera state depending on the inputs that have been used this frame.
  8689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8690. */
  8691. checkInputs: () => void;
  8692. /**
  8693. * Instantiate a new Camera Input Manager.
  8694. * @param camera Defines the camera the input manager blongs to
  8695. */
  8696. constructor(camera: TCamera);
  8697. /**
  8698. * Add an input method to a camera
  8699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8700. * @param input camera input method
  8701. */
  8702. add(input: ICameraInput<TCamera>): void;
  8703. /**
  8704. * Remove a specific input method from a camera
  8705. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8706. * @param inputToRemove camera input method
  8707. */
  8708. remove(inputToRemove: ICameraInput<TCamera>): void;
  8709. /**
  8710. * Remove a specific input type from a camera
  8711. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8712. * @param inputType the type of the input to remove
  8713. */
  8714. removeByType(inputType: string): void;
  8715. private _addCheckInputs;
  8716. /**
  8717. * Attach the input controls to the currently attached dom element to listen the events from.
  8718. * @param input Defines the input to attach
  8719. */
  8720. attachInput(input: ICameraInput<TCamera>): void;
  8721. /**
  8722. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8723. * @param element Defines the dom element to collect the events from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current manager inputs controls from a specific dom element.
  8729. * @param element Defines the dom element to collect the events from
  8730. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8731. */
  8732. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8733. /**
  8734. * Rebuild the dynamic inputCheck function from the current list of
  8735. * defined inputs in the manager.
  8736. */
  8737. rebuildInputCheck(): void;
  8738. /**
  8739. * Remove all attached input methods from a camera
  8740. */
  8741. clear(): void;
  8742. /**
  8743. * Serialize the current input manager attached to a camera.
  8744. * This ensures than once parsed,
  8745. * the input associated to the camera will be identical to the current ones
  8746. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8747. */
  8748. serialize(serializedCamera: any): void;
  8749. /**
  8750. * Parses an input manager serialized JSON to restore the previous list of inputs
  8751. * and states associated to a camera.
  8752. * @param parsedCamera Defines the JSON to parse
  8753. */
  8754. parse(parsedCamera: any): void;
  8755. }
  8756. }
  8757. declare module "babylonjs/Events/keyboardEvents" {
  8758. /**
  8759. * Gather the list of keyboard event types as constants.
  8760. */
  8761. export class KeyboardEventTypes {
  8762. /**
  8763. * The keydown event is fired when a key becomes active (pressed).
  8764. */
  8765. static readonly KEYDOWN: number;
  8766. /**
  8767. * The keyup event is fired when a key has been released.
  8768. */
  8769. static readonly KEYUP: number;
  8770. }
  8771. /**
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. */
  8774. export class KeyboardInfo {
  8775. /**
  8776. * Defines the type of event (KeyboardEventTypes)
  8777. */
  8778. type: number;
  8779. /**
  8780. * Defines the related dom event
  8781. */
  8782. event: KeyboardEvent;
  8783. /**
  8784. * Instantiates a new keyboard info.
  8785. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8786. * @param type Defines the type of event (KeyboardEventTypes)
  8787. * @param event Defines the related dom event
  8788. */
  8789. constructor(
  8790. /**
  8791. * Defines the type of event (KeyboardEventTypes)
  8792. */
  8793. type: number,
  8794. /**
  8795. * Defines the related dom event
  8796. */
  8797. event: KeyboardEvent);
  8798. }
  8799. /**
  8800. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8801. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8802. */
  8803. export class KeyboardInfoPre extends KeyboardInfo {
  8804. /**
  8805. * Defines the type of event (KeyboardEventTypes)
  8806. */
  8807. type: number;
  8808. /**
  8809. * Defines the related dom event
  8810. */
  8811. event: KeyboardEvent;
  8812. /**
  8813. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8814. */
  8815. skipOnPointerObservable: boolean;
  8816. /**
  8817. * Instantiates a new keyboard pre info.
  8818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8819. * @param type Defines the type of event (KeyboardEventTypes)
  8820. * @param event Defines the related dom event
  8821. */
  8822. constructor(
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number,
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent);
  8831. }
  8832. }
  8833. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8834. import { Nullable } from "babylonjs/types";
  8835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8836. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8837. /**
  8838. * Manage the keyboard inputs to control the movement of a free camera.
  8839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8840. */
  8841. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8842. /**
  8843. * Defines the camera the input is attached to.
  8844. */
  8845. camera: FreeCamera;
  8846. /**
  8847. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8848. */
  8849. keysUp: number[];
  8850. /**
  8851. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8852. */
  8853. keysDown: number[];
  8854. /**
  8855. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8856. */
  8857. keysLeft: number[];
  8858. /**
  8859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8860. */
  8861. keysRight: number[];
  8862. private _keys;
  8863. private _onCanvasBlurObserver;
  8864. private _onKeyboardObserver;
  8865. private _engine;
  8866. private _scene;
  8867. /**
  8868. * Attach the input controls to a specific dom element to get the input from.
  8869. * @param element Defines the element the controls should be listened from
  8870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8871. */
  8872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8873. /**
  8874. * Detach the current controls from the specified dom element.
  8875. * @param element Defines the element to stop listening the inputs from
  8876. */
  8877. detachControl(element: Nullable<HTMLElement>): void;
  8878. /**
  8879. * Update the current camera state depending on the inputs that have been used this frame.
  8880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8881. */
  8882. checkInputs(): void;
  8883. /**
  8884. * Gets the class name of the current intput.
  8885. * @returns the class name
  8886. */
  8887. getClassName(): string;
  8888. /** @hidden */
  8889. _onLostFocus(): void;
  8890. /**
  8891. * Get the friendly name associated with the input class.
  8892. * @returns the input friendly name
  8893. */
  8894. getSimpleName(): string;
  8895. }
  8896. }
  8897. declare module "babylonjs/Lights/shadowLight" {
  8898. import { Camera } from "babylonjs/Cameras/camera";
  8899. import { Scene } from "babylonjs/scene";
  8900. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8902. import { Light } from "babylonjs/Lights/light";
  8903. /**
  8904. * Interface describing all the common properties and methods a shadow light needs to implement.
  8905. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8906. * as well as binding the different shadow properties to the effects.
  8907. */
  8908. export interface IShadowLight extends Light {
  8909. /**
  8910. * The light id in the scene (used in scene.findLighById for instance)
  8911. */
  8912. id: string;
  8913. /**
  8914. * The position the shdow will be casted from.
  8915. */
  8916. position: Vector3;
  8917. /**
  8918. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8919. */
  8920. direction: Vector3;
  8921. /**
  8922. * The transformed position. Position of the light in world space taking parenting in account.
  8923. */
  8924. transformedPosition: Vector3;
  8925. /**
  8926. * The transformed direction. Direction of the light in world space taking parenting in account.
  8927. */
  8928. transformedDirection: Vector3;
  8929. /**
  8930. * The friendly name of the light in the scene.
  8931. */
  8932. name: string;
  8933. /**
  8934. * Defines the shadow projection clipping minimum z value.
  8935. */
  8936. shadowMinZ: number;
  8937. /**
  8938. * Defines the shadow projection clipping maximum z value.
  8939. */
  8940. shadowMaxZ: number;
  8941. /**
  8942. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8943. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8944. */
  8945. computeTransformedInformation(): boolean;
  8946. /**
  8947. * Gets the scene the light belongs to.
  8948. * @returns The scene
  8949. */
  8950. getScene(): Scene;
  8951. /**
  8952. * Callback defining a custom Projection Matrix Builder.
  8953. * This can be used to override the default projection matrix computation.
  8954. */
  8955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8956. /**
  8957. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8958. * @param matrix The materix to updated with the projection information
  8959. * @param viewMatrix The transform matrix of the light
  8960. * @param renderList The list of mesh to render in the map
  8961. * @returns The current light
  8962. */
  8963. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8964. /**
  8965. * Gets the current depth scale used in ESM.
  8966. * @returns The scale
  8967. */
  8968. getDepthScale(): number;
  8969. /**
  8970. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8971. * @returns true if a cube texture needs to be use
  8972. */
  8973. needCube(): boolean;
  8974. /**
  8975. * Detects if the projection matrix requires to be recomputed this frame.
  8976. * @returns true if it requires to be recomputed otherwise, false.
  8977. */
  8978. needProjectionMatrixCompute(): boolean;
  8979. /**
  8980. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8981. */
  8982. forceProjectionMatrixCompute(): void;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Gets the minZ used for shadow according to both the scene and the light.
  8991. * @param activeCamera The camera we are returning the min for
  8992. * @returns the depth min z
  8993. */
  8994. getDepthMinZ(activeCamera: Camera): number;
  8995. /**
  8996. * Gets the maxZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the max for
  8998. * @returns the depth max z
  8999. */
  9000. getDepthMaxZ(activeCamera: Camera): number;
  9001. }
  9002. /**
  9003. * Base implementation IShadowLight
  9004. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9005. */
  9006. export abstract class ShadowLight extends Light implements IShadowLight {
  9007. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9008. protected _position: Vector3;
  9009. protected _setPosition(value: Vector3): void;
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. /**
  9015. * Sets the position the shadow will be casted from. Also use as the light position for both
  9016. * point and spot lights.
  9017. */
  9018. position: Vector3;
  9019. protected _direction: Vector3;
  9020. protected _setDirection(value: Vector3): void;
  9021. /**
  9022. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. /**
  9026. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9027. * Also use as the light direction on spot and directional lights.
  9028. */
  9029. direction: Vector3;
  9030. private _shadowMinZ;
  9031. /**
  9032. * Gets the shadow projection clipping minimum z value.
  9033. */
  9034. /**
  9035. * Sets the shadow projection clipping minimum z value.
  9036. */
  9037. shadowMinZ: number;
  9038. private _shadowMaxZ;
  9039. /**
  9040. * Sets the shadow projection clipping maximum z value.
  9041. */
  9042. /**
  9043. * Gets the shadow projection clipping maximum z value.
  9044. */
  9045. shadowMaxZ: number;
  9046. /**
  9047. * Callback defining a custom Projection Matrix Builder.
  9048. * This can be used to override the default projection matrix computation.
  9049. */
  9050. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9051. /**
  9052. * The transformed position. Position of the light in world space taking parenting in account.
  9053. */
  9054. transformedPosition: Vector3;
  9055. /**
  9056. * The transformed direction. Direction of the light in world space taking parenting in account.
  9057. */
  9058. transformedDirection: Vector3;
  9059. private _needProjectionMatrixCompute;
  9060. /**
  9061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9063. */
  9064. computeTransformedInformation(): boolean;
  9065. /**
  9066. * Return the depth scale used for the shadow map.
  9067. * @returns the depth scale.
  9068. */
  9069. getDepthScale(): number;
  9070. /**
  9071. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9072. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9073. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9074. */
  9075. getShadowDirection(faceIndex?: number): Vector3;
  9076. /**
  9077. * Returns the ShadowLight absolute position in the World.
  9078. * @returns the position vector in world space
  9079. */
  9080. getAbsolutePosition(): Vector3;
  9081. /**
  9082. * Sets the ShadowLight direction toward the passed target.
  9083. * @param target The point to target in local space
  9084. * @returns the updated ShadowLight direction
  9085. */
  9086. setDirectionToTarget(target: Vector3): Vector3;
  9087. /**
  9088. * Returns the light rotation in euler definition.
  9089. * @returns the x y z rotation in local space.
  9090. */
  9091. getRotation(): Vector3;
  9092. /**
  9093. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9094. * @returns true if a cube texture needs to be use
  9095. */
  9096. needCube(): boolean;
  9097. /**
  9098. * Detects if the projection matrix requires to be recomputed this frame.
  9099. * @returns true if it requires to be recomputed otherwise, false.
  9100. */
  9101. needProjectionMatrixCompute(): boolean;
  9102. /**
  9103. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9104. */
  9105. forceProjectionMatrixCompute(): void;
  9106. /** @hidden */
  9107. _initCache(): void;
  9108. /** @hidden */
  9109. _isSynchronized(): boolean;
  9110. /**
  9111. * Computes the world matrix of the node
  9112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9113. * @returns the world matrix
  9114. */
  9115. computeWorldMatrix(force?: boolean): Matrix;
  9116. /**
  9117. * Gets the minZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the min for
  9119. * @returns the depth min z
  9120. */
  9121. getDepthMinZ(activeCamera: Camera): number;
  9122. /**
  9123. * Gets the maxZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the max for
  9125. * @returns the depth max z
  9126. */
  9127. getDepthMaxZ(activeCamera: Camera): number;
  9128. /**
  9129. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9130. * @param matrix The materix to updated with the projection information
  9131. * @param viewMatrix The transform matrix of the light
  9132. * @param renderList The list of mesh to render in the map
  9133. * @returns The current light
  9134. */
  9135. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9136. }
  9137. }
  9138. declare module "babylonjs/Materials/materialHelper" {
  9139. import { Nullable } from "babylonjs/types";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Engine } from "babylonjs/Engines/engine";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9145. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9147. /**
  9148. * "Static Class" containing the most commonly used helper while dealing with material for
  9149. * rendering purpose.
  9150. *
  9151. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9152. *
  9153. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9154. */
  9155. export class MaterialHelper {
  9156. /**
  9157. * Bind the current view position to an effect.
  9158. * @param effect The effect to be bound
  9159. * @param scene The scene the eyes position is used from
  9160. */
  9161. static BindEyePosition(effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Helps preparing the defines values about the UVs in used in the effect.
  9164. * UVs are shared as much as we can accross channels in the shaders.
  9165. * @param texture The texture we are preparing the UVs for
  9166. * @param defines The defines to update
  9167. * @param key The channel key "diffuse", "specular"... used in the shader
  9168. */
  9169. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9170. /**
  9171. * Binds a texture matrix value to its corrsponding uniform
  9172. * @param texture The texture to bind the matrix for
  9173. * @param uniformBuffer The uniform buffer receivin the data
  9174. * @param key The channel key "diffuse", "specular"... used in the shader
  9175. */
  9176. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9177. /**
  9178. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9179. * @param mesh defines the current mesh
  9180. * @param scene defines the current scene
  9181. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9182. * @param pointsCloud defines if point cloud rendering has to be turned on
  9183. * @param fogEnabled defines if fog has to be turned on
  9184. * @param alphaTest defines if alpha testing has to be turned on
  9185. * @param defines defines the current list of defines
  9186. */
  9187. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9188. /**
  9189. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9190. * @param scene defines the current scene
  9191. * @param engine defines the current engine
  9192. * @param defines specifies the list of active defines
  9193. * @param useInstances defines if instances have to be turned on
  9194. * @param useClipPlane defines if clip plane have to be turned on
  9195. */
  9196. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9197. /**
  9198. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9199. * @param mesh The mesh containing the geometry data we will draw
  9200. * @param defines The defines to update
  9201. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9202. * @param useBones Precise whether bones should be used or not (override mesh info)
  9203. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9204. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9205. * @returns false if defines are considered not dirty and have not been checked
  9206. */
  9207. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9208. /**
  9209. * Prepares the defines related to the light information passed in parameter
  9210. * @param scene The scene we are intending to draw
  9211. * @param mesh The mesh the effect is compiling for
  9212. * @param defines The defines to update
  9213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9214. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9215. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9216. * @returns true if normals will be required for the rest of the effect
  9217. */
  9218. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9221. * that won t be acctive due to defines being turned off.
  9222. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9223. * @param samplersList The samplers list
  9224. * @param defines The defines helping in the list generation
  9225. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9226. */
  9227. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9228. /**
  9229. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9230. * @param defines The defines to update while falling back
  9231. * @param fallbacks The authorized effect fallbacks
  9232. * @param maxSimultaneousLights The maximum number of lights allowed
  9233. * @param rank the current rank of the Effect
  9234. * @returns The newly affected rank
  9235. */
  9236. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param defines The current Defines of the effect
  9242. */
  9243. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9244. /**
  9245. * Prepares the list of attributes required for bones according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the bones attributes for
  9248. * @param defines The current Defines of the effect
  9249. * @param fallbacks The current efffect fallback strategy
  9250. */
  9251. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9252. /**
  9253. * Prepares the list of attributes required for instances according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param defines The current Defines of the effect
  9256. */
  9257. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9258. /**
  9259. * Binds the light shadow information to the effect for the given mesh.
  9260. * @param light The light containing the generator
  9261. * @param scene The scene the lights belongs to
  9262. * @param mesh The mesh we are binding the information to render
  9263. * @param lightIndex The light index in the effect used to render the mesh
  9264. * @param effect The effect we are binding the data to
  9265. */
  9266. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9267. /**
  9268. * Binds the light information to the effect.
  9269. * @param light The light containing the generator
  9270. * @param effect The effect we are binding the data to
  9271. * @param lightIndex The light index in the effect used to render
  9272. */
  9273. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9274. /**
  9275. * Binds the lights information from the scene to the effect for the given mesh.
  9276. * @param scene The scene the lights belongs to
  9277. * @param mesh The mesh we are binding the information to render
  9278. * @param effect The effect we are binding the data to
  9279. * @param defines The generated defines for the effect
  9280. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9281. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9282. */
  9283. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9284. private static _tempFogColor;
  9285. /**
  9286. * Binds the fog information from the scene to the effect for the given mesh.
  9287. * @param scene The scene the lights belongs to
  9288. * @param mesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. * @param linearSpace Defines if the fog effect is applied in linear space
  9291. */
  9292. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9293. /**
  9294. * Binds the bones information from the mesh to the effect.
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9299. /**
  9300. * Binds the morph targets information from the mesh to the effect.
  9301. * @param abstractMesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9305. /**
  9306. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9307. * @param defines The generated defines used in the effect
  9308. * @param effect The effect we are binding the data to
  9309. * @param scene The scene we are willing to render with logarithmic scale for
  9310. */
  9311. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9312. /**
  9313. * Binds the clip plane information from the scene to the effect.
  9314. * @param scene The scene the clip plane information are extracted from
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindClipPlane(effect: Effect, scene: Scene): void;
  9318. }
  9319. }
  9320. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9321. /** @hidden */
  9322. export var kernelBlurVaryingDeclaration: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9328. /** @hidden */
  9329. export var kernelBlurFragment: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9335. /** @hidden */
  9336. export var kernelBlurFragment2: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9342. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9343. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9344. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9345. /** @hidden */
  9346. export var kernelBlurPixelShader: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9352. /** @hidden */
  9353. export var kernelBlurVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9359. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9360. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9361. /** @hidden */
  9362. export var kernelBlurVertexShader: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9368. import { Vector2 } from "babylonjs/Maths/math";
  9369. import { Nullable } from "babylonjs/types";
  9370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9371. import { Camera } from "babylonjs/Cameras/camera";
  9372. import { Effect } from "babylonjs/Materials/effect";
  9373. import { Engine } from "babylonjs/Engines/engine";
  9374. import "babylonjs/Shaders/kernelBlur.fragment";
  9375. import "babylonjs/Shaders/kernelBlur.vertex";
  9376. /**
  9377. * The Blur Post Process which blurs an image based on a kernel and direction.
  9378. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9379. */
  9380. export class BlurPostProcess extends PostProcess {
  9381. /** The direction in which to blur the image. */
  9382. direction: Vector2;
  9383. private blockCompilation;
  9384. protected _kernel: number;
  9385. protected _idealKernel: number;
  9386. protected _packedFloat: boolean;
  9387. private _staticDefines;
  9388. /**
  9389. * Sets the length in pixels of the blur sample region
  9390. */
  9391. /**
  9392. * Gets the length in pixels of the blur sample region
  9393. */
  9394. kernel: number;
  9395. /**
  9396. * Sets wether or not the blur needs to unpack/repack floats
  9397. */
  9398. /**
  9399. * Gets wether or not the blur is unpacking/repacking floats
  9400. */
  9401. packedFloat: boolean;
  9402. /**
  9403. * Creates a new instance BlurPostProcess
  9404. * @param name The name of the effect.
  9405. * @param direction The direction in which to blur the image.
  9406. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9407. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9408. * @param camera The camera to apply the render pass to.
  9409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9410. * @param engine The engine which the post process will be applied. (default: current engine)
  9411. * @param reusable If the post process can be reused on the same frame. (default: false)
  9412. * @param textureType Type of textures used when performing the post process. (default: 0)
  9413. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9414. */
  9415. constructor(name: string,
  9416. /** The direction in which to blur the image. */
  9417. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9418. /**
  9419. * Updates the effect with the current post process compile time values and recompiles the shader.
  9420. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9421. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9422. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9423. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9424. * @param onCompiled Called when the shader has been compiled.
  9425. * @param onError Called if there is an error when compiling a shader.
  9426. */
  9427. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9428. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9429. /**
  9430. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9431. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9432. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9433. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9434. * The gaps between physical kernels are compensated for in the weighting of the samples
  9435. * @param idealKernel Ideal blur kernel.
  9436. * @return Nearest best kernel.
  9437. */
  9438. protected _nearestBestKernel(idealKernel: number): number;
  9439. /**
  9440. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9441. * @param x The point on the Gaussian distribution to sample.
  9442. * @return the value of the Gaussian function at x.
  9443. */
  9444. protected _gaussianWeight(x: number): number;
  9445. /**
  9446. * Generates a string that can be used as a floating point number in GLSL.
  9447. * @param x Value to print.
  9448. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9449. * @return GLSL float string.
  9450. */
  9451. protected _glslFloat(x: number, decimalFigures?: number): string;
  9452. }
  9453. }
  9454. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9455. /** @hidden */
  9456. export var shadowMapPixelShader: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9462. /** @hidden */
  9463. export var bonesDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexGlobalDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9476. /** @hidden */
  9477. export var morphTargetsVertexDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9483. /** @hidden */
  9484. export var instancesDeclaration: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9490. /** @hidden */
  9491. export var helperFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9525. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9526. /** @hidden */
  9527. export var shadowMapVertexShader: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9533. /** @hidden */
  9534. export var depthBoxBlurPixelShader: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9540. import { Nullable } from "babylonjs/types";
  9541. import { Scene } from "babylonjs/scene";
  9542. import { Matrix } from "babylonjs/Maths/math";
  9543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9545. import { Mesh } from "babylonjs/Meshes/mesh";
  9546. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9548. import { Effect } from "babylonjs/Materials/effect";
  9549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9550. import "babylonjs/Shaders/shadowMap.fragment";
  9551. import "babylonjs/Shaders/shadowMap.vertex";
  9552. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9553. import { Observable } from "babylonjs/Misc/observable";
  9554. /**
  9555. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9556. */
  9557. export interface ICustomShaderOptions {
  9558. /**
  9559. * Gets or sets the custom shader name to use
  9560. */
  9561. shaderName: string;
  9562. /**
  9563. * The list of attribute names used in the shader
  9564. */
  9565. attributes?: string[];
  9566. /**
  9567. * The list of unifrom names used in the shader
  9568. */
  9569. uniforms?: string[];
  9570. /**
  9571. * The list of sampler names used in the shader
  9572. */
  9573. samplers?: string[];
  9574. /**
  9575. * The list of defines used in the shader
  9576. */
  9577. defines?: string[];
  9578. }
  9579. /**
  9580. * Interface to implement to create a shadow generator compatible with BJS.
  9581. */
  9582. export interface IShadowGenerator {
  9583. /**
  9584. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9585. * @returns The render target texture if present otherwise, null
  9586. */
  9587. getShadowMap(): Nullable<RenderTargetTexture>;
  9588. /**
  9589. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9590. * @returns The render target texture if the shadow map is present otherwise, null
  9591. */
  9592. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9593. /**
  9594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9595. * @param subMesh The submesh we want to render in the shadow map
  9596. * @param useInstances Defines wether will draw in the map using instances
  9597. * @returns true if ready otherwise, false
  9598. */
  9599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9600. /**
  9601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9602. * @param defines Defines of the material we want to update
  9603. * @param lightIndex Index of the light in the enabled light list of the material
  9604. */
  9605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9606. /**
  9607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9608. * defined in the generator but impacting the effect).
  9609. * It implies the unifroms available on the materials are the standard BJS ones.
  9610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9611. * @param effect The effect we are binfing the information for
  9612. */
  9613. bindShadowLight(lightIndex: string, effect: Effect): void;
  9614. /**
  9615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9616. * (eq to shadow prjection matrix * light transform matrix)
  9617. * @returns The transform matrix used to create the shadow map
  9618. */
  9619. getTransformMatrix(): Matrix;
  9620. /**
  9621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9622. * Cube and 2D textures for instance.
  9623. */
  9624. recreateShadowMap(): void;
  9625. /**
  9626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9627. * @param onCompiled Callback triggered at the and of the effects compilation
  9628. * @param options Sets of optional options forcing the compilation with different modes
  9629. */
  9630. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9631. useInstances: boolean;
  9632. }>): void;
  9633. /**
  9634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9635. * @param options Sets of optional options forcing the compilation with different modes
  9636. * @returns A promise that resolves when the compilation completes
  9637. */
  9638. forceCompilationAsync(options?: Partial<{
  9639. useInstances: boolean;
  9640. }>): Promise<void>;
  9641. /**
  9642. * Serializes the shadow generator setup to a json object.
  9643. * @returns The serialized JSON object
  9644. */
  9645. serialize(): any;
  9646. /**
  9647. * Disposes the Shadow map and related Textures and effects.
  9648. */
  9649. dispose(): void;
  9650. }
  9651. /**
  9652. * Default implementation IShadowGenerator.
  9653. * This is the main object responsible of generating shadows in the framework.
  9654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9655. */
  9656. export class ShadowGenerator implements IShadowGenerator {
  9657. /**
  9658. * Shadow generator mode None: no filtering applied.
  9659. */
  9660. static readonly FILTER_NONE: number;
  9661. /**
  9662. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9664. */
  9665. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9666. /**
  9667. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9668. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9669. */
  9670. static readonly FILTER_POISSONSAMPLING: number;
  9671. /**
  9672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9674. */
  9675. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9676. /**
  9677. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9678. * edge artifacts on steep falloff.
  9679. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9680. */
  9681. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9682. /**
  9683. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9684. * edge artifacts on steep falloff.
  9685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9686. */
  9687. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9688. /**
  9689. * Shadow generator mode PCF: Percentage Closer Filtering
  9690. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9691. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9692. */
  9693. static readonly FILTER_PCF: number;
  9694. /**
  9695. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9696. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9697. * Contact Hardening
  9698. */
  9699. static readonly FILTER_PCSS: number;
  9700. /**
  9701. * Reserved for PCF and PCSS
  9702. * Highest Quality.
  9703. *
  9704. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9705. *
  9706. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9707. */
  9708. static readonly QUALITY_HIGH: number;
  9709. /**
  9710. * Reserved for PCF and PCSS
  9711. * Good tradeoff for quality/perf cross devices
  9712. *
  9713. * Execute PCF on a 3*3 kernel.
  9714. *
  9715. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9716. */
  9717. static readonly QUALITY_MEDIUM: number;
  9718. /**
  9719. * Reserved for PCF and PCSS
  9720. * The lowest quality but the fastest.
  9721. *
  9722. * Execute PCF on a 1*1 kernel.
  9723. *
  9724. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9725. */
  9726. static readonly QUALITY_LOW: number;
  9727. /** Gets or sets the custom shader name to use */
  9728. customShaderOptions: ICustomShaderOptions;
  9729. /**
  9730. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9731. */
  9732. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9733. /**
  9734. * Observable triggered before a mesh is rendered in the shadow map.
  9735. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9736. */
  9737. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9738. private _bias;
  9739. /**
  9740. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9741. */
  9742. /**
  9743. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9744. */
  9745. bias: number;
  9746. private _normalBias;
  9747. /**
  9748. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9749. */
  9750. /**
  9751. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9752. */
  9753. normalBias: number;
  9754. private _blurBoxOffset;
  9755. /**
  9756. * Gets the blur box offset: offset applied during the blur pass.
  9757. * Only useful if useKernelBlur = false
  9758. */
  9759. /**
  9760. * Sets the blur box offset: offset applied during the blur pass.
  9761. * Only useful if useKernelBlur = false
  9762. */
  9763. blurBoxOffset: number;
  9764. private _blurScale;
  9765. /**
  9766. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9767. * 2 means half of the size.
  9768. */
  9769. /**
  9770. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9771. * 2 means half of the size.
  9772. */
  9773. blurScale: number;
  9774. private _blurKernel;
  9775. /**
  9776. * Gets the blur kernel: kernel size of the blur pass.
  9777. * Only useful if useKernelBlur = true
  9778. */
  9779. /**
  9780. * Sets the blur kernel: kernel size of the blur pass.
  9781. * Only useful if useKernelBlur = true
  9782. */
  9783. blurKernel: number;
  9784. private _useKernelBlur;
  9785. /**
  9786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9788. */
  9789. /**
  9790. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9791. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9792. */
  9793. useKernelBlur: boolean;
  9794. private _depthScale;
  9795. /**
  9796. * Gets the depth scale used in ESM mode.
  9797. */
  9798. /**
  9799. * Sets the depth scale used in ESM mode.
  9800. * This can override the scale stored on the light.
  9801. */
  9802. depthScale: number;
  9803. private _filter;
  9804. /**
  9805. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9806. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9807. */
  9808. /**
  9809. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9810. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9811. */
  9812. filter: number;
  9813. /**
  9814. * Gets if the current filter is set to Poisson Sampling.
  9815. */
  9816. /**
  9817. * Sets the current filter to Poisson Sampling.
  9818. */
  9819. usePoissonSampling: boolean;
  9820. /**
  9821. * Gets if the current filter is set to ESM.
  9822. */
  9823. /**
  9824. * Sets the current filter is to ESM.
  9825. */
  9826. useExponentialShadowMap: boolean;
  9827. /**
  9828. * Gets if the current filter is set to filtered ESM.
  9829. */
  9830. /**
  9831. * Gets if the current filter is set to filtered ESM.
  9832. */
  9833. useBlurExponentialShadowMap: boolean;
  9834. /**
  9835. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9836. * exponential to prevent steep falloff artifacts).
  9837. */
  9838. /**
  9839. * Sets the current filter to "close ESM" (using the inverse of the
  9840. * exponential to prevent steep falloff artifacts).
  9841. */
  9842. useCloseExponentialShadowMap: boolean;
  9843. /**
  9844. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9845. * exponential to prevent steep falloff artifacts).
  9846. */
  9847. /**
  9848. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9849. * exponential to prevent steep falloff artifacts).
  9850. */
  9851. useBlurCloseExponentialShadowMap: boolean;
  9852. /**
  9853. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9854. */
  9855. /**
  9856. * Sets the current filter to "PCF" (percentage closer filtering).
  9857. */
  9858. usePercentageCloserFiltering: boolean;
  9859. private _filteringQuality;
  9860. /**
  9861. * Gets the PCF or PCSS Quality.
  9862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9863. */
  9864. /**
  9865. * Sets the PCF or PCSS Quality.
  9866. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9867. */
  9868. filteringQuality: number;
  9869. /**
  9870. * Gets if the current filter is set to "PCSS" (contact hardening).
  9871. */
  9872. /**
  9873. * Sets the current filter to "PCSS" (contact hardening).
  9874. */
  9875. useContactHardeningShadow: boolean;
  9876. private _contactHardeningLightSizeUVRatio;
  9877. /**
  9878. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9879. * Using a ratio helps keeping shape stability independently of the map size.
  9880. *
  9881. * It does not account for the light projection as it was having too much
  9882. * instability during the light setup or during light position changes.
  9883. *
  9884. * Only valid if useContactHardeningShadow is true.
  9885. */
  9886. /**
  9887. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9888. * Using a ratio helps keeping shape stability independently of the map size.
  9889. *
  9890. * It does not account for the light projection as it was having too much
  9891. * instability during the light setup or during light position changes.
  9892. *
  9893. * Only valid if useContactHardeningShadow is true.
  9894. */
  9895. contactHardeningLightSizeUVRatio: number;
  9896. private _darkness;
  9897. /**
  9898. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9899. * 0 means strongest and 1 would means no shadow.
  9900. * @returns the darkness.
  9901. */
  9902. getDarkness(): number;
  9903. /**
  9904. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9905. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9906. * @returns the shadow generator allowing fluent coding.
  9907. */
  9908. setDarkness(darkness: number): ShadowGenerator;
  9909. private _transparencyShadow;
  9910. /**
  9911. * Sets the ability to have transparent shadow (boolean).
  9912. * @param transparent True if transparent else False
  9913. * @returns the shadow generator allowing fluent coding
  9914. */
  9915. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9916. private _shadowMap;
  9917. private _shadowMap2;
  9918. /**
  9919. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9920. * @returns The render target texture if present otherwise, null
  9921. */
  9922. getShadowMap(): Nullable<RenderTargetTexture>;
  9923. /**
  9924. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9925. * @returns The render target texture if the shadow map is present otherwise, null
  9926. */
  9927. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9930. * @param mesh Mesh to add
  9931. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9932. * @returns the Shadow Generator itself
  9933. */
  9934. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9935. /**
  9936. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9937. * @param mesh Mesh to remove
  9938. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9939. * @returns the Shadow Generator itself
  9940. */
  9941. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9942. /**
  9943. * Controls the extent to which the shadows fade out at the edge of the frustum
  9944. * Used only by directionals and spots
  9945. */
  9946. frustumEdgeFalloff: number;
  9947. private _light;
  9948. /**
  9949. * Returns the associated light object.
  9950. * @returns the light generating the shadow
  9951. */
  9952. getLight(): IShadowLight;
  9953. /**
  9954. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9955. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9956. * It might on the other hand introduce peter panning.
  9957. */
  9958. forceBackFacesOnly: boolean;
  9959. private _scene;
  9960. private _lightDirection;
  9961. private _effect;
  9962. private _viewMatrix;
  9963. private _projectionMatrix;
  9964. private _transformMatrix;
  9965. private _cachedPosition;
  9966. private _cachedDirection;
  9967. private _cachedDefines;
  9968. private _currentRenderID;
  9969. private _boxBlurPostprocess;
  9970. private _kernelBlurXPostprocess;
  9971. private _kernelBlurYPostprocess;
  9972. private _blurPostProcesses;
  9973. private _mapSize;
  9974. private _currentFaceIndex;
  9975. private _currentFaceIndexCache;
  9976. private _textureType;
  9977. private _defaultTextureMatrix;
  9978. /** @hidden */
  9979. static _SceneComponentInitialization: (scene: Scene) => void;
  9980. /**
  9981. * Creates a ShadowGenerator object.
  9982. * A ShadowGenerator is the required tool to use the shadows.
  9983. * Each light casting shadows needs to use its own ShadowGenerator.
  9984. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9985. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9986. * @param light The light object generating the shadows.
  9987. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9988. */
  9989. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9990. private _initializeGenerator;
  9991. private _initializeShadowMap;
  9992. private _initializeBlurRTTAndPostProcesses;
  9993. private _renderForShadowMap;
  9994. private _renderSubMeshForShadowMap;
  9995. private _applyFilterValues;
  9996. /**
  9997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9998. * @param onCompiled Callback triggered at the and of the effects compilation
  9999. * @param options Sets of optional options forcing the compilation with different modes
  10000. */
  10001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10002. useInstances: boolean;
  10003. }>): void;
  10004. /**
  10005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. * @returns A promise that resolves when the compilation completes
  10008. */
  10009. forceCompilationAsync(options?: Partial<{
  10010. useInstances: boolean;
  10011. }>): Promise<void>;
  10012. /**
  10013. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10014. * @param subMesh The submesh we want to render in the shadow map
  10015. * @param useInstances Defines wether will draw in the map using instances
  10016. * @returns true if ready otherwise, false
  10017. */
  10018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10019. /**
  10020. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10021. * @param defines Defines of the material we want to update
  10022. * @param lightIndex Index of the light in the enabled light list of the material
  10023. */
  10024. prepareDefines(defines: any, lightIndex: number): void;
  10025. /**
  10026. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10027. * defined in the generator but impacting the effect).
  10028. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10029. * @param effect The effect we are binfing the information for
  10030. */
  10031. bindShadowLight(lightIndex: string, effect: Effect): void;
  10032. /**
  10033. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10034. * (eq to shadow prjection matrix * light transform matrix)
  10035. * @returns The transform matrix used to create the shadow map
  10036. */
  10037. getTransformMatrix(): Matrix;
  10038. /**
  10039. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10040. * Cube and 2D textures for instance.
  10041. */
  10042. recreateShadowMap(): void;
  10043. private _disposeBlurPostProcesses;
  10044. private _disposeRTTandPostProcesses;
  10045. /**
  10046. * Disposes the ShadowGenerator.
  10047. * Returns nothing.
  10048. */
  10049. dispose(): void;
  10050. /**
  10051. * Serializes the shadow generator setup to a json object.
  10052. * @returns The serialized JSON object
  10053. */
  10054. serialize(): any;
  10055. /**
  10056. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10057. * @param parsedShadowGenerator The JSON object to parse
  10058. * @param scene The scene to create the shadow map for
  10059. * @returns The parsed shadow generator
  10060. */
  10061. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10062. }
  10063. }
  10064. declare module "babylonjs/Lights/light" {
  10065. import { Nullable } from "babylonjs/types";
  10066. import { Scene } from "babylonjs/scene";
  10067. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10068. import { Node } from "babylonjs/node";
  10069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10070. import { Effect } from "babylonjs/Materials/effect";
  10071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10072. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10073. /**
  10074. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10075. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10076. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  10077. */
  10078. export abstract class Light extends Node {
  10079. /**
  10080. * Falloff Default: light is falling off following the material specification:
  10081. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10082. */
  10083. static readonly FALLOFF_DEFAULT: number;
  10084. /**
  10085. * Falloff Physical: light is falling off following the inverse squared distance law.
  10086. */
  10087. static readonly FALLOFF_PHYSICAL: number;
  10088. /**
  10089. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10090. * to enhance interoperability with other engines.
  10091. */
  10092. static readonly FALLOFF_GLTF: number;
  10093. /**
  10094. * Falloff Standard: light is falling off like in the standard material
  10095. * to enhance interoperability with other materials.
  10096. */
  10097. static readonly FALLOFF_STANDARD: number;
  10098. /**
  10099. * If every light affecting the material is in this lightmapMode,
  10100. * material.lightmapTexture adds or multiplies
  10101. * (depends on material.useLightmapAsShadowmap)
  10102. * after every other light calculations.
  10103. */
  10104. static readonly LIGHTMAP_DEFAULT: number;
  10105. /**
  10106. * material.lightmapTexture as only diffuse lighting from this light
  10107. * adds only specular lighting from this light
  10108. * adds dynamic shadows
  10109. */
  10110. static readonly LIGHTMAP_SPECULAR: number;
  10111. /**
  10112. * material.lightmapTexture as only lighting
  10113. * no light calculation from this light
  10114. * only adds dynamic shadows from this light
  10115. */
  10116. static readonly LIGHTMAP_SHADOWSONLY: number;
  10117. /**
  10118. * Each light type uses the default quantity according to its type:
  10119. * point/spot lights use luminous intensity
  10120. * directional lights use illuminance
  10121. */
  10122. static readonly INTENSITYMODE_AUTOMATIC: number;
  10123. /**
  10124. * lumen (lm)
  10125. */
  10126. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10127. /**
  10128. * candela (lm/sr)
  10129. */
  10130. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10131. /**
  10132. * lux (lm/m^2)
  10133. */
  10134. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10135. /**
  10136. * nit (cd/m^2)
  10137. */
  10138. static readonly INTENSITYMODE_LUMINANCE: number;
  10139. /**
  10140. * Light type const id of the point light.
  10141. */
  10142. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10143. /**
  10144. * Light type const id of the directional light.
  10145. */
  10146. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10147. /**
  10148. * Light type const id of the spot light.
  10149. */
  10150. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10151. /**
  10152. * Light type const id of the hemispheric light.
  10153. */
  10154. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10155. /**
  10156. * Diffuse gives the basic color to an object.
  10157. */
  10158. diffuse: Color3;
  10159. /**
  10160. * Specular produces a highlight color on an object.
  10161. * Note: This is note affecting PBR materials.
  10162. */
  10163. specular: Color3;
  10164. /**
  10165. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10166. * falling off base on range or angle.
  10167. * This can be set to any values in Light.FALLOFF_x.
  10168. *
  10169. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10170. * other types of materials.
  10171. */
  10172. falloffType: number;
  10173. /**
  10174. * Strength of the light.
  10175. * Note: By default it is define in the framework own unit.
  10176. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10177. */
  10178. intensity: number;
  10179. private _range;
  10180. protected _inverseSquaredRange: number;
  10181. /**
  10182. * Defines how far from the source the light is impacting in scene units.
  10183. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10184. */
  10185. /**
  10186. * Defines how far from the source the light is impacting in scene units.
  10187. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10188. */
  10189. range: number;
  10190. /**
  10191. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10192. * of light.
  10193. */
  10194. private _photometricScale;
  10195. private _intensityMode;
  10196. /**
  10197. * Gets the photometric scale used to interpret the intensity.
  10198. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10199. */
  10200. /**
  10201. * Sets the photometric scale used to interpret the intensity.
  10202. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10203. */
  10204. intensityMode: number;
  10205. private _radius;
  10206. /**
  10207. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10208. */
  10209. /**
  10210. * sets the light radius used by PBR Materials to simulate soft area lights.
  10211. */
  10212. radius: number;
  10213. private _renderPriority;
  10214. /**
  10215. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10216. * exceeding the number allowed of the materials.
  10217. */
  10218. renderPriority: number;
  10219. private _shadowEnabled;
  10220. /**
  10221. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10222. * the current shadow generator.
  10223. */
  10224. /**
  10225. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10226. * the current shadow generator.
  10227. */
  10228. shadowEnabled: boolean;
  10229. private _includedOnlyMeshes;
  10230. /**
  10231. * Gets the only meshes impacted by this light.
  10232. */
  10233. /**
  10234. * Sets the only meshes impacted by this light.
  10235. */
  10236. includedOnlyMeshes: AbstractMesh[];
  10237. private _excludedMeshes;
  10238. /**
  10239. * Gets the meshes not impacted by this light.
  10240. */
  10241. /**
  10242. * Sets the meshes not impacted by this light.
  10243. */
  10244. excludedMeshes: AbstractMesh[];
  10245. private _excludeWithLayerMask;
  10246. /**
  10247. * Gets the layer id use to find what meshes are not impacted by the light.
  10248. * Inactive if 0
  10249. */
  10250. /**
  10251. * Sets the layer id use to find what meshes are not impacted by the light.
  10252. * Inactive if 0
  10253. */
  10254. excludeWithLayerMask: number;
  10255. private _includeOnlyWithLayerMask;
  10256. /**
  10257. * Gets the layer id use to find what meshes are impacted by the light.
  10258. * Inactive if 0
  10259. */
  10260. /**
  10261. * Sets the layer id use to find what meshes are impacted by the light.
  10262. * Inactive if 0
  10263. */
  10264. includeOnlyWithLayerMask: number;
  10265. private _lightmapMode;
  10266. /**
  10267. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10268. */
  10269. /**
  10270. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10271. */
  10272. lightmapMode: number;
  10273. /**
  10274. * Shadow generator associted to the light.
  10275. * @hidden Internal use only.
  10276. */
  10277. _shadowGenerator: Nullable<IShadowGenerator>;
  10278. /**
  10279. * @hidden Internal use only.
  10280. */
  10281. _excludedMeshesIds: string[];
  10282. /**
  10283. * @hidden Internal use only.
  10284. */
  10285. _includedOnlyMeshesIds: string[];
  10286. /**
  10287. * The current light unifom buffer.
  10288. * @hidden Internal use only.
  10289. */
  10290. _uniformBuffer: UniformBuffer;
  10291. /**
  10292. * Creates a Light object in the scene.
  10293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10294. * @param name The firendly name of the light
  10295. * @param scene The scene the light belongs too
  10296. */
  10297. constructor(name: string, scene: Scene);
  10298. protected abstract _buildUniformLayout(): void;
  10299. /**
  10300. * Sets the passed Effect "effect" with the Light information.
  10301. * @param effect The effect to update
  10302. * @param lightIndex The index of the light in the effect to update
  10303. * @returns The light
  10304. */
  10305. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10306. /**
  10307. * Returns the string "Light".
  10308. * @returns the class name
  10309. */
  10310. getClassName(): string;
  10311. /** @hidden */
  10312. readonly _isLight: boolean;
  10313. /**
  10314. * Converts the light information to a readable string for debug purpose.
  10315. * @param fullDetails Supports for multiple levels of logging within scene loading
  10316. * @returns the human readable light info
  10317. */
  10318. toString(fullDetails?: boolean): string;
  10319. /** @hidden */
  10320. protected _syncParentEnabledState(): void;
  10321. /**
  10322. * Set the enabled state of this node.
  10323. * @param value - the new enabled state
  10324. */
  10325. setEnabled(value: boolean): void;
  10326. /**
  10327. * Returns the Light associated shadow generator if any.
  10328. * @return the associated shadow generator.
  10329. */
  10330. getShadowGenerator(): Nullable<IShadowGenerator>;
  10331. /**
  10332. * Returns a Vector3, the absolute light position in the World.
  10333. * @returns the world space position of the light
  10334. */
  10335. getAbsolutePosition(): Vector3;
  10336. /**
  10337. * Specifies if the light will affect the passed mesh.
  10338. * @param mesh The mesh to test against the light
  10339. * @return true the mesh is affected otherwise, false.
  10340. */
  10341. canAffectMesh(mesh: AbstractMesh): boolean;
  10342. /**
  10343. * Sort function to order lights for rendering.
  10344. * @param a First Light object to compare to second.
  10345. * @param b Second Light object to compare first.
  10346. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10347. */
  10348. static CompareLightsPriority(a: Light, b: Light): number;
  10349. /**
  10350. * Releases resources associated with this node.
  10351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10353. */
  10354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10355. /**
  10356. * Returns the light type ID (integer).
  10357. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10358. */
  10359. getTypeID(): number;
  10360. /**
  10361. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10362. * @returns the scaled intensity in intensity mode unit
  10363. */
  10364. getScaledIntensity(): number;
  10365. /**
  10366. * Returns a new Light object, named "name", from the current one.
  10367. * @param name The name of the cloned light
  10368. * @returns the new created light
  10369. */
  10370. clone(name: string): Nullable<Light>;
  10371. /**
  10372. * Serializes the current light into a Serialization object.
  10373. * @returns the serialized object.
  10374. */
  10375. serialize(): any;
  10376. /**
  10377. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10378. * This new light is named "name" and added to the passed scene.
  10379. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10380. * @param name The friendly name of the light
  10381. * @param scene The scene the new light will belong to
  10382. * @returns the constructor function
  10383. */
  10384. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10385. /**
  10386. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10387. * @param parsedLight The JSON representation of the light
  10388. * @param scene The scene to create the parsed light in
  10389. * @returns the created light after parsing
  10390. */
  10391. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10392. private _hookArrayForExcluded;
  10393. private _hookArrayForIncludedOnly;
  10394. private _resyncMeshes;
  10395. /**
  10396. * Forces the meshes to update their light related information in their rendering used effects
  10397. * @hidden Internal Use Only
  10398. */
  10399. _markMeshesAsLightDirty(): void;
  10400. /**
  10401. * Recomputes the cached photometric scale if needed.
  10402. */
  10403. private _computePhotometricScale;
  10404. /**
  10405. * Returns the Photometric Scale according to the light type and intensity mode.
  10406. */
  10407. private _getPhotometricScale;
  10408. /**
  10409. * Reorder the light in the scene according to their defined priority.
  10410. * @hidden Internal Use Only
  10411. */
  10412. _reorderLightsInScene(): void;
  10413. /**
  10414. * Prepares the list of defines specific to the light type.
  10415. * @param defines the list of defines
  10416. * @param lightIndex defines the index of the light for the effect
  10417. */
  10418. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10419. }
  10420. }
  10421. declare module "babylonjs/Actions/action" {
  10422. import { Observable } from "babylonjs/Misc/observable";
  10423. import { Condition } from "babylonjs/Actions/condition";
  10424. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10425. import { ActionManager } from "babylonjs/Actions/actionManager";
  10426. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10427. /**
  10428. * Interface used to define Action
  10429. */
  10430. export interface IAction {
  10431. /**
  10432. * Trigger for the action
  10433. */
  10434. trigger: number;
  10435. /** Options of the trigger */
  10436. triggerOptions: any;
  10437. /**
  10438. * Gets the trigger parameters
  10439. * @returns the trigger parameters
  10440. */
  10441. getTriggerParameter(): any;
  10442. /**
  10443. * Internal only - executes current action event
  10444. * @hidden
  10445. */
  10446. _executeCurrent(evt?: ActionEvent): void;
  10447. /**
  10448. * Serialize placeholder for child classes
  10449. * @param parent of child
  10450. * @returns the serialized object
  10451. */
  10452. serialize(parent: any): any;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */
  10457. _prepare(): void;
  10458. /**
  10459. * Internal only - manager for action
  10460. * @hidden
  10461. */
  10462. _actionManager: AbstractActionManager;
  10463. }
  10464. /**
  10465. * The action to be carried out following a trigger
  10466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10467. */
  10468. export class Action implements IAction {
  10469. /** the trigger, with or without parameters, for the action */
  10470. triggerOptions: any;
  10471. /**
  10472. * Trigger for the action
  10473. */
  10474. trigger: number;
  10475. /**
  10476. * Internal only - manager for action
  10477. * @hidden
  10478. */
  10479. _actionManager: ActionManager;
  10480. private _nextActiveAction;
  10481. private _child;
  10482. private _condition?;
  10483. private _triggerParameter;
  10484. /**
  10485. * An event triggered prior to action being executed.
  10486. */
  10487. onBeforeExecuteObservable: Observable<Action>;
  10488. /**
  10489. * Creates a new Action
  10490. * @param triggerOptions the trigger, with or without parameters, for the action
  10491. * @param condition an optional determinant of action
  10492. */
  10493. constructor(
  10494. /** the trigger, with or without parameters, for the action */
  10495. triggerOptions: any, condition?: Condition);
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _prepare(): void;
  10501. /**
  10502. * Gets the trigger parameters
  10503. * @returns the trigger parameters
  10504. */
  10505. getTriggerParameter(): any;
  10506. /**
  10507. * Internal only - executes current action event
  10508. * @hidden
  10509. */
  10510. _executeCurrent(evt?: ActionEvent): void;
  10511. /**
  10512. * Execute placeholder for child classes
  10513. * @param evt optional action event
  10514. */
  10515. execute(evt?: ActionEvent): void;
  10516. /**
  10517. * Skips to next active action
  10518. */
  10519. skipToNextActiveAction(): void;
  10520. /**
  10521. * Adds action to chain of actions, may be a DoNothingAction
  10522. * @param action defines the next action to execute
  10523. * @returns The action passed in
  10524. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10525. */
  10526. then(action: Action): Action;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. _getProperty(propertyPath: string): string;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. _getEffectiveTarget(target: any, propertyPath: string): any;
  10537. /**
  10538. * Serialize placeholder for child classes
  10539. * @param parent of child
  10540. * @returns the serialized object
  10541. */
  10542. serialize(parent: any): any;
  10543. /**
  10544. * Internal only called by serialize
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedAction: any, parent?: any): any;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. static _SerializeValueAsString: (value: any) => string;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10558. name: string;
  10559. targetType: string;
  10560. value: string;
  10561. };
  10562. }
  10563. }
  10564. declare module "babylonjs/Actions/condition" {
  10565. import { ActionManager } from "babylonjs/Actions/actionManager";
  10566. /**
  10567. * A Condition applied to an Action
  10568. */
  10569. export class Condition {
  10570. /**
  10571. * Internal only - manager for action
  10572. * @hidden
  10573. */
  10574. _actionManager: ActionManager;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. _evaluationId: number;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. _currentResult: boolean;
  10585. /**
  10586. * Creates a new Condition
  10587. * @param actionManager the manager of the action the condition is applied to
  10588. */
  10589. constructor(actionManager: ActionManager);
  10590. /**
  10591. * Check if the current condition is valid
  10592. * @returns a boolean
  10593. */
  10594. isValid(): boolean;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. _getProperty(propertyPath: string): string;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _getEffectiveTarget(target: any, propertyPath: string): any;
  10605. /**
  10606. * Serialize placeholder for child classes
  10607. * @returns the serialized object
  10608. */
  10609. serialize(): any;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. protected _serialize(serializedCondition: any): any;
  10615. }
  10616. /**
  10617. * Defines specific conditional operators as extensions of Condition
  10618. */
  10619. export class ValueCondition extends Condition {
  10620. /** path to specify the property of the target the conditional operator uses */
  10621. propertyPath: string;
  10622. /** the value compared by the conditional operator against the current value of the property */
  10623. value: any;
  10624. /** the conditional operator, default ValueCondition.IsEqual */
  10625. operator: number;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. private static _IsEqual;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private static _IsDifferent;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. private static _IsGreater;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. private static _IsLesser;
  10646. /**
  10647. * returns the number for IsEqual
  10648. */
  10649. static readonly IsEqual: number;
  10650. /**
  10651. * Returns the number for IsDifferent
  10652. */
  10653. static readonly IsDifferent: number;
  10654. /**
  10655. * Returns the number for IsGreater
  10656. */
  10657. static readonly IsGreater: number;
  10658. /**
  10659. * Returns the number for IsLesser
  10660. */
  10661. static readonly IsLesser: number;
  10662. /**
  10663. * Internal only The action manager for the condition
  10664. * @hidden
  10665. */
  10666. _actionManager: ActionManager;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. private _target;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. private _effectiveTarget;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _property;
  10682. /**
  10683. * Creates a new ValueCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target for the action
  10686. * @param propertyPath path to specify the property of the target the conditional operator uses
  10687. * @param value the value compared by the conditional operator against the current value of the property
  10688. * @param operator the conditional operator, default ValueCondition.IsEqual
  10689. */
  10690. constructor(actionManager: ActionManager, target: any,
  10691. /** path to specify the property of the target the conditional operator uses */
  10692. propertyPath: string,
  10693. /** the value compared by the conditional operator against the current value of the property */
  10694. value: any,
  10695. /** the conditional operator, default ValueCondition.IsEqual */
  10696. operator?: number);
  10697. /**
  10698. * Compares the given value with the property value for the specified conditional operator
  10699. * @returns the result of the comparison
  10700. */
  10701. isValid(): boolean;
  10702. /**
  10703. * Serialize the ValueCondition into a JSON compatible object
  10704. * @returns serialization object
  10705. */
  10706. serialize(): any;
  10707. /**
  10708. * Gets the name of the conditional operator for the ValueCondition
  10709. * @param operator the conditional operator
  10710. * @returns the name
  10711. */
  10712. static GetOperatorName(operator: number): string;
  10713. }
  10714. /**
  10715. * Defines a predicate condition as an extension of Condition
  10716. */
  10717. export class PredicateCondition extends Condition {
  10718. /** defines the predicate function used to validate the condition */
  10719. predicate: () => boolean;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: ActionManager;
  10725. /**
  10726. * Creates a new PredicateCondition
  10727. * @param actionManager manager for the action the condition applies to
  10728. * @param predicate defines the predicate function used to validate the condition
  10729. */
  10730. constructor(actionManager: ActionManager,
  10731. /** defines the predicate function used to validate the condition */
  10732. predicate: () => boolean);
  10733. /**
  10734. * @returns the validity of the predicate condition
  10735. */
  10736. isValid(): boolean;
  10737. }
  10738. /**
  10739. * Defines a state condition as an extension of Condition
  10740. */
  10741. export class StateCondition extends Condition {
  10742. /** Value to compare with target state */
  10743. value: string;
  10744. /**
  10745. * Internal only - manager for action
  10746. * @hidden
  10747. */
  10748. _actionManager: ActionManager;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _target;
  10754. /**
  10755. * Creates a new StateCondition
  10756. * @param actionManager manager for the action the condition applies to
  10757. * @param target of the condition
  10758. * @param value to compare with target state
  10759. */
  10760. constructor(actionManager: ActionManager, target: any,
  10761. /** Value to compare with target state */
  10762. value: string);
  10763. /**
  10764. * Gets a boolean indicating if the current condition is met
  10765. * @returns the validity of the state
  10766. */
  10767. isValid(): boolean;
  10768. /**
  10769. * Serialize the StateCondition into a JSON compatible object
  10770. * @returns serialization object
  10771. */
  10772. serialize(): any;
  10773. }
  10774. }
  10775. declare module "babylonjs/Actions/directActions" {
  10776. import { Action } from "babylonjs/Actions/action";
  10777. import { Condition } from "babylonjs/Actions/condition";
  10778. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10779. /**
  10780. * This defines an action responsible to toggle a boolean once triggered.
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10782. */
  10783. export class SwitchBooleanAction extends Action {
  10784. /**
  10785. * The path to the boolean property in the target object
  10786. */
  10787. propertyPath: string;
  10788. private _target;
  10789. private _effectiveTarget;
  10790. private _property;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the object containing the boolean
  10795. * @param propertyPath defines the path to the boolean property in the target object
  10796. * @param condition defines the trigger related conditions
  10797. */
  10798. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10799. /** @hidden */
  10800. _prepare(): void;
  10801. /**
  10802. * Execute the action toggle the boolean value.
  10803. */
  10804. execute(): void;
  10805. /**
  10806. * Serializes the actions and its related information.
  10807. * @param parent defines the object to serialize in
  10808. * @returns the serialized object
  10809. */
  10810. serialize(parent: any): any;
  10811. }
  10812. /**
  10813. * This defines an action responsible to set a the state field of the target
  10814. * to a desired value once triggered.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10816. */
  10817. export class SetStateAction extends Action {
  10818. /**
  10819. * The value to store in the state field.
  10820. */
  10821. value: string;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the object containing the state property
  10827. * @param value defines the value to store in the state field
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10831. /**
  10832. * Execute the action and store the value on the target state property.
  10833. */
  10834. execute(): void;
  10835. /**
  10836. * Serializes the actions and its related information.
  10837. * @param parent defines the object to serialize in
  10838. * @returns the serialized object
  10839. */
  10840. serialize(parent: any): any;
  10841. }
  10842. /**
  10843. * This defines an action responsible to set a property of the target
  10844. * to a desired value once triggered.
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10846. */
  10847. export class SetValueAction extends Action {
  10848. /**
  10849. * The path of the property to set in the target.
  10850. */
  10851. propertyPath: string;
  10852. /**
  10853. * The value to set in the property
  10854. */
  10855. value: any;
  10856. private _target;
  10857. private _effectiveTarget;
  10858. private _property;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the object containing the property
  10863. * @param propertyPath defines the path of the property to set in the target
  10864. * @param value defines the value to set in the property
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action and set the targetted property to the desired value.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to increment the target value
  10883. * to a desired value once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class IncrementValueAction extends Action {
  10887. /**
  10888. * The path of the property to increment in the target.
  10889. */
  10890. propertyPath: string;
  10891. /**
  10892. * The value we should increment the property by.
  10893. */
  10894. value: any;
  10895. private _target;
  10896. private _effectiveTarget;
  10897. private _property;
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param target defines the object containing the property
  10902. * @param propertyPath defines the path of the property to increment in the target
  10903. * @param value defines the value value we should increment the property by
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and increment the target of the value amount.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to start an animation once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class PlayAnimationAction extends Action {
  10925. /**
  10926. * Where the animation should start (animation frame)
  10927. */
  10928. from: number;
  10929. /**
  10930. * Where the animation should stop (animation frame)
  10931. */
  10932. to: number;
  10933. /**
  10934. * Define if the animation should loop or stop after the first play.
  10935. */
  10936. loop?: boolean;
  10937. private _target;
  10938. /**
  10939. * Instantiate the action
  10940. * @param triggerOptions defines the trigger options
  10941. * @param target defines the target animation or animation name
  10942. * @param from defines from where the animation should start (animation frame)
  10943. * @param end defines where the animation should stop (animation frame)
  10944. * @param loop defines if the animation should loop or stop after the first play
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10948. /** @hidden */
  10949. _prepare(): void;
  10950. /**
  10951. * Execute the action and play the animation.
  10952. */
  10953. execute(): void;
  10954. /**
  10955. * Serializes the actions and its related information.
  10956. * @param parent defines the object to serialize in
  10957. * @returns the serialized object
  10958. */
  10959. serialize(parent: any): any;
  10960. }
  10961. /**
  10962. * This defines an action responsible to stop an animation once triggered.
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10964. */
  10965. export class StopAnimationAction extends Action {
  10966. private _target;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param target defines the target animation or animation name
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, target: any, condition?: Condition);
  10974. /** @hidden */
  10975. _prepare(): void;
  10976. /**
  10977. * Execute the action and stop the animation.
  10978. */
  10979. execute(): void;
  10980. /**
  10981. * Serializes the actions and its related information.
  10982. * @param parent defines the object to serialize in
  10983. * @returns the serialized object
  10984. */
  10985. serialize(parent: any): any;
  10986. }
  10987. /**
  10988. * This defines an action responsible that does nothing once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class DoNothingAction extends Action {
  10992. /**
  10993. * Instantiate the action
  10994. * @param triggerOptions defines the trigger options
  10995. * @param condition defines the trigger related conditions
  10996. */
  10997. constructor(triggerOptions?: any, condition?: Condition);
  10998. /**
  10999. * Execute the action and do nothing.
  11000. */
  11001. execute(): void;
  11002. /**
  11003. * Serializes the actions and its related information.
  11004. * @param parent defines the object to serialize in
  11005. * @returns the serialized object
  11006. */
  11007. serialize(parent: any): any;
  11008. }
  11009. /**
  11010. * This defines an action responsible to trigger several actions once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class CombineAction extends Action {
  11014. /**
  11015. * The list of aggregated animations to run.
  11016. */
  11017. children: Action[];
  11018. /**
  11019. * Instantiate the action
  11020. * @param triggerOptions defines the trigger options
  11021. * @param children defines the list of aggregated animations to run
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and executes all the aggregated actions.
  11029. */
  11030. execute(evt: ActionEvent): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. /**
  11039. * This defines an action responsible to run code (external event) once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class ExecuteCodeAction extends Action {
  11043. /**
  11044. * The callback function to run.
  11045. */
  11046. func: (evt: ActionEvent) => void;
  11047. /**
  11048. * Instantiate the action
  11049. * @param triggerOptions defines the trigger options
  11050. * @param func defines the callback function to run
  11051. * @param condition defines the trigger related conditions
  11052. */
  11053. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11054. /**
  11055. * Execute the action and run the attached code.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. }
  11059. /**
  11060. * This defines an action responsible to set the parent property of the target once triggered.
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11062. */
  11063. export class SetParentAction extends Action {
  11064. private _parent;
  11065. private _target;
  11066. /**
  11067. * Instantiate the action
  11068. * @param triggerOptions defines the trigger options
  11069. * @param target defines the target containing the parent property
  11070. * @param parent defines from where the animation should start (animation frame)
  11071. * @param condition defines the trigger related conditions
  11072. */
  11073. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11074. /** @hidden */
  11075. _prepare(): void;
  11076. /**
  11077. * Execute the action and set the parent property.
  11078. */
  11079. execute(): void;
  11080. /**
  11081. * Serializes the actions and its related information.
  11082. * @param parent defines the object to serialize in
  11083. * @returns the serialized object
  11084. */
  11085. serialize(parent: any): any;
  11086. }
  11087. }
  11088. declare module "babylonjs/Actions/actionManager" {
  11089. import { Nullable } from "babylonjs/types";
  11090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11091. import { Scene } from "babylonjs/scene";
  11092. import { IAction } from "babylonjs/Actions/action";
  11093. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11094. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11095. /**
  11096. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11097. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11099. */
  11100. export class ActionManager extends AbstractActionManager {
  11101. /**
  11102. * Nothing
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly NothingTrigger: number;
  11106. /**
  11107. * On pick
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnPickTrigger: number;
  11111. /**
  11112. * On left pick
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnLeftPickTrigger: number;
  11116. /**
  11117. * On right pick
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11119. */
  11120. static readonly OnRightPickTrigger: number;
  11121. /**
  11122. * On center pick
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11124. */
  11125. static readonly OnCenterPickTrigger: number;
  11126. /**
  11127. * On pick down
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11129. */
  11130. static readonly OnPickDownTrigger: number;
  11131. /**
  11132. * On double pick
  11133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11134. */
  11135. static readonly OnDoublePickTrigger: number;
  11136. /**
  11137. * On pick up
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11139. */
  11140. static readonly OnPickUpTrigger: number;
  11141. /**
  11142. * On pick out.
  11143. * This trigger will only be raised if you also declared a OnPickDown
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11145. */
  11146. static readonly OnPickOutTrigger: number;
  11147. /**
  11148. * On long press
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11150. */
  11151. static readonly OnLongPressTrigger: number;
  11152. /**
  11153. * On pointer over
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11155. */
  11156. static readonly OnPointerOverTrigger: number;
  11157. /**
  11158. * On pointer out
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11160. */
  11161. static readonly OnPointerOutTrigger: number;
  11162. /**
  11163. * On every frame
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly OnEveryFrameTrigger: number;
  11167. /**
  11168. * On intersection enter
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnIntersectionEnterTrigger: number;
  11172. /**
  11173. * On intersection exit
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnIntersectionExitTrigger: number;
  11177. /**
  11178. * On key down
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnKeyDownTrigger: number;
  11182. /**
  11183. * On key up
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnKeyUpTrigger: number;
  11187. private _scene;
  11188. /**
  11189. * Creates a new action manager
  11190. * @param scene defines the hosting scene
  11191. */
  11192. constructor(scene: Scene);
  11193. /**
  11194. * Releases all associated resources
  11195. */
  11196. dispose(): void;
  11197. /**
  11198. * Gets hosting scene
  11199. * @returns the hosting scene
  11200. */
  11201. getScene(): Scene;
  11202. /**
  11203. * Does this action manager handles actions of any of the given triggers
  11204. * @param triggers defines the triggers to be tested
  11205. * @return a boolean indicating whether one (or more) of the triggers is handled
  11206. */
  11207. hasSpecificTriggers(triggers: number[]): boolean;
  11208. /**
  11209. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11210. * speed.
  11211. * @param triggerA defines the trigger to be tested
  11212. * @param triggerB defines the trigger to be tested
  11213. * @return a boolean indicating whether one (or more) of the triggers is handled
  11214. */
  11215. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11216. /**
  11217. * Does this action manager handles actions of a given trigger
  11218. * @param trigger defines the trigger to be tested
  11219. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11220. * @return whether the trigger is handled
  11221. */
  11222. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11223. /**
  11224. * Does this action manager has pointer triggers
  11225. */
  11226. readonly hasPointerTriggers: boolean;
  11227. /**
  11228. * Does this action manager has pick triggers
  11229. */
  11230. readonly hasPickTriggers: boolean;
  11231. /**
  11232. * Registers an action to this action manager
  11233. * @param action defines the action to be registered
  11234. * @return the action amended (prepared) after registration
  11235. */
  11236. registerAction(action: IAction): Nullable<IAction>;
  11237. /**
  11238. * Unregisters an action to this action manager
  11239. * @param action defines the action to be unregistered
  11240. * @return a boolean indicating whether the action has been unregistered
  11241. */
  11242. unregisterAction(action: IAction): Boolean;
  11243. /**
  11244. * Process a specific trigger
  11245. * @param trigger defines the trigger to process
  11246. * @param evt defines the event details to be processed
  11247. */
  11248. processTrigger(trigger: number, evt?: IActionEvent): void;
  11249. /** @hidden */
  11250. _getEffectiveTarget(target: any, propertyPath: string): any;
  11251. /** @hidden */
  11252. _getProperty(propertyPath: string): string;
  11253. /**
  11254. * Serialize this manager to a JSON object
  11255. * @param name defines the property name to store this manager
  11256. * @returns a JSON representation of this manager
  11257. */
  11258. serialize(name: string): any;
  11259. /**
  11260. * Creates a new ActionManager from a JSON data
  11261. * @param parsedActions defines the JSON data to read from
  11262. * @param object defines the hosting mesh
  11263. * @param scene defines the hosting scene
  11264. */
  11265. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11266. /**
  11267. * Get a trigger name by index
  11268. * @param trigger defines the trigger index
  11269. * @returns a trigger name
  11270. */
  11271. static GetTriggerName(trigger: number): string;
  11272. }
  11273. }
  11274. declare module "babylonjs/Culling/ray" {
  11275. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11276. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11278. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11279. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11280. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11281. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11282. /**
  11283. * Class representing a ray with position and direction
  11284. */
  11285. export class Ray {
  11286. /** origin point */
  11287. origin: Vector3;
  11288. /** direction */
  11289. direction: Vector3;
  11290. /** length of the ray */
  11291. length: number;
  11292. private static readonly TmpVector3;
  11293. private _tmpRay;
  11294. /**
  11295. * Creates a new ray
  11296. * @param origin origin point
  11297. * @param direction direction
  11298. * @param length length of the ray
  11299. */
  11300. constructor(
  11301. /** origin point */
  11302. origin: Vector3,
  11303. /** direction */
  11304. direction: Vector3,
  11305. /** length of the ray */
  11306. length?: number);
  11307. /**
  11308. * Checks if the ray intersects a box
  11309. * @param minimum bound of the box
  11310. * @param maximum bound of the box
  11311. * @param intersectionTreshold extra extend to be added to the box in all direction
  11312. * @returns if the box was hit
  11313. */
  11314. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11315. /**
  11316. * Checks if the ray intersects a box
  11317. * @param box the bounding box to check
  11318. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11319. * @returns if the box was hit
  11320. */
  11321. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11322. /**
  11323. * If the ray hits a sphere
  11324. * @param sphere the bounding sphere to check
  11325. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11326. * @returns true if it hits the sphere
  11327. */
  11328. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11329. /**
  11330. * If the ray hits a triange
  11331. * @param vertex0 triangle vertex
  11332. * @param vertex1 triangle vertex
  11333. * @param vertex2 triangle vertex
  11334. * @returns intersection information if hit
  11335. */
  11336. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11337. /**
  11338. * Checks if ray intersects a plane
  11339. * @param plane the plane to check
  11340. * @returns the distance away it was hit
  11341. */
  11342. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11343. /**
  11344. * Checks if ray intersects a mesh
  11345. * @param mesh the mesh to check
  11346. * @param fastCheck if only the bounding box should checked
  11347. * @returns picking info of the intersecton
  11348. */
  11349. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11350. /**
  11351. * Checks if ray intersects a mesh
  11352. * @param meshes the meshes to check
  11353. * @param fastCheck if only the bounding box should checked
  11354. * @param results array to store result in
  11355. * @returns Array of picking infos
  11356. */
  11357. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11358. private _comparePickingInfo;
  11359. private static smallnum;
  11360. private static rayl;
  11361. /**
  11362. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11363. * @param sega the first point of the segment to test the intersection against
  11364. * @param segb the second point of the segment to test the intersection against
  11365. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11366. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11367. */
  11368. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11369. /**
  11370. * Update the ray from viewport position
  11371. * @param x position
  11372. * @param y y position
  11373. * @param viewportWidth viewport width
  11374. * @param viewportHeight viewport height
  11375. * @param world world matrix
  11376. * @param view view matrix
  11377. * @param projection projection matrix
  11378. * @returns this ray updated
  11379. */
  11380. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11381. /**
  11382. * Creates a ray with origin and direction of 0,0,0
  11383. * @returns the new ray
  11384. */
  11385. static Zero(): Ray;
  11386. /**
  11387. * Creates a new ray from screen space and viewport
  11388. * @param x position
  11389. * @param y y position
  11390. * @param viewportWidth viewport width
  11391. * @param viewportHeight viewport height
  11392. * @param world world matrix
  11393. * @param view view matrix
  11394. * @param projection projection matrix
  11395. * @returns new ray
  11396. */
  11397. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11398. /**
  11399. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11400. * transformed to the given world matrix.
  11401. * @param origin The origin point
  11402. * @param end The end point
  11403. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11404. * @returns the new ray
  11405. */
  11406. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11407. /**
  11408. * Transforms a ray by a matrix
  11409. * @param ray ray to transform
  11410. * @param matrix matrix to apply
  11411. * @returns the resulting new ray
  11412. */
  11413. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11414. /**
  11415. * Transforms a ray by a matrix
  11416. * @param ray ray to transform
  11417. * @param matrix matrix to apply
  11418. * @param result ray to store result in
  11419. */
  11420. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11421. /**
  11422. * Unproject a ray from screen space to object space
  11423. * @param sourceX defines the screen space x coordinate to use
  11424. * @param sourceY defines the screen space y coordinate to use
  11425. * @param viewportWidth defines the current width of the viewport
  11426. * @param viewportHeight defines the current height of the viewport
  11427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11428. * @param view defines the view matrix to use
  11429. * @param projection defines the projection matrix to use
  11430. */
  11431. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11432. }
  11433. /**
  11434. * Type used to define predicate used to select faces when a mesh intersection is detected
  11435. */
  11436. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11437. module "babylonjs/scene" {
  11438. interface Scene {
  11439. /** @hidden */
  11440. _tempPickingRay: Nullable<Ray>;
  11441. /** @hidden */
  11442. _cachedRayForTransform: Ray;
  11443. /** @hidden */
  11444. _pickWithRayInverseMatrix: Matrix;
  11445. /** @hidden */
  11446. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11447. /** @hidden */
  11448. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11449. }
  11450. }
  11451. }
  11452. declare module "babylonjs/sceneComponent" {
  11453. import { Scene } from "babylonjs/scene";
  11454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11456. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11457. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11458. import { Nullable } from "babylonjs/types";
  11459. import { Camera } from "babylonjs/Cameras/camera";
  11460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11461. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11462. import { AbstractScene } from "babylonjs/abstractScene";
  11463. /**
  11464. * Groups all the scene component constants in one place to ease maintenance.
  11465. * @hidden
  11466. */
  11467. export class SceneComponentConstants {
  11468. static readonly NAME_EFFECTLAYER: string;
  11469. static readonly NAME_LAYER: string;
  11470. static readonly NAME_LENSFLARESYSTEM: string;
  11471. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11472. static readonly NAME_PARTICLESYSTEM: string;
  11473. static readonly NAME_GAMEPAD: string;
  11474. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11475. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11476. static readonly NAME_DEPTHRENDERER: string;
  11477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11478. static readonly NAME_SPRITE: string;
  11479. static readonly NAME_OUTLINERENDERER: string;
  11480. static readonly NAME_PROCEDURALTEXTURE: string;
  11481. static readonly NAME_SHADOWGENERATOR: string;
  11482. static readonly NAME_OCTREE: string;
  11483. static readonly NAME_PHYSICSENGINE: string;
  11484. static readonly NAME_AUDIO: string;
  11485. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11486. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11487. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11488. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11489. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11490. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11491. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11492. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11493. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11494. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11495. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11496. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11497. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11498. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11499. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11500. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11501. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11502. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11504. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11505. static readonly STEP_AFTERRENDER_AUDIO: number;
  11506. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11507. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11508. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11509. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11510. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11511. static readonly STEP_POINTERMOVE_SPRITE: number;
  11512. static readonly STEP_POINTERDOWN_SPRITE: number;
  11513. static readonly STEP_POINTERUP_SPRITE: number;
  11514. }
  11515. /**
  11516. * This represents a scene component.
  11517. *
  11518. * This is used to decouple the dependency the scene is having on the different workloads like
  11519. * layers, post processes...
  11520. */
  11521. export interface ISceneComponent {
  11522. /**
  11523. * The name of the component. Each component must have a unique name.
  11524. */
  11525. name: string;
  11526. /**
  11527. * The scene the component belongs to.
  11528. */
  11529. scene: Scene;
  11530. /**
  11531. * Register the component to one instance of a scene.
  11532. */
  11533. register(): void;
  11534. /**
  11535. * Rebuilds the elements related to this component in case of
  11536. * context lost for instance.
  11537. */
  11538. rebuild(): void;
  11539. /**
  11540. * Disposes the component and the associated ressources.
  11541. */
  11542. dispose(): void;
  11543. }
  11544. /**
  11545. * This represents a SERIALIZABLE scene component.
  11546. *
  11547. * This extends Scene Component to add Serialization methods on top.
  11548. */
  11549. export interface ISceneSerializableComponent extends ISceneComponent {
  11550. /**
  11551. * Adds all the element from the container to the scene
  11552. * @param container the container holding the elements
  11553. */
  11554. addFromContainer(container: AbstractScene): void;
  11555. /**
  11556. * Removes all the elements in the container from the scene
  11557. * @param container contains the elements to remove
  11558. */
  11559. removeFromContainer(container: AbstractScene): void;
  11560. /**
  11561. * Serializes the component data to the specified json object
  11562. * @param serializationObject The object to serialize to
  11563. */
  11564. serialize(serializationObject: any): void;
  11565. }
  11566. /**
  11567. * Strong typing of a Mesh related stage step action
  11568. */
  11569. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11570. /**
  11571. * Strong typing of a Evaluate Sub Mesh related stage step action
  11572. */
  11573. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11574. /**
  11575. * Strong typing of a Active Mesh related stage step action
  11576. */
  11577. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11578. /**
  11579. * Strong typing of a Camera related stage step action
  11580. */
  11581. export type CameraStageAction = (camera: Camera) => void;
  11582. /**
  11583. * Strong typing of a Render Target related stage step action
  11584. */
  11585. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11586. /**
  11587. * Strong typing of a RenderingGroup related stage step action
  11588. */
  11589. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11590. /**
  11591. * Strong typing of a Mesh Render related stage step action
  11592. */
  11593. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11594. /**
  11595. * Strong typing of a simple stage step action
  11596. */
  11597. export type SimpleStageAction = () => void;
  11598. /**
  11599. * Strong typing of a render target action.
  11600. */
  11601. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11602. /**
  11603. * Strong typing of a pointer move action.
  11604. */
  11605. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11606. /**
  11607. * Strong typing of a pointer up/down action.
  11608. */
  11609. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11610. /**
  11611. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11612. * @hidden
  11613. */
  11614. export class Stage<T extends Function> extends Array<{
  11615. index: number;
  11616. component: ISceneComponent;
  11617. action: T;
  11618. }> {
  11619. /**
  11620. * Hide ctor from the rest of the world.
  11621. * @param items The items to add.
  11622. */
  11623. private constructor();
  11624. /**
  11625. * Creates a new Stage.
  11626. * @returns A new instance of a Stage
  11627. */
  11628. static Create<T extends Function>(): Stage<T>;
  11629. /**
  11630. * Registers a step in an ordered way in the targeted stage.
  11631. * @param index Defines the position to register the step in
  11632. * @param component Defines the component attached to the step
  11633. * @param action Defines the action to launch during the step
  11634. */
  11635. registerStep(index: number, component: ISceneComponent, action: T): void;
  11636. /**
  11637. * Clears all the steps from the stage.
  11638. */
  11639. clear(): void;
  11640. }
  11641. }
  11642. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11643. import { Nullable } from "babylonjs/types";
  11644. import { Observable } from "babylonjs/Misc/observable";
  11645. import { Scene } from "babylonjs/scene";
  11646. import { Sprite } from "babylonjs/Sprites/sprite";
  11647. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. import { Camera } from "babylonjs/Cameras/camera";
  11650. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11651. import { ISceneComponent } from "babylonjs/sceneComponent";
  11652. module "babylonjs/scene" {
  11653. interface Scene {
  11654. /** @hidden */
  11655. _pointerOverSprite: Nullable<Sprite>;
  11656. /** @hidden */
  11657. _pickedDownSprite: Nullable<Sprite>;
  11658. /** @hidden */
  11659. _tempSpritePickingRay: Nullable<Ray>;
  11660. /**
  11661. * All of the sprite managers added to this scene
  11662. * @see http://doc.babylonjs.com/babylon101/sprites
  11663. */
  11664. spriteManagers: Array<ISpriteManager>;
  11665. /**
  11666. * An event triggered when sprites rendering is about to start
  11667. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11668. */
  11669. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11670. /**
  11671. * An event triggered when sprites rendering is done
  11672. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11673. */
  11674. onAfterSpritesRenderingObservable: Observable<Scene>;
  11675. /** @hidden */
  11676. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11677. /** Launch a ray to try to pick a sprite in the scene
  11678. * @param x position on screen
  11679. * @param y position on screen
  11680. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11682. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11683. * @returns a PickingInfo
  11684. */
  11685. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11686. /** Use the given ray to pick a sprite in the scene
  11687. * @param ray The ray (in world space) to use to pick meshes
  11688. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11689. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11690. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11691. * @returns a PickingInfo
  11692. */
  11693. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11694. /**
  11695. * Force the sprite under the pointer
  11696. * @param sprite defines the sprite to use
  11697. */
  11698. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11699. /**
  11700. * Gets the sprite under the pointer
  11701. * @returns a Sprite or null if no sprite is under the pointer
  11702. */
  11703. getPointerOverSprite(): Nullable<Sprite>;
  11704. }
  11705. }
  11706. /**
  11707. * Defines the sprite scene component responsible to manage sprites
  11708. * in a given scene.
  11709. */
  11710. export class SpriteSceneComponent implements ISceneComponent {
  11711. /**
  11712. * The component name helpfull to identify the component in the list of scene components.
  11713. */
  11714. readonly name: string;
  11715. /**
  11716. * The scene the component belongs to.
  11717. */
  11718. scene: Scene;
  11719. /** @hidden */
  11720. private _spritePredicate;
  11721. /**
  11722. * Creates a new instance of the component for the given scene
  11723. * @param scene Defines the scene to register the component in
  11724. */
  11725. constructor(scene: Scene);
  11726. /**
  11727. * Registers the component in a given scene
  11728. */
  11729. register(): void;
  11730. /**
  11731. * Rebuilds the elements related to this component in case of
  11732. * context lost for instance.
  11733. */
  11734. rebuild(): void;
  11735. /**
  11736. * Disposes the component and the associated ressources.
  11737. */
  11738. dispose(): void;
  11739. private _pickSpriteButKeepRay;
  11740. private _pointerMove;
  11741. private _pointerDown;
  11742. private _pointerUp;
  11743. }
  11744. }
  11745. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11746. /** @hidden */
  11747. export var fogFragmentDeclaration: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11753. /** @hidden */
  11754. export var fogFragment: {
  11755. name: string;
  11756. shader: string;
  11757. };
  11758. }
  11759. declare module "babylonjs/Shaders/sprites.fragment" {
  11760. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11761. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11762. /** @hidden */
  11763. export var spritesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11769. /** @hidden */
  11770. export var fogVertexDeclaration: {
  11771. name: string;
  11772. shader: string;
  11773. };
  11774. }
  11775. declare module "babylonjs/Shaders/sprites.vertex" {
  11776. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11777. /** @hidden */
  11778. export var spritesVertexShader: {
  11779. name: string;
  11780. shader: string;
  11781. };
  11782. }
  11783. declare module "babylonjs/Sprites/spriteManager" {
  11784. import { IDisposable, Scene } from "babylonjs/scene";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { Observable } from "babylonjs/Misc/observable";
  11787. import { Sprite } from "babylonjs/Sprites/sprite";
  11788. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11789. import { Camera } from "babylonjs/Cameras/camera";
  11790. import { Texture } from "babylonjs/Materials/Textures/texture";
  11791. import "babylonjs/Shaders/sprites.fragment";
  11792. import "babylonjs/Shaders/sprites.vertex";
  11793. import { Ray } from "babylonjs/Culling/ray";
  11794. /**
  11795. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11796. */
  11797. export interface ISpriteManager extends IDisposable {
  11798. /**
  11799. * Restricts the camera to viewing objects with the same layerMask.
  11800. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11801. */
  11802. layerMask: number;
  11803. /**
  11804. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11805. */
  11806. isPickable: boolean;
  11807. /**
  11808. * Specifies the rendering group id for this mesh (0 by default)
  11809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11810. */
  11811. renderingGroupId: number;
  11812. /**
  11813. * Defines the list of sprites managed by the manager.
  11814. */
  11815. sprites: Array<Sprite>;
  11816. /**
  11817. * Tests the intersection of a sprite with a specific ray.
  11818. * @param ray The ray we are sending to test the collision
  11819. * @param camera The camera space we are sending rays in
  11820. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11821. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11822. * @returns picking info or null.
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Renders the list of sprites on screen.
  11827. */
  11828. render(): void;
  11829. }
  11830. /**
  11831. * Class used to manage multiple sprites on the same spritesheet
  11832. * @see http://doc.babylonjs.com/babylon101/sprites
  11833. */
  11834. export class SpriteManager implements ISpriteManager {
  11835. /** defines the manager's name */
  11836. name: string;
  11837. /** Gets the list of sprites */
  11838. sprites: Sprite[];
  11839. /** Gets or sets the rendering group id (0 by default) */
  11840. renderingGroupId: number;
  11841. /** Gets or sets camera layer mask */
  11842. layerMask: number;
  11843. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11844. fogEnabled: boolean;
  11845. /** Gets or sets a boolean indicating if the sprites are pickable */
  11846. isPickable: boolean;
  11847. /** Defines the default width of a cell in the spritesheet */
  11848. cellWidth: number;
  11849. /** Defines the default height of a cell in the spritesheet */
  11850. cellHeight: number;
  11851. /**
  11852. * An event triggered when the manager is disposed.
  11853. */
  11854. onDisposeObservable: Observable<SpriteManager>;
  11855. private _onDisposeObserver;
  11856. /**
  11857. * Callback called when the manager is disposed
  11858. */
  11859. onDispose: () => void;
  11860. private _capacity;
  11861. private _spriteTexture;
  11862. private _epsilon;
  11863. private _scene;
  11864. private _vertexData;
  11865. private _buffer;
  11866. private _vertexBuffers;
  11867. private _indexBuffer;
  11868. private _effectBase;
  11869. private _effectFog;
  11870. /**
  11871. * Gets or sets the spritesheet texture
  11872. */
  11873. texture: Texture;
  11874. /**
  11875. * Creates a new sprite manager
  11876. * @param name defines the manager's name
  11877. * @param imgUrl defines the sprite sheet url
  11878. * @param capacity defines the maximum allowed number of sprites
  11879. * @param cellSize defines the size of a sprite cell
  11880. * @param scene defines the hosting scene
  11881. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11882. * @param samplingMode defines the smapling mode to use with spritesheet
  11883. */
  11884. constructor(
  11885. /** defines the manager's name */
  11886. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11887. private _appendSpriteVertex;
  11888. /**
  11889. * Intersects the sprites with a ray
  11890. * @param ray defines the ray to intersect with
  11891. * @param camera defines the current active camera
  11892. * @param predicate defines a predicate used to select candidate sprites
  11893. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11894. * @returns null if no hit or a PickingInfo
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Render all child sprites
  11899. */
  11900. render(): void;
  11901. /**
  11902. * Release associated resources
  11903. */
  11904. dispose(): void;
  11905. }
  11906. }
  11907. declare module "babylonjs/Sprites/sprite" {
  11908. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11909. import { Nullable } from "babylonjs/types";
  11910. import { ActionManager } from "babylonjs/Actions/actionManager";
  11911. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11912. /**
  11913. * Class used to represent a sprite
  11914. * @see http://doc.babylonjs.com/babylon101/sprites
  11915. */
  11916. export class Sprite {
  11917. /** defines the name */
  11918. name: string;
  11919. /** Gets or sets the current world position */
  11920. position: Vector3;
  11921. /** Gets or sets the main color */
  11922. color: Color4;
  11923. /** Gets or sets the width */
  11924. width: number;
  11925. /** Gets or sets the height */
  11926. height: number;
  11927. /** Gets or sets rotation angle */
  11928. angle: number;
  11929. /** Gets or sets the cell index in the sprite sheet */
  11930. cellIndex: number;
  11931. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11932. invertU: number;
  11933. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11934. invertV: number;
  11935. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11936. disposeWhenFinishedAnimating: boolean;
  11937. /** Gets the list of attached animations */
  11938. animations: Animation[];
  11939. /** Gets or sets a boolean indicating if the sprite can be picked */
  11940. isPickable: boolean;
  11941. /**
  11942. * Gets or sets the associated action manager
  11943. */
  11944. actionManager: Nullable<ActionManager>;
  11945. private _animationStarted;
  11946. private _loopAnimation;
  11947. private _fromIndex;
  11948. private _toIndex;
  11949. private _delay;
  11950. private _direction;
  11951. private _manager;
  11952. private _time;
  11953. private _onAnimationEnd;
  11954. /**
  11955. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11956. */
  11957. isVisible: boolean;
  11958. /**
  11959. * Gets or sets the sprite size
  11960. */
  11961. size: number;
  11962. /**
  11963. * Creates a new Sprite
  11964. * @param name defines the name
  11965. * @param manager defines the manager
  11966. */
  11967. constructor(
  11968. /** defines the name */
  11969. name: string, manager: ISpriteManager);
  11970. /**
  11971. * Starts an animation
  11972. * @param from defines the initial key
  11973. * @param to defines the end key
  11974. * @param loop defines if the animation must loop
  11975. * @param delay defines the start delay (in ms)
  11976. * @param onAnimationEnd defines a callback to call when animation ends
  11977. */
  11978. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11979. /** Stops current animation (if any) */
  11980. stopAnimation(): void;
  11981. /** @hidden */
  11982. _animate(deltaTime: number): void;
  11983. /** Release associated resources */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module "babylonjs/Collisions/pickingInfo" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11991. import { Sprite } from "babylonjs/Sprites/sprite";
  11992. import { Ray } from "babylonjs/Culling/ray";
  11993. /**
  11994. * Information about the result of picking within a scene
  11995. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11996. */
  11997. export class PickingInfo {
  11998. /** @hidden */
  11999. _pickingUnavailable: boolean;
  12000. /**
  12001. * If the pick collided with an object
  12002. */
  12003. hit: boolean;
  12004. /**
  12005. * Distance away where the pick collided
  12006. */
  12007. distance: number;
  12008. /**
  12009. * The location of pick collision
  12010. */
  12011. pickedPoint: Nullable<Vector3>;
  12012. /**
  12013. * The mesh corresponding the the pick collision
  12014. */
  12015. pickedMesh: Nullable<AbstractMesh>;
  12016. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12017. bu: number;
  12018. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12019. bv: number;
  12020. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12021. faceId: number;
  12022. /** Id of the the submesh that was picked */
  12023. subMeshId: number;
  12024. /** If a sprite was picked, this will be the sprite the pick collided with */
  12025. pickedSprite: Nullable<Sprite>;
  12026. /**
  12027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12028. */
  12029. originMesh: Nullable<AbstractMesh>;
  12030. /**
  12031. * The ray that was used to perform the picking.
  12032. */
  12033. ray: Nullable<Ray>;
  12034. /**
  12035. * Gets the normal correspodning to the face the pick collided with
  12036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12038. * @returns The normal correspodning to the face the pick collided with
  12039. */
  12040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12041. /**
  12042. * Gets the texture coordinates of where the pick occured
  12043. * @returns the vector containing the coordnates of the texture
  12044. */
  12045. getTextureCoordinates(): Nullable<Vector2>;
  12046. }
  12047. }
  12048. declare module "babylonjs/Events/pointerEvents" {
  12049. import { Nullable } from "babylonjs/types";
  12050. import { Vector2 } from "babylonjs/Maths/math";
  12051. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12052. import { Ray } from "babylonjs/Culling/ray";
  12053. /**
  12054. * Gather the list of pointer event types as constants.
  12055. */
  12056. export class PointerEventTypes {
  12057. /**
  12058. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12059. */
  12060. static readonly POINTERDOWN: number;
  12061. /**
  12062. * The pointerup event is fired when a pointer is no longer active.
  12063. */
  12064. static readonly POINTERUP: number;
  12065. /**
  12066. * The pointermove event is fired when a pointer changes coordinates.
  12067. */
  12068. static readonly POINTERMOVE: number;
  12069. /**
  12070. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12071. */
  12072. static readonly POINTERWHEEL: number;
  12073. /**
  12074. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12075. */
  12076. static readonly POINTERPICK: number;
  12077. /**
  12078. * The pointertap event is fired when a the object has been touched and released without drag.
  12079. */
  12080. static readonly POINTERTAP: number;
  12081. /**
  12082. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12083. */
  12084. static readonly POINTERDOUBLETAP: number;
  12085. }
  12086. /**
  12087. * Base class of pointer info types.
  12088. */
  12089. export class PointerInfoBase {
  12090. /**
  12091. * Defines the type of event (PointerEventTypes)
  12092. */
  12093. type: number;
  12094. /**
  12095. * Defines the related dom event
  12096. */
  12097. event: PointerEvent | MouseWheelEvent;
  12098. /**
  12099. * Instantiates the base class of pointers info.
  12100. * @param type Defines the type of event (PointerEventTypes)
  12101. * @param event Defines the related dom event
  12102. */
  12103. constructor(
  12104. /**
  12105. * Defines the type of event (PointerEventTypes)
  12106. */
  12107. type: number,
  12108. /**
  12109. * Defines the related dom event
  12110. */
  12111. event: PointerEvent | MouseWheelEvent);
  12112. }
  12113. /**
  12114. * This class is used to store pointer related info for the onPrePointerObservable event.
  12115. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12116. */
  12117. export class PointerInfoPre extends PointerInfoBase {
  12118. /**
  12119. * Ray from a pointer if availible (eg. 6dof controller)
  12120. */
  12121. ray: Nullable<Ray>;
  12122. /**
  12123. * Defines the local position of the pointer on the canvas.
  12124. */
  12125. localPosition: Vector2;
  12126. /**
  12127. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12128. */
  12129. skipOnPointerObservable: boolean;
  12130. /**
  12131. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12132. * @param type Defines the type of event (PointerEventTypes)
  12133. * @param event Defines the related dom event
  12134. * @param localX Defines the local x coordinates of the pointer when the event occured
  12135. * @param localY Defines the local y coordinates of the pointer when the event occured
  12136. */
  12137. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12138. }
  12139. /**
  12140. * This type contains all the data related to a pointer event in Babylon.js.
  12141. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12142. */
  12143. export class PointerInfo extends PointerInfoBase {
  12144. /**
  12145. * Defines the picking info associated to the info (if any)\
  12146. */
  12147. pickInfo: Nullable<PickingInfo>;
  12148. /**
  12149. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12150. * @param type Defines the type of event (PointerEventTypes)
  12151. * @param event Defines the related dom event
  12152. * @param pickInfo Defines the picking info associated to the info (if any)\
  12153. */
  12154. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12155. /**
  12156. * Defines the picking info associated to the info (if any)\
  12157. */
  12158. pickInfo: Nullable<PickingInfo>);
  12159. }
  12160. /**
  12161. * Data relating to a touch event on the screen.
  12162. */
  12163. export interface PointerTouch {
  12164. /**
  12165. * X coordinate of touch.
  12166. */
  12167. x: number;
  12168. /**
  12169. * Y coordinate of touch.
  12170. */
  12171. y: number;
  12172. /**
  12173. * Id of touch. Unique for each finger.
  12174. */
  12175. pointerId: number;
  12176. /**
  12177. * Event type passed from DOM.
  12178. */
  12179. type: any;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12183. import { Nullable } from "babylonjs/types";
  12184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12186. /**
  12187. * Manage the mouse inputs to control the movement of a free camera.
  12188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12189. */
  12190. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12191. /**
  12192. * Define if touch is enabled in the mouse input
  12193. */
  12194. touchEnabled: boolean;
  12195. /**
  12196. * Defines the camera the input is attached to.
  12197. */
  12198. camera: FreeCamera;
  12199. /**
  12200. * Defines the buttons associated with the input to handle camera move.
  12201. */
  12202. buttons: number[];
  12203. /**
  12204. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12205. */
  12206. angularSensibility: number;
  12207. private _pointerInput;
  12208. private _onMouseMove;
  12209. private _observer;
  12210. private previousPosition;
  12211. /**
  12212. * Manage the mouse inputs to control the movement of a free camera.
  12213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12214. * @param touchEnabled Defines if touch is enabled or not
  12215. */
  12216. constructor(
  12217. /**
  12218. * Define if touch is enabled in the mouse input
  12219. */
  12220. touchEnabled?: boolean);
  12221. /**
  12222. * Attach the input controls to a specific dom element to get the input from.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Called on JS contextmenu event.
  12229. * Override this method to provide functionality.
  12230. */
  12231. protected onContextMenu(evt: PointerEvent): void;
  12232. /**
  12233. * Detach the current controls from the specified dom element.
  12234. * @param element Defines the element to stop listening the inputs from
  12235. */
  12236. detachControl(element: Nullable<HTMLElement>): void;
  12237. /**
  12238. * Gets the class name of the current intput.
  12239. * @returns the class name
  12240. */
  12241. getClassName(): string;
  12242. /**
  12243. * Get the friendly name associated with the input class.
  12244. * @returns the input friendly name
  12245. */
  12246. getSimpleName(): string;
  12247. }
  12248. }
  12249. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12250. import { Nullable } from "babylonjs/types";
  12251. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12253. /**
  12254. * Manage the touch inputs to control the movement of a free camera.
  12255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12256. */
  12257. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12258. /**
  12259. * Defines the camera the input is attached to.
  12260. */
  12261. camera: FreeCamera;
  12262. /**
  12263. * Defines the touch sensibility for rotation.
  12264. * The higher the faster.
  12265. */
  12266. touchAngularSensibility: number;
  12267. /**
  12268. * Defines the touch sensibility for move.
  12269. * The higher the faster.
  12270. */
  12271. touchMoveSensibility: number;
  12272. private _offsetX;
  12273. private _offsetY;
  12274. private _pointerPressed;
  12275. private _pointerInput;
  12276. private _observer;
  12277. private _onLostFocus;
  12278. /**
  12279. * Attach the input controls to a specific dom element to get the input from.
  12280. * @param element Defines the element the controls should be listened from
  12281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12282. */
  12283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12284. /**
  12285. * Detach the current controls from the specified dom element.
  12286. * @param element Defines the element to stop listening the inputs from
  12287. */
  12288. detachControl(element: Nullable<HTMLElement>): void;
  12289. /**
  12290. * Update the current camera state depending on the inputs that have been used this frame.
  12291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12292. */
  12293. checkInputs(): void;
  12294. /**
  12295. * Gets the class name of the current intput.
  12296. * @returns the class name
  12297. */
  12298. getClassName(): string;
  12299. /**
  12300. * Get the friendly name associated with the input class.
  12301. * @returns the input friendly name
  12302. */
  12303. getSimpleName(): string;
  12304. }
  12305. }
  12306. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12307. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12308. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12309. /**
  12310. * Default Inputs manager for the FreeCamera.
  12311. * It groups all the default supported inputs for ease of use.
  12312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12313. */
  12314. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12315. /**
  12316. * Instantiates a new FreeCameraInputsManager.
  12317. * @param camera Defines the camera the inputs belong to
  12318. */
  12319. constructor(camera: FreeCamera);
  12320. /**
  12321. * Add keyboard input support to the input manager.
  12322. * @returns the current input manager
  12323. */
  12324. addKeyboard(): FreeCameraInputsManager;
  12325. /**
  12326. * Add mouse input support to the input manager.
  12327. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12328. * @returns the current input manager
  12329. */
  12330. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12331. /**
  12332. * Add touch input support to the input manager.
  12333. * @returns the current input manager
  12334. */
  12335. addTouch(): FreeCameraInputsManager;
  12336. }
  12337. }
  12338. declare module "babylonjs/Cameras/freeCamera" {
  12339. import { Vector3 } from "babylonjs/Maths/math";
  12340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12341. import { Scene } from "babylonjs/scene";
  12342. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12343. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12344. /**
  12345. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12346. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12348. */
  12349. export class FreeCamera extends TargetCamera {
  12350. /**
  12351. * Define the collision ellipsoid of the camera.
  12352. * This is helpful to simulate a camera body like the player body around the camera
  12353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12354. */
  12355. ellipsoid: Vector3;
  12356. /**
  12357. * Define an offset for the position of the ellipsoid around the camera.
  12358. * This can be helpful to determine the center of the body near the gravity center of the body
  12359. * instead of its head.
  12360. */
  12361. ellipsoidOffset: Vector3;
  12362. /**
  12363. * Enable or disable collisions of the camera with the rest of the scene objects.
  12364. */
  12365. checkCollisions: boolean;
  12366. /**
  12367. * Enable or disable gravity on the camera.
  12368. */
  12369. applyGravity: boolean;
  12370. /**
  12371. * Define the input manager associated to the camera.
  12372. */
  12373. inputs: FreeCameraInputsManager;
  12374. /**
  12375. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12376. * Higher values reduce sensitivity.
  12377. */
  12378. /**
  12379. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12380. * Higher values reduce sensitivity.
  12381. */
  12382. angularSensibility: number;
  12383. /**
  12384. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12385. */
  12386. keysUp: number[];
  12387. /**
  12388. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12389. */
  12390. keysDown: number[];
  12391. /**
  12392. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12393. */
  12394. keysLeft: number[];
  12395. /**
  12396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12397. */
  12398. keysRight: number[];
  12399. /**
  12400. * Event raised when the camera collide with a mesh in the scene.
  12401. */
  12402. onCollide: (collidedMesh: AbstractMesh) => void;
  12403. private _collider;
  12404. private _needMoveForGravity;
  12405. private _oldPosition;
  12406. private _diffPosition;
  12407. private _newPosition;
  12408. /** @hidden */
  12409. _localDirection: Vector3;
  12410. /** @hidden */
  12411. _transformedDirection: Vector3;
  12412. /**
  12413. * Instantiates a Free Camera.
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. * @param name Define the name of the camera in the scene
  12418. * @param position Define the start position of the camera in the scene
  12419. * @param scene Define the scene the camera belongs to
  12420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12421. */
  12422. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12423. /**
  12424. * Attached controls to the current camera.
  12425. * @param element Defines the element the controls should be listened from
  12426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12427. */
  12428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12429. /**
  12430. * Detach the current controls from the camera.
  12431. * The camera will stop reacting to inputs.
  12432. * @param element Defines the element to stop listening the inputs from
  12433. */
  12434. detachControl(element: HTMLElement): void;
  12435. private _collisionMask;
  12436. /**
  12437. * Define a collision mask to limit the list of object the camera can collide with
  12438. */
  12439. collisionMask: number;
  12440. /** @hidden */
  12441. _collideWithWorld(displacement: Vector3): void;
  12442. private _onCollisionPositionChange;
  12443. /** @hidden */
  12444. _checkInputs(): void;
  12445. /** @hidden */
  12446. _decideIfNeedsToMove(): boolean;
  12447. /** @hidden */
  12448. _updatePosition(): void;
  12449. /**
  12450. * Destroy the camera and release the current resources hold by it.
  12451. */
  12452. dispose(): void;
  12453. /**
  12454. * Gets the current object class name.
  12455. * @return the class name
  12456. */
  12457. getClassName(): string;
  12458. }
  12459. }
  12460. declare module "babylonjs/Gamepads/gamepad" {
  12461. import { Observable } from "babylonjs/Misc/observable";
  12462. /**
  12463. * Represents a gamepad control stick position
  12464. */
  12465. export class StickValues {
  12466. /**
  12467. * The x component of the control stick
  12468. */
  12469. x: number;
  12470. /**
  12471. * The y component of the control stick
  12472. */
  12473. y: number;
  12474. /**
  12475. * Initializes the gamepad x and y control stick values
  12476. * @param x The x component of the gamepad control stick value
  12477. * @param y The y component of the gamepad control stick value
  12478. */
  12479. constructor(
  12480. /**
  12481. * The x component of the control stick
  12482. */
  12483. x: number,
  12484. /**
  12485. * The y component of the control stick
  12486. */
  12487. y: number);
  12488. }
  12489. /**
  12490. * An interface which manages callbacks for gamepad button changes
  12491. */
  12492. export interface GamepadButtonChanges {
  12493. /**
  12494. * Called when a gamepad has been changed
  12495. */
  12496. changed: boolean;
  12497. /**
  12498. * Called when a gamepad press event has been triggered
  12499. */
  12500. pressChanged: boolean;
  12501. /**
  12502. * Called when a touch event has been triggered
  12503. */
  12504. touchChanged: boolean;
  12505. /**
  12506. * Called when a value has changed
  12507. */
  12508. valueChanged: boolean;
  12509. }
  12510. /**
  12511. * Represents a gamepad
  12512. */
  12513. export class Gamepad {
  12514. /**
  12515. * The id of the gamepad
  12516. */
  12517. id: string;
  12518. /**
  12519. * The index of the gamepad
  12520. */
  12521. index: number;
  12522. /**
  12523. * The browser gamepad
  12524. */
  12525. browserGamepad: any;
  12526. /**
  12527. * Specifies what type of gamepad this represents
  12528. */
  12529. type: number;
  12530. private _leftStick;
  12531. private _rightStick;
  12532. /** @hidden */
  12533. _isConnected: boolean;
  12534. private _leftStickAxisX;
  12535. private _leftStickAxisY;
  12536. private _rightStickAxisX;
  12537. private _rightStickAxisY;
  12538. /**
  12539. * Triggered when the left control stick has been changed
  12540. */
  12541. private _onleftstickchanged;
  12542. /**
  12543. * Triggered when the right control stick has been changed
  12544. */
  12545. private _onrightstickchanged;
  12546. /**
  12547. * Represents a gamepad controller
  12548. */
  12549. static GAMEPAD: number;
  12550. /**
  12551. * Represents a generic controller
  12552. */
  12553. static GENERIC: number;
  12554. /**
  12555. * Represents an XBox controller
  12556. */
  12557. static XBOX: number;
  12558. /**
  12559. * Represents a pose-enabled controller
  12560. */
  12561. static POSE_ENABLED: number;
  12562. /**
  12563. * Specifies whether the left control stick should be Y-inverted
  12564. */
  12565. protected _invertLeftStickY: boolean;
  12566. /**
  12567. * Specifies if the gamepad has been connected
  12568. */
  12569. readonly isConnected: boolean;
  12570. /**
  12571. * Initializes the gamepad
  12572. * @param id The id of the gamepad
  12573. * @param index The index of the gamepad
  12574. * @param browserGamepad The browser gamepad
  12575. * @param leftStickX The x component of the left joystick
  12576. * @param leftStickY The y component of the left joystick
  12577. * @param rightStickX The x component of the right joystick
  12578. * @param rightStickY The y component of the right joystick
  12579. */
  12580. constructor(
  12581. /**
  12582. * The id of the gamepad
  12583. */
  12584. id: string,
  12585. /**
  12586. * The index of the gamepad
  12587. */
  12588. index: number,
  12589. /**
  12590. * The browser gamepad
  12591. */
  12592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12593. /**
  12594. * Callback triggered when the left joystick has changed
  12595. * @param callback
  12596. */
  12597. onleftstickchanged(callback: (values: StickValues) => void): void;
  12598. /**
  12599. * Callback triggered when the right joystick has changed
  12600. * @param callback
  12601. */
  12602. onrightstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Gets the left joystick
  12605. */
  12606. /**
  12607. * Sets the left joystick values
  12608. */
  12609. leftStick: StickValues;
  12610. /**
  12611. * Gets the right joystick
  12612. */
  12613. /**
  12614. * Sets the right joystick value
  12615. */
  12616. rightStick: StickValues;
  12617. /**
  12618. * Updates the gamepad joystick positions
  12619. */
  12620. update(): void;
  12621. /**
  12622. * Disposes the gamepad
  12623. */
  12624. dispose(): void;
  12625. }
  12626. /**
  12627. * Represents a generic gamepad
  12628. */
  12629. export class GenericPad extends Gamepad {
  12630. private _buttons;
  12631. private _onbuttondown;
  12632. private _onbuttonup;
  12633. /**
  12634. * Observable triggered when a button has been pressed
  12635. */
  12636. onButtonDownObservable: Observable<number>;
  12637. /**
  12638. * Observable triggered when a button has been released
  12639. */
  12640. onButtonUpObservable: Observable<number>;
  12641. /**
  12642. * Callback triggered when a button has been pressed
  12643. * @param callback Called when a button has been pressed
  12644. */
  12645. onbuttondown(callback: (buttonPressed: number) => void): void;
  12646. /**
  12647. * Callback triggered when a button has been released
  12648. * @param callback Called when a button has been released
  12649. */
  12650. onbuttonup(callback: (buttonReleased: number) => void): void;
  12651. /**
  12652. * Initializes the generic gamepad
  12653. * @param id The id of the generic gamepad
  12654. * @param index The index of the generic gamepad
  12655. * @param browserGamepad The browser gamepad
  12656. */
  12657. constructor(id: string, index: number, browserGamepad: any);
  12658. private _setButtonValue;
  12659. /**
  12660. * Updates the generic gamepad
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the generic gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. }
  12669. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12670. import { Observable } from "babylonjs/Misc/observable";
  12671. import { Nullable } from "babylonjs/types";
  12672. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12673. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12675. import { Ray } from "babylonjs/Culling/ray";
  12676. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12677. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12678. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12679. /**
  12680. * Defines the types of pose enabled controllers that are supported
  12681. */
  12682. export enum PoseEnabledControllerType {
  12683. /**
  12684. * HTC Vive
  12685. */
  12686. VIVE = 0,
  12687. /**
  12688. * Oculus Rift
  12689. */
  12690. OCULUS = 1,
  12691. /**
  12692. * Windows mixed reality
  12693. */
  12694. WINDOWS = 2,
  12695. /**
  12696. * Samsung gear VR
  12697. */
  12698. GEAR_VR = 3,
  12699. /**
  12700. * Google Daydream
  12701. */
  12702. DAYDREAM = 4,
  12703. /**
  12704. * Generic
  12705. */
  12706. GENERIC = 5
  12707. }
  12708. /**
  12709. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12710. */
  12711. export interface MutableGamepadButton {
  12712. /**
  12713. * Value of the button/trigger
  12714. */
  12715. value: number;
  12716. /**
  12717. * If the button/trigger is currently touched
  12718. */
  12719. touched: boolean;
  12720. /**
  12721. * If the button/trigger is currently pressed
  12722. */
  12723. pressed: boolean;
  12724. }
  12725. /**
  12726. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12727. * @hidden
  12728. */
  12729. export interface ExtendedGamepadButton extends GamepadButton {
  12730. /**
  12731. * If the button/trigger is currently pressed
  12732. */
  12733. readonly pressed: boolean;
  12734. /**
  12735. * If the button/trigger is currently touched
  12736. */
  12737. readonly touched: boolean;
  12738. /**
  12739. * Value of the button/trigger
  12740. */
  12741. readonly value: number;
  12742. }
  12743. /** @hidden */
  12744. export interface _GamePadFactory {
  12745. /**
  12746. * Returns wether or not the current gamepad can be created for this type of controller.
  12747. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12748. * @returns true if it can be created, otherwise false
  12749. */
  12750. canCreate(gamepadInfo: any): boolean;
  12751. /**
  12752. * Creates a new instance of the Gamepad.
  12753. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12754. * @returns the new gamepad instance
  12755. */
  12756. create(gamepadInfo: any): Gamepad;
  12757. }
  12758. /**
  12759. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12760. */
  12761. export class PoseEnabledControllerHelper {
  12762. /** @hidden */
  12763. static _ControllerFactories: _GamePadFactory[];
  12764. /** @hidden */
  12765. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12766. /**
  12767. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12768. * @param vrGamepad the gamepad to initialized
  12769. * @returns a vr controller of the type the gamepad identified as
  12770. */
  12771. static InitiateController(vrGamepad: any): Gamepad;
  12772. }
  12773. /**
  12774. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12775. */
  12776. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12777. private _deviceRoomPosition;
  12778. private _deviceRoomRotationQuaternion;
  12779. /**
  12780. * The device position in babylon space
  12781. */
  12782. devicePosition: Vector3;
  12783. /**
  12784. * The device rotation in babylon space
  12785. */
  12786. deviceRotationQuaternion: Quaternion;
  12787. /**
  12788. * The scale factor of the device in babylon space
  12789. */
  12790. deviceScaleFactor: number;
  12791. /**
  12792. * (Likely devicePosition should be used instead) The device position in its room space
  12793. */
  12794. position: Vector3;
  12795. /**
  12796. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12797. */
  12798. rotationQuaternion: Quaternion;
  12799. /**
  12800. * The type of controller (Eg. Windows mixed reality)
  12801. */
  12802. controllerType: PoseEnabledControllerType;
  12803. protected _calculatedPosition: Vector3;
  12804. private _calculatedRotation;
  12805. /**
  12806. * The raw pose from the device
  12807. */
  12808. rawPose: DevicePose;
  12809. private _trackPosition;
  12810. private _maxRotationDistFromHeadset;
  12811. private _draggedRoomRotation;
  12812. /**
  12813. * @hidden
  12814. */
  12815. _disableTrackPosition(fixedPosition: Vector3): void;
  12816. /**
  12817. * Internal, the mesh attached to the controller
  12818. * @hidden
  12819. */
  12820. _mesh: Nullable<AbstractMesh>;
  12821. private _poseControlledCamera;
  12822. private _leftHandSystemQuaternion;
  12823. /**
  12824. * Internal, matrix used to convert room space to babylon space
  12825. * @hidden
  12826. */
  12827. _deviceToWorld: Matrix;
  12828. /**
  12829. * Node to be used when casting a ray from the controller
  12830. * @hidden
  12831. */
  12832. _pointingPoseNode: Nullable<TransformNode>;
  12833. /**
  12834. * Name of the child mesh that can be used to cast a ray from the controller
  12835. */
  12836. static readonly POINTING_POSE: string;
  12837. /**
  12838. * Creates a new PoseEnabledController from a gamepad
  12839. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12840. */
  12841. constructor(browserGamepad: any);
  12842. private _workingMatrix;
  12843. /**
  12844. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12845. */
  12846. update(): void;
  12847. /**
  12848. * Updates only the pose device and mesh without doing any button event checking
  12849. */
  12850. protected _updatePoseAndMesh(): void;
  12851. /**
  12852. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12853. * @param poseData raw pose fromthe device
  12854. */
  12855. updateFromDevice(poseData: DevicePose): void;
  12856. /**
  12857. * @hidden
  12858. */
  12859. _meshAttachedObservable: Observable<AbstractMesh>;
  12860. /**
  12861. * Attaches a mesh to the controller
  12862. * @param mesh the mesh to be attached
  12863. */
  12864. attachToMesh(mesh: AbstractMesh): void;
  12865. /**
  12866. * Attaches the controllers mesh to a camera
  12867. * @param camera the camera the mesh should be attached to
  12868. */
  12869. attachToPoseControlledCamera(camera: TargetCamera): void;
  12870. /**
  12871. * Disposes of the controller
  12872. */
  12873. dispose(): void;
  12874. /**
  12875. * The mesh that is attached to the controller
  12876. */
  12877. readonly mesh: Nullable<AbstractMesh>;
  12878. /**
  12879. * Gets the ray of the controller in the direction the controller is pointing
  12880. * @param length the length the resulting ray should be
  12881. * @returns a ray in the direction the controller is pointing
  12882. */
  12883. getForwardRay(length?: number): Ray;
  12884. }
  12885. }
  12886. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12887. import { Observable } from "babylonjs/Misc/observable";
  12888. import { Scene } from "babylonjs/scene";
  12889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12890. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12891. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12892. /**
  12893. * Defines the WebVRController object that represents controllers tracked in 3D space
  12894. */
  12895. export abstract class WebVRController extends PoseEnabledController {
  12896. /**
  12897. * Internal, the default controller model for the controller
  12898. */
  12899. protected _defaultModel: AbstractMesh;
  12900. /**
  12901. * Fired when the trigger state has changed
  12902. */
  12903. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12904. /**
  12905. * Fired when the main button state has changed
  12906. */
  12907. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12908. /**
  12909. * Fired when the secondary button state has changed
  12910. */
  12911. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12912. /**
  12913. * Fired when the pad state has changed
  12914. */
  12915. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12916. /**
  12917. * Fired when controllers stick values have changed
  12918. */
  12919. onPadValuesChangedObservable: Observable<StickValues>;
  12920. /**
  12921. * Array of button availible on the controller
  12922. */
  12923. protected _buttons: Array<MutableGamepadButton>;
  12924. private _onButtonStateChange;
  12925. /**
  12926. * Fired when a controller button's state has changed
  12927. * @param callback the callback containing the button that was modified
  12928. */
  12929. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12930. /**
  12931. * X and Y axis corrisponding to the controllers joystick
  12932. */
  12933. pad: StickValues;
  12934. /**
  12935. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12936. */
  12937. hand: string;
  12938. /**
  12939. * The default controller model for the controller
  12940. */
  12941. readonly defaultModel: AbstractMesh;
  12942. /**
  12943. * Creates a new WebVRController from a gamepad
  12944. * @param vrGamepad the gamepad that the WebVRController should be created from
  12945. */
  12946. constructor(vrGamepad: any);
  12947. /**
  12948. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12949. */
  12950. update(): void;
  12951. /**
  12952. * Function to be called when a button is modified
  12953. */
  12954. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12955. /**
  12956. * Loads a mesh and attaches it to the controller
  12957. * @param scene the scene the mesh should be added to
  12958. * @param meshLoaded callback for when the mesh has been loaded
  12959. */
  12960. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12961. private _setButtonValue;
  12962. private _changes;
  12963. private _checkChanges;
  12964. /**
  12965. * Disposes of th webVRCOntroller
  12966. */
  12967. dispose(): void;
  12968. }
  12969. }
  12970. declare module "babylonjs/Lights/hemisphericLight" {
  12971. import { Nullable } from "babylonjs/types";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12974. import { Effect } from "babylonjs/Materials/effect";
  12975. import { Light } from "babylonjs/Lights/light";
  12976. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12977. /**
  12978. * The HemisphericLight simulates the ambient environment light,
  12979. * so the passed direction is the light reflection direction, not the incoming direction.
  12980. */
  12981. export class HemisphericLight extends Light {
  12982. /**
  12983. * The groundColor is the light in the opposite direction to the one specified during creation.
  12984. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  12985. */
  12986. groundColor: Color3;
  12987. /**
  12988. * The light reflection direction, not the incoming direction.
  12989. */
  12990. direction: Vector3;
  12991. /**
  12992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12994. * The HemisphericLight can't cast shadows.
  12995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12996. * @param name The friendly name of the light
  12997. * @param direction The direction of the light reflection
  12998. * @param scene The scene the light belongs to
  12999. */
  13000. constructor(name: string, direction: Vector3, scene: Scene);
  13001. protected _buildUniformLayout(): void;
  13002. /**
  13003. * Returns the string "HemisphericLight".
  13004. * @return The class name
  13005. */
  13006. getClassName(): string;
  13007. /**
  13008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13009. * Returns the updated direction.
  13010. * @param target The target the direction should point to
  13011. * @return The computed direction
  13012. */
  13013. setDirectionToTarget(target: Vector3): Vector3;
  13014. /**
  13015. * Returns the shadow generator associated to the light.
  13016. * @returns Always null for hemispheric lights because it does not support shadows.
  13017. */
  13018. getShadowGenerator(): Nullable<IShadowGenerator>;
  13019. /**
  13020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13021. * @param effect The effect to update
  13022. * @param lightIndex The index of the light in the effect to update
  13023. * @returns The hemispheric light
  13024. */
  13025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13026. /**
  13027. * Computes the world matrix of the node
  13028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13029. * @param useWasUpdatedFlag defines a reserved property
  13030. * @returns the world matrix
  13031. */
  13032. computeWorldMatrix(): Matrix;
  13033. /**
  13034. * Returns the integer 3.
  13035. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13036. */
  13037. getTypeID(): number;
  13038. /**
  13039. * Prepares the list of defines specific to the light type.
  13040. * @param defines the list of defines
  13041. * @param lightIndex defines the index of the light for the effect
  13042. */
  13043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13044. }
  13045. }
  13046. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13047. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13048. import { Nullable } from "babylonjs/types";
  13049. import { Observable } from "babylonjs/Misc/observable";
  13050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13051. import { Scene } from "babylonjs/scene";
  13052. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13053. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13054. import { Node } from "babylonjs/node";
  13055. import { Ray } from "babylonjs/Culling/ray";
  13056. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13057. /**
  13058. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13059. * IMPORTANT!! The data is right-hand data.
  13060. * @export
  13061. * @interface DevicePose
  13062. */
  13063. export interface DevicePose {
  13064. /**
  13065. * The position of the device, values in array are [x,y,z].
  13066. */
  13067. readonly position: Nullable<Float32Array>;
  13068. /**
  13069. * The linearVelocity of the device, values in array are [x,y,z].
  13070. */
  13071. readonly linearVelocity: Nullable<Float32Array>;
  13072. /**
  13073. * The linearAcceleration of the device, values in array are [x,y,z].
  13074. */
  13075. readonly linearAcceleration: Nullable<Float32Array>;
  13076. /**
  13077. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13078. */
  13079. readonly orientation: Nullable<Float32Array>;
  13080. /**
  13081. * The angularVelocity of the device, values in array are [x,y,z].
  13082. */
  13083. readonly angularVelocity: Nullable<Float32Array>;
  13084. /**
  13085. * The angularAcceleration of the device, values in array are [x,y,z].
  13086. */
  13087. readonly angularAcceleration: Nullable<Float32Array>;
  13088. }
  13089. /**
  13090. * Interface representing a pose controlled object in Babylon.
  13091. * A pose controlled object has both regular pose values as well as pose values
  13092. * from an external device such as a VR head mounted display
  13093. */
  13094. export interface PoseControlled {
  13095. /**
  13096. * The position of the object in babylon space.
  13097. */
  13098. position: Vector3;
  13099. /**
  13100. * The rotation quaternion of the object in babylon space.
  13101. */
  13102. rotationQuaternion: Quaternion;
  13103. /**
  13104. * The position of the device in babylon space.
  13105. */
  13106. devicePosition?: Vector3;
  13107. /**
  13108. * The rotation quaternion of the device in babylon space.
  13109. */
  13110. deviceRotationQuaternion: Quaternion;
  13111. /**
  13112. * The raw pose coming from the device.
  13113. */
  13114. rawPose: Nullable<DevicePose>;
  13115. /**
  13116. * The scale of the device to be used when translating from device space to babylon space.
  13117. */
  13118. deviceScaleFactor: number;
  13119. /**
  13120. * Updates the poseControlled values based on the input device pose.
  13121. * @param poseData the pose data to update the object with
  13122. */
  13123. updateFromDevice(poseData: DevicePose): void;
  13124. }
  13125. /**
  13126. * Set of options to customize the webVRCamera
  13127. */
  13128. export interface WebVROptions {
  13129. /**
  13130. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13131. */
  13132. trackPosition?: boolean;
  13133. /**
  13134. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13135. */
  13136. positionScale?: number;
  13137. /**
  13138. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13139. */
  13140. displayName?: string;
  13141. /**
  13142. * Should the native controller meshes be initialized. (default: true)
  13143. */
  13144. controllerMeshes?: boolean;
  13145. /**
  13146. * Creating a default HemiLight only on controllers. (default: true)
  13147. */
  13148. defaultLightingOnControllers?: boolean;
  13149. /**
  13150. * If you don't want to use the default VR button of the helper. (default: false)
  13151. */
  13152. useCustomVRButton?: boolean;
  13153. /**
  13154. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13155. */
  13156. customVRButton?: HTMLButtonElement;
  13157. /**
  13158. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13159. */
  13160. rayLength?: number;
  13161. /**
  13162. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13163. */
  13164. defaultHeight?: number;
  13165. }
  13166. /**
  13167. * This represents a WebVR camera.
  13168. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13169. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13170. */
  13171. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13172. private webVROptions;
  13173. /**
  13174. * @hidden
  13175. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13176. */
  13177. _vrDevice: any;
  13178. /**
  13179. * The rawPose of the vrDevice.
  13180. */
  13181. rawPose: Nullable<DevicePose>;
  13182. private _onVREnabled;
  13183. private _specsVersion;
  13184. private _attached;
  13185. private _frameData;
  13186. protected _descendants: Array<Node>;
  13187. private _deviceRoomPosition;
  13188. /** @hidden */
  13189. _deviceRoomRotationQuaternion: Quaternion;
  13190. private _standingMatrix;
  13191. /**
  13192. * Represents device position in babylon space.
  13193. */
  13194. devicePosition: Vector3;
  13195. /**
  13196. * Represents device rotation in babylon space.
  13197. */
  13198. deviceRotationQuaternion: Quaternion;
  13199. /**
  13200. * The scale of the device to be used when translating from device space to babylon space.
  13201. */
  13202. deviceScaleFactor: number;
  13203. private _deviceToWorld;
  13204. private _worldToDevice;
  13205. /**
  13206. * References to the webVR controllers for the vrDevice.
  13207. */
  13208. controllers: Array<WebVRController>;
  13209. /**
  13210. * Emits an event when a controller is attached.
  13211. */
  13212. onControllersAttachedObservable: Observable<WebVRController[]>;
  13213. /**
  13214. * Emits an event when a controller's mesh has been loaded;
  13215. */
  13216. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13217. /**
  13218. * Emits an event when the HMD's pose has been updated.
  13219. */
  13220. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13221. private _poseSet;
  13222. /**
  13223. * If the rig cameras be used as parent instead of this camera.
  13224. */
  13225. rigParenting: boolean;
  13226. private _lightOnControllers;
  13227. private _defaultHeight?;
  13228. /**
  13229. * Instantiates a WebVRFreeCamera.
  13230. * @param name The name of the WebVRFreeCamera
  13231. * @param position The starting anchor position for the camera
  13232. * @param scene The scene the camera belongs to
  13233. * @param webVROptions a set of customizable options for the webVRCamera
  13234. */
  13235. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13236. /**
  13237. * Gets the device distance from the ground in meters.
  13238. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  13239. */
  13240. deviceDistanceToRoomGround(): number;
  13241. /**
  13242. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13243. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13244. */
  13245. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13246. /**
  13247. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13248. * @returns A promise with a boolean set to if the standing matrix is supported.
  13249. */
  13250. useStandingMatrixAsync(): Promise<boolean>;
  13251. /**
  13252. * Disposes the camera
  13253. */
  13254. dispose(): void;
  13255. /**
  13256. * Gets a vrController by name.
  13257. * @param name The name of the controller to retreive
  13258. * @returns the controller matching the name specified or null if not found
  13259. */
  13260. getControllerByName(name: string): Nullable<WebVRController>;
  13261. private _leftController;
  13262. /**
  13263. * The controller corrisponding to the users left hand.
  13264. */
  13265. readonly leftController: Nullable<WebVRController>;
  13266. private _rightController;
  13267. /**
  13268. * The controller corrisponding to the users right hand.
  13269. */
  13270. readonly rightController: Nullable<WebVRController>;
  13271. /**
  13272. * Casts a ray forward from the vrCamera's gaze.
  13273. * @param length Length of the ray (default: 100)
  13274. * @returns the ray corrisponding to the gaze
  13275. */
  13276. getForwardRay(length?: number): Ray;
  13277. /**
  13278. * @hidden
  13279. * Updates the camera based on device's frame data
  13280. */
  13281. _checkInputs(): void;
  13282. /**
  13283. * Updates the poseControlled values based on the input device pose.
  13284. * @param poseData Pose coming from the device
  13285. */
  13286. updateFromDevice(poseData: DevicePose): void;
  13287. private _htmlElementAttached;
  13288. private _detachIfAttached;
  13289. /**
  13290. * WebVR's attach control will start broadcasting frames to the device.
  13291. * Note that in certain browsers (chrome for example) this function must be called
  13292. * within a user-interaction callback. Example:
  13293. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13294. *
  13295. * @param element html element to attach the vrDevice to
  13296. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13297. */
  13298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13299. /**
  13300. * Detaches the camera from the html element and disables VR
  13301. *
  13302. * @param element html element to detach from
  13303. */
  13304. detachControl(element: HTMLElement): void;
  13305. /**
  13306. * @returns the name of this class
  13307. */
  13308. getClassName(): string;
  13309. /**
  13310. * Calls resetPose on the vrDisplay
  13311. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13312. */
  13313. resetToCurrentRotation(): void;
  13314. /**
  13315. * @hidden
  13316. * Updates the rig cameras (left and right eye)
  13317. */
  13318. _updateRigCameras(): void;
  13319. private _workingVector;
  13320. private _oneVector;
  13321. private _workingMatrix;
  13322. private updateCacheCalled;
  13323. private _correctPositionIfNotTrackPosition;
  13324. /**
  13325. * @hidden
  13326. * Updates the cached values of the camera
  13327. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13328. */
  13329. _updateCache(ignoreParentClass?: boolean): void;
  13330. /**
  13331. * @hidden
  13332. * Get current device position in babylon world
  13333. */
  13334. _computeDevicePosition(): void;
  13335. /**
  13336. * Updates the current device position and rotation in the babylon world
  13337. */
  13338. update(): void;
  13339. /**
  13340. * @hidden
  13341. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13342. * @returns an identity matrix
  13343. */
  13344. _getViewMatrix(): Matrix;
  13345. private _tmpMatrix;
  13346. /**
  13347. * This function is called by the two RIG cameras.
  13348. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13349. * @hidden
  13350. */
  13351. _getWebVRViewMatrix(): Matrix;
  13352. /** @hidden */
  13353. _getWebVRProjectionMatrix(): Matrix;
  13354. private _onGamepadConnectedObserver;
  13355. private _onGamepadDisconnectedObserver;
  13356. private _updateCacheWhenTrackingDisabledObserver;
  13357. /**
  13358. * Initializes the controllers and their meshes
  13359. */
  13360. initControllers(): void;
  13361. }
  13362. }
  13363. declare module "babylonjs/PostProcesses/postProcess" {
  13364. import { Nullable } from "babylonjs/types";
  13365. import { SmartArray } from "babylonjs/Misc/smartArray";
  13366. import { Observable } from "babylonjs/Misc/observable";
  13367. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13368. import { Camera } from "babylonjs/Cameras/camera";
  13369. import { Effect } from "babylonjs/Materials/effect";
  13370. import "babylonjs/Shaders/postprocess.vertex";
  13371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13372. import { Engine } from "babylonjs/Engines/engine";
  13373. /**
  13374. * Size options for a post process
  13375. */
  13376. export type PostProcessOptions = {
  13377. width: number;
  13378. height: number;
  13379. };
  13380. /**
  13381. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13382. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13383. */
  13384. export class PostProcess {
  13385. /** Name of the PostProcess. */
  13386. name: string;
  13387. /**
  13388. * Gets or sets the unique id of the post process
  13389. */
  13390. uniqueId: number;
  13391. /**
  13392. * Width of the texture to apply the post process on
  13393. */
  13394. width: number;
  13395. /**
  13396. * Height of the texture to apply the post process on
  13397. */
  13398. height: number;
  13399. /**
  13400. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13401. * @hidden
  13402. */
  13403. _outputTexture: Nullable<InternalTexture>;
  13404. /**
  13405. * Sampling mode used by the shader
  13406. * See https://doc.babylonjs.com/classes/3.1/texture
  13407. */
  13408. renderTargetSamplingMode: number;
  13409. /**
  13410. * Clear color to use when screen clearing
  13411. */
  13412. clearColor: Color4;
  13413. /**
  13414. * If the buffer needs to be cleared before applying the post process. (default: true)
  13415. * Should be set to false if shader will overwrite all previous pixels.
  13416. */
  13417. autoClear: boolean;
  13418. /**
  13419. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13420. */
  13421. alphaMode: number;
  13422. /**
  13423. * Sets the setAlphaBlendConstants of the babylon engine
  13424. */
  13425. alphaConstants: Color4;
  13426. /**
  13427. * Animations to be used for the post processing
  13428. */
  13429. animations: import("babylonjs/Animations/animation").Animation[];
  13430. /**
  13431. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13432. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13433. */
  13434. enablePixelPerfectMode: boolean;
  13435. /**
  13436. * Force the postprocess to be applied without taking in account viewport
  13437. */
  13438. forceFullscreenViewport: boolean;
  13439. /**
  13440. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13441. *
  13442. * | Value | Type | Description |
  13443. * | ----- | ----------------------------------- | ----------- |
  13444. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13445. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13446. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13447. *
  13448. */
  13449. scaleMode: number;
  13450. /**
  13451. * Force textures to be a power of two (default: false)
  13452. */
  13453. alwaysForcePOT: boolean;
  13454. private _samples;
  13455. /**
  13456. * Number of sample textures (default: 1)
  13457. */
  13458. samples: number;
  13459. /**
  13460. * Modify the scale of the post process to be the same as the viewport (default: false)
  13461. */
  13462. adaptScaleToCurrentViewport: boolean;
  13463. private _camera;
  13464. private _scene;
  13465. private _engine;
  13466. private _options;
  13467. private _reusable;
  13468. private _textureType;
  13469. /**
  13470. * Smart array of input and output textures for the post process.
  13471. * @hidden
  13472. */
  13473. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13474. /**
  13475. * The index in _textures that corresponds to the output texture.
  13476. * @hidden
  13477. */
  13478. _currentRenderTextureInd: number;
  13479. private _effect;
  13480. private _samplers;
  13481. private _fragmentUrl;
  13482. private _vertexUrl;
  13483. private _parameters;
  13484. private _scaleRatio;
  13485. protected _indexParameters: any;
  13486. private _shareOutputWithPostProcess;
  13487. private _texelSize;
  13488. private _forcedOutputTexture;
  13489. /**
  13490. * Returns the fragment url or shader name used in the post process.
  13491. * @returns the fragment url or name in the shader store.
  13492. */
  13493. getEffectName(): string;
  13494. /**
  13495. * An event triggered when the postprocess is activated.
  13496. */
  13497. onActivateObservable: Observable<Camera>;
  13498. private _onActivateObserver;
  13499. /**
  13500. * A function that is added to the onActivateObservable
  13501. */
  13502. onActivate: Nullable<(camera: Camera) => void>;
  13503. /**
  13504. * An event triggered when the postprocess changes its size.
  13505. */
  13506. onSizeChangedObservable: Observable<PostProcess>;
  13507. private _onSizeChangedObserver;
  13508. /**
  13509. * A function that is added to the onSizeChangedObservable
  13510. */
  13511. onSizeChanged: (postProcess: PostProcess) => void;
  13512. /**
  13513. * An event triggered when the postprocess applies its effect.
  13514. */
  13515. onApplyObservable: Observable<Effect>;
  13516. private _onApplyObserver;
  13517. /**
  13518. * A function that is added to the onApplyObservable
  13519. */
  13520. onApply: (effect: Effect) => void;
  13521. /**
  13522. * An event triggered before rendering the postprocess
  13523. */
  13524. onBeforeRenderObservable: Observable<Effect>;
  13525. private _onBeforeRenderObserver;
  13526. /**
  13527. * A function that is added to the onBeforeRenderObservable
  13528. */
  13529. onBeforeRender: (effect: Effect) => void;
  13530. /**
  13531. * An event triggered after rendering the postprocess
  13532. */
  13533. onAfterRenderObservable: Observable<Effect>;
  13534. private _onAfterRenderObserver;
  13535. /**
  13536. * A function that is added to the onAfterRenderObservable
  13537. */
  13538. onAfterRender: (efect: Effect) => void;
  13539. /**
  13540. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  13541. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13542. */
  13543. inputTexture: InternalTexture;
  13544. /**
  13545. * Gets the camera which post process is applied to.
  13546. * @returns The camera the post process is applied to.
  13547. */
  13548. getCamera(): Camera;
  13549. /**
  13550. * Gets the texel size of the postprocess.
  13551. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13552. */
  13553. readonly texelSize: Vector2;
  13554. /**
  13555. * Creates a new instance PostProcess
  13556. * @param name The name of the PostProcess.
  13557. * @param fragmentUrl The url of the fragment shader to be used.
  13558. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13559. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13561. * @param camera The camera to apply the render pass to.
  13562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13563. * @param engine The engine which the post process will be applied. (default: current engine)
  13564. * @param reusable If the post process can be reused on the same frame. (default: false)
  13565. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13566. * @param textureType Type of textures used when performing the post process. (default: 0)
  13567. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13568. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13569. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13570. */
  13571. constructor(
  13572. /** Name of the PostProcess. */
  13573. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  13574. /**
  13575. * Gets a string idenfifying the name of the class
  13576. * @returns "PostProcess" string
  13577. */
  13578. getClassName(): string;
  13579. /**
  13580. * Gets the engine which this post process belongs to.
  13581. * @returns The engine the post process was enabled with.
  13582. */
  13583. getEngine(): Engine;
  13584. /**
  13585. * The effect that is created when initializing the post process.
  13586. * @returns The created effect corrisponding the the postprocess.
  13587. */
  13588. getEffect(): Effect;
  13589. /**
  13590. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13591. * @param postProcess The post process to share the output with.
  13592. * @returns This post process.
  13593. */
  13594. shareOutputWith(postProcess: PostProcess): PostProcess;
  13595. /**
  13596. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13597. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13598. */
  13599. useOwnOutput(): void;
  13600. /**
  13601. * Updates the effect with the current post process compile time values and recompiles the shader.
  13602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13605. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13606. * @param onCompiled Called when the shader has been compiled.
  13607. * @param onError Called if there is an error when compiling a shader.
  13608. */
  13609. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13610. /**
  13611. * The post process is reusable if it can be used multiple times within one frame.
  13612. * @returns If the post process is reusable
  13613. */
  13614. isReusable(): boolean;
  13615. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13616. markTextureDirty(): void;
  13617. /**
  13618. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13619. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  13620. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13621. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13622. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13623. * @returns The target texture that was bound to be written to.
  13624. */
  13625. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13626. /**
  13627. * If the post process is supported.
  13628. */
  13629. readonly isSupported: boolean;
  13630. /**
  13631. * The aspect ratio of the output texture.
  13632. */
  13633. readonly aspectRatio: number;
  13634. /**
  13635. * Get a value indicating if the post-process is ready to be used
  13636. * @returns true if the post-process is ready (shader is compiled)
  13637. */
  13638. isReady(): boolean;
  13639. /**
  13640. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13641. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13642. */
  13643. apply(): Nullable<Effect>;
  13644. private _disposeTextures;
  13645. /**
  13646. * Disposes the post process.
  13647. * @param camera The camera to dispose the post process on.
  13648. */
  13649. dispose(camera?: Camera): void;
  13650. }
  13651. }
  13652. declare module "babylonjs/PostProcesses/postProcessManager" {
  13653. import { Nullable } from "babylonjs/types";
  13654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13655. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13656. import { Scene } from "babylonjs/scene";
  13657. /**
  13658. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13659. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13660. */
  13661. export class PostProcessManager {
  13662. private _scene;
  13663. private _indexBuffer;
  13664. private _vertexBuffers;
  13665. /**
  13666. * Creates a new instance PostProcess
  13667. * @param scene The scene that the post process is associated with.
  13668. */
  13669. constructor(scene: Scene);
  13670. private _prepareBuffers;
  13671. private _buildIndexBuffer;
  13672. /**
  13673. * Rebuilds the vertex buffers of the manager.
  13674. * @hidden
  13675. */
  13676. _rebuild(): void;
  13677. /**
  13678. * Prepares a frame to be run through a post process.
  13679. * @param sourceTexture The input texture to the post procesess. (default: null)
  13680. * @param postProcesses An array of post processes to be run. (default: null)
  13681. * @returns True if the post processes were able to be run.
  13682. * @hidden
  13683. */
  13684. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13685. /**
  13686. * Manually render a set of post processes to a texture.
  13687. * @param postProcesses An array of post processes to be run.
  13688. * @param targetTexture The target texture to render to.
  13689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13690. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13691. * @param lodLevel defines which lod of the texture to render to
  13692. */
  13693. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13694. /**
  13695. * Finalize the result of the output of the postprocesses.
  13696. * @param doNotPresent If true the result will not be displayed to the screen.
  13697. * @param targetTexture The target texture to render to.
  13698. * @param faceIndex The index of the face to bind the target texture to.
  13699. * @param postProcesses The array of post processes to render.
  13700. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13701. * @hidden
  13702. */
  13703. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13704. /**
  13705. * Disposes of the post process manager.
  13706. */
  13707. dispose(): void;
  13708. }
  13709. }
  13710. declare module "babylonjs/Layers/layerSceneComponent" {
  13711. import { Scene } from "babylonjs/scene";
  13712. import { ISceneComponent } from "babylonjs/sceneComponent";
  13713. import { Layer } from "babylonjs/Layers/layer";
  13714. module "babylonjs/abstractScene" {
  13715. interface AbstractScene {
  13716. /**
  13717. * The list of layers (background and foreground) of the scene
  13718. */
  13719. layers: Array<Layer>;
  13720. }
  13721. }
  13722. /**
  13723. * Defines the layer scene component responsible to manage any layers
  13724. * in a given scene.
  13725. */
  13726. export class LayerSceneComponent implements ISceneComponent {
  13727. /**
  13728. * The component name helpfull to identify the component in the list of scene components.
  13729. */
  13730. readonly name: string;
  13731. /**
  13732. * The scene the component belongs to.
  13733. */
  13734. scene: Scene;
  13735. private _engine;
  13736. /**
  13737. * Creates a new instance of the component for the given scene
  13738. * @param scene Defines the scene to register the component in
  13739. */
  13740. constructor(scene: Scene);
  13741. /**
  13742. * Registers the component in a given scene
  13743. */
  13744. register(): void;
  13745. /**
  13746. * Rebuilds the elements related to this component in case of
  13747. * context lost for instance.
  13748. */
  13749. rebuild(): void;
  13750. /**
  13751. * Disposes the component and the associated ressources.
  13752. */
  13753. dispose(): void;
  13754. private _draw;
  13755. private _drawCameraPredicate;
  13756. private _drawCameraBackground;
  13757. private _drawCameraForeground;
  13758. private _drawRenderTargetPredicate;
  13759. private _drawRenderTargetBackground;
  13760. private _drawRenderTargetForeground;
  13761. }
  13762. }
  13763. declare module "babylonjs/Shaders/layer.fragment" {
  13764. /** @hidden */
  13765. export var layerPixelShader: {
  13766. name: string;
  13767. shader: string;
  13768. };
  13769. }
  13770. declare module "babylonjs/Shaders/layer.vertex" {
  13771. /** @hidden */
  13772. export var layerVertexShader: {
  13773. name: string;
  13774. shader: string;
  13775. };
  13776. }
  13777. declare module "babylonjs/Layers/layer" {
  13778. import { Observable } from "babylonjs/Misc/observable";
  13779. import { Nullable } from "babylonjs/types";
  13780. import { Scene } from "babylonjs/scene";
  13781. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13782. import { Texture } from "babylonjs/Materials/Textures/texture";
  13783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13784. import "babylonjs/Shaders/layer.fragment";
  13785. import "babylonjs/Shaders/layer.vertex";
  13786. /**
  13787. * This represents a full screen 2d layer.
  13788. * This can be useful to display a picture in the background of your scene for instance.
  13789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13790. */
  13791. export class Layer {
  13792. /**
  13793. * Define the name of the layer.
  13794. */
  13795. name: string;
  13796. /**
  13797. * Define the texture the layer should display.
  13798. */
  13799. texture: Nullable<Texture>;
  13800. /**
  13801. * Is the layer in background or foreground.
  13802. */
  13803. isBackground: boolean;
  13804. /**
  13805. * Define the color of the layer (instead of texture).
  13806. */
  13807. color: Color4;
  13808. /**
  13809. * Define the scale of the layer in order to zoom in out of the texture.
  13810. */
  13811. scale: Vector2;
  13812. /**
  13813. * Define an offset for the layer in order to shift the texture.
  13814. */
  13815. offset: Vector2;
  13816. /**
  13817. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13818. */
  13819. alphaBlendingMode: number;
  13820. /**
  13821. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13822. * Alpha test will not mix with the background color in case of transparency.
  13823. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13824. */
  13825. alphaTest: boolean;
  13826. /**
  13827. * Define a mask to restrict the layer to only some of the scene cameras.
  13828. */
  13829. layerMask: number;
  13830. /**
  13831. * Define the list of render target the layer is visible into.
  13832. */
  13833. renderTargetTextures: RenderTargetTexture[];
  13834. /**
  13835. * Define if the layer is only used in renderTarget or if it also
  13836. * renders in the main frame buffer of the canvas.
  13837. */
  13838. renderOnlyInRenderTargetTextures: boolean;
  13839. private _scene;
  13840. private _vertexBuffers;
  13841. private _indexBuffer;
  13842. private _effect;
  13843. private _alphaTestEffect;
  13844. /**
  13845. * An event triggered when the layer is disposed.
  13846. */
  13847. onDisposeObservable: Observable<Layer>;
  13848. private _onDisposeObserver;
  13849. /**
  13850. * Back compatibility with callback before the onDisposeObservable existed.
  13851. * The set callback will be triggered when the layer has been disposed.
  13852. */
  13853. onDispose: () => void;
  13854. /**
  13855. * An event triggered before rendering the scene
  13856. */
  13857. onBeforeRenderObservable: Observable<Layer>;
  13858. private _onBeforeRenderObserver;
  13859. /**
  13860. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13861. * The set callback will be triggered just before rendering the layer.
  13862. */
  13863. onBeforeRender: () => void;
  13864. /**
  13865. * An event triggered after rendering the scene
  13866. */
  13867. onAfterRenderObservable: Observable<Layer>;
  13868. private _onAfterRenderObserver;
  13869. /**
  13870. * Back compatibility with callback before the onAfterRenderObservable existed.
  13871. * The set callback will be triggered just after rendering the layer.
  13872. */
  13873. onAfterRender: () => void;
  13874. /**
  13875. * Instantiates a new layer.
  13876. * This represents a full screen 2d layer.
  13877. * This can be useful to display a picture in the background of your scene for instance.
  13878. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13879. * @param name Define the name of the layer in the scene
  13880. * @param imgUrl Define the url of the texture to display in the layer
  13881. * @param scene Define the scene the layer belongs to
  13882. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13883. * @param color Defines a color for the layer
  13884. */
  13885. constructor(
  13886. /**
  13887. * Define the name of the layer.
  13888. */
  13889. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13890. private _createIndexBuffer;
  13891. /** @hidden */
  13892. _rebuild(): void;
  13893. /**
  13894. * Renders the layer in the scene.
  13895. */
  13896. render(): void;
  13897. /**
  13898. * Disposes and releases the associated ressources.
  13899. */
  13900. dispose(): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13904. import { Scene } from "babylonjs/scene";
  13905. import { ISceneComponent } from "babylonjs/sceneComponent";
  13906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13907. module "babylonjs/abstractScene" {
  13908. interface AbstractScene {
  13909. /**
  13910. * The list of procedural textures added to the scene
  13911. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13912. */
  13913. proceduralTextures: Array<ProceduralTexture>;
  13914. }
  13915. }
  13916. /**
  13917. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13918. * in a given scene.
  13919. */
  13920. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13921. /**
  13922. * The component name helpfull to identify the component in the list of scene components.
  13923. */
  13924. readonly name: string;
  13925. /**
  13926. * The scene the component belongs to.
  13927. */
  13928. scene: Scene;
  13929. /**
  13930. * Creates a new instance of the component for the given scene
  13931. * @param scene Defines the scene to register the component in
  13932. */
  13933. constructor(scene: Scene);
  13934. /**
  13935. * Registers the component in a given scene
  13936. */
  13937. register(): void;
  13938. /**
  13939. * Rebuilds the elements related to this component in case of
  13940. * context lost for instance.
  13941. */
  13942. rebuild(): void;
  13943. /**
  13944. * Disposes the component and the associated ressources.
  13945. */
  13946. dispose(): void;
  13947. private _beforeClear;
  13948. }
  13949. }
  13950. declare module "babylonjs/Shaders/procedural.vertex" {
  13951. /** @hidden */
  13952. export var proceduralVertexShader: {
  13953. name: string;
  13954. shader: string;
  13955. };
  13956. }
  13957. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13958. import { Observable } from "babylonjs/Misc/observable";
  13959. import { Nullable } from "babylonjs/types";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13962. import { Effect } from "babylonjs/Materials/effect";
  13963. import { Texture } from "babylonjs/Materials/Textures/texture";
  13964. import "babylonjs/Shaders/procedural.vertex";
  13965. /**
  13966. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  13967. * This is the base class of any Procedural texture and contains most of the shareable code.
  13968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13969. */
  13970. export class ProceduralTexture extends Texture {
  13971. isCube: boolean;
  13972. /**
  13973. * Define if the texture is enabled or not (disabled texture will not render)
  13974. */
  13975. isEnabled: boolean;
  13976. /**
  13977. * Define if the texture must be cleared before rendering (default is true)
  13978. */
  13979. autoClear: boolean;
  13980. /**
  13981. * Callback called when the texture is generated
  13982. */
  13983. onGenerated: () => void;
  13984. /**
  13985. * Event raised when the texture is generated
  13986. */
  13987. onGeneratedObservable: Observable<ProceduralTexture>;
  13988. /** @hidden */
  13989. _generateMipMaps: boolean;
  13990. /** @hidden **/
  13991. _effect: Effect;
  13992. /** @hidden */
  13993. _textures: {
  13994. [key: string]: Texture;
  13995. };
  13996. private _size;
  13997. private _currentRefreshId;
  13998. private _refreshRate;
  13999. private _vertexBuffers;
  14000. private _indexBuffer;
  14001. private _uniforms;
  14002. private _samplers;
  14003. private _fragment;
  14004. private _floats;
  14005. private _ints;
  14006. private _floatsArrays;
  14007. private _colors3;
  14008. private _colors4;
  14009. private _vectors2;
  14010. private _vectors3;
  14011. private _matrices;
  14012. private _fallbackTexture;
  14013. private _fallbackTextureUsed;
  14014. private _engine;
  14015. private _cachedDefines;
  14016. private _contentUpdateId;
  14017. private _contentData;
  14018. /**
  14019. * Instantiates a new procedural texture.
  14020. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  14021. * This is the base class of any Procedural texture and contains most of the shareable code.
  14022. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14023. * @param name Define the name of the texture
  14024. * @param size Define the size of the texture to create
  14025. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14026. * @param scene Define the scene the texture belongs to
  14027. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14028. * @param generateMipMaps Define if the texture should creates mip maps or not
  14029. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14030. */
  14031. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14032. /**
  14033. * The effect that is created when initializing the post process.
  14034. * @returns The created effect corrisponding the the postprocess.
  14035. */
  14036. getEffect(): Effect;
  14037. /**
  14038. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14039. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14040. */
  14041. getContent(): Nullable<ArrayBufferView>;
  14042. private _createIndexBuffer;
  14043. /** @hidden */
  14044. _rebuild(): void;
  14045. /**
  14046. * Resets the texture in order to recreate its associated resources.
  14047. * This can be called in case of context loss
  14048. */
  14049. reset(): void;
  14050. protected _getDefines(): string;
  14051. /**
  14052. * Is the texture ready to be used ? (rendered at least once)
  14053. * @returns true if ready, otherwise, false.
  14054. */
  14055. isReady(): boolean;
  14056. /**
  14057. * Resets the refresh counter of the texture and start bak from scratch.
  14058. * Could be useful to regenerate the texture if it is setup to render only once.
  14059. */
  14060. resetRefreshCounter(): void;
  14061. /**
  14062. * Set the fragment shader to use in order to render the texture.
  14063. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14064. */
  14065. setFragment(fragment: any): void;
  14066. /**
  14067. * Define the refresh rate of the texture or the rendering frequency.
  14068. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14069. */
  14070. refreshRate: number;
  14071. /** @hidden */
  14072. _shouldRender(): boolean;
  14073. /**
  14074. * Get the size the texture is rendering at.
  14075. * @returns the size (texture is always squared)
  14076. */
  14077. getRenderSize(): number;
  14078. /**
  14079. * Resize the texture to new value.
  14080. * @param size Define the new size the texture should have
  14081. * @param generateMipMaps Define whether the new texture should create mip maps
  14082. */
  14083. resize(size: number, generateMipMaps: boolean): void;
  14084. private _checkUniform;
  14085. /**
  14086. * Set a texture in the shader program used to render.
  14087. * @param name Define the name of the uniform samplers as defined in the shader
  14088. * @param texture Define the texture to bind to this sampler
  14089. * @return the texture itself allowing "fluent" like uniform updates
  14090. */
  14091. setTexture(name: string, texture: Texture): ProceduralTexture;
  14092. /**
  14093. * Set a float in the shader.
  14094. * @param name Define the name of the uniform as defined in the shader
  14095. * @param value Define the value to give to the uniform
  14096. * @return the texture itself allowing "fluent" like uniform updates
  14097. */
  14098. setFloat(name: string, value: number): ProceduralTexture;
  14099. /**
  14100. * Set a int in the shader.
  14101. * @param name Define the name of the uniform as defined in the shader
  14102. * @param value Define the value to give to the uniform
  14103. * @return the texture itself allowing "fluent" like uniform updates
  14104. */
  14105. setInt(name: string, value: number): ProceduralTexture;
  14106. /**
  14107. * Set an array of floats in the shader.
  14108. * @param name Define the name of the uniform as defined in the shader
  14109. * @param value Define the value to give to the uniform
  14110. * @return the texture itself allowing "fluent" like uniform updates
  14111. */
  14112. setFloats(name: string, value: number[]): ProceduralTexture;
  14113. /**
  14114. * Set a vec3 in the shader from a Color3.
  14115. * @param name Define the name of the uniform as defined in the shader
  14116. * @param value Define the value to give to the uniform
  14117. * @return the texture itself allowing "fluent" like uniform updates
  14118. */
  14119. setColor3(name: string, value: Color3): ProceduralTexture;
  14120. /**
  14121. * Set a vec4 in the shader from a Color4.
  14122. * @param name Define the name of the uniform as defined in the shader
  14123. * @param value Define the value to give to the uniform
  14124. * @return the texture itself allowing "fluent" like uniform updates
  14125. */
  14126. setColor4(name: string, value: Color4): ProceduralTexture;
  14127. /**
  14128. * Set a vec2 in the shader from a Vector2.
  14129. * @param name Define the name of the uniform as defined in the shader
  14130. * @param value Define the value to give to the uniform
  14131. * @return the texture itself allowing "fluent" like uniform updates
  14132. */
  14133. setVector2(name: string, value: Vector2): ProceduralTexture;
  14134. /**
  14135. * Set a vec3 in the shader from a Vector3.
  14136. * @param name Define the name of the uniform as defined in the shader
  14137. * @param value Define the value to give to the uniform
  14138. * @return the texture itself allowing "fluent" like uniform updates
  14139. */
  14140. setVector3(name: string, value: Vector3): ProceduralTexture;
  14141. /**
  14142. * Set a mat4 in the shader from a MAtrix.
  14143. * @param name Define the name of the uniform as defined in the shader
  14144. * @param value Define the value to give to the uniform
  14145. * @return the texture itself allowing "fluent" like uniform updates
  14146. */
  14147. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14148. /**
  14149. * Render the texture to its associated render target.
  14150. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14151. */
  14152. render(useCameraPostProcess?: boolean): void;
  14153. /**
  14154. * Clone the texture.
  14155. * @returns the cloned texture
  14156. */
  14157. clone(): ProceduralTexture;
  14158. /**
  14159. * Dispose the texture and release its asoociated resources.
  14160. */
  14161. dispose(): void;
  14162. }
  14163. }
  14164. declare module "babylonjs/Particles/baseParticleSystem" {
  14165. import { Nullable } from "babylonjs/types";
  14166. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14168. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14169. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14171. import { Scene } from "babylonjs/scene";
  14172. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14173. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14174. import { Texture } from "babylonjs/Materials/Textures/texture";
  14175. import { Animation } from "babylonjs/Animations/animation";
  14176. /**
  14177. * This represents the base class for particle system in Babylon.
  14178. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14180. * @example https://doc.babylonjs.com/babylon101/particles
  14181. */
  14182. export class BaseParticleSystem {
  14183. /**
  14184. * Source color is added to the destination color without alpha affecting the result
  14185. */
  14186. static BLENDMODE_ONEONE: number;
  14187. /**
  14188. * Blend current color and particle color using particle’s alpha
  14189. */
  14190. static BLENDMODE_STANDARD: number;
  14191. /**
  14192. * Add current color and particle color multiplied by particle’s alpha
  14193. */
  14194. static BLENDMODE_ADD: number;
  14195. /**
  14196. * Multiply current color with particle color
  14197. */
  14198. static BLENDMODE_MULTIPLY: number;
  14199. /**
  14200. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14201. */
  14202. static BLENDMODE_MULTIPLYADD: number;
  14203. /**
  14204. * List of animations used by the particle system.
  14205. */
  14206. animations: Animation[];
  14207. /**
  14208. * The id of the Particle system.
  14209. */
  14210. id: string;
  14211. /**
  14212. * The friendly name of the Particle system.
  14213. */
  14214. name: string;
  14215. /**
  14216. * The rendering group used by the Particle system to chose when to render.
  14217. */
  14218. renderingGroupId: number;
  14219. /**
  14220. * The emitter represents the Mesh or position we are attaching the particle system to.
  14221. */
  14222. emitter: Nullable<AbstractMesh | Vector3>;
  14223. /**
  14224. * The maximum number of particles to emit per frame
  14225. */
  14226. emitRate: number;
  14227. /**
  14228. * If you want to launch only a few particles at once, that can be done, as well.
  14229. */
  14230. manualEmitCount: number;
  14231. /**
  14232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14233. */
  14234. updateSpeed: number;
  14235. /**
  14236. * The amount of time the particle system is running (depends of the overall update speed).
  14237. */
  14238. targetStopDuration: number;
  14239. /**
  14240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14241. */
  14242. disposeOnStop: boolean;
  14243. /**
  14244. * Minimum power of emitting particles.
  14245. */
  14246. minEmitPower: number;
  14247. /**
  14248. * Maximum power of emitting particles.
  14249. */
  14250. maxEmitPower: number;
  14251. /**
  14252. * Minimum life time of emitting particles.
  14253. */
  14254. minLifeTime: number;
  14255. /**
  14256. * Maximum life time of emitting particles.
  14257. */
  14258. maxLifeTime: number;
  14259. /**
  14260. * Minimum Size of emitting particles.
  14261. */
  14262. minSize: number;
  14263. /**
  14264. * Maximum Size of emitting particles.
  14265. */
  14266. maxSize: number;
  14267. /**
  14268. * Minimum scale of emitting particles on X axis.
  14269. */
  14270. minScaleX: number;
  14271. /**
  14272. * Maximum scale of emitting particles on X axis.
  14273. */
  14274. maxScaleX: number;
  14275. /**
  14276. * Minimum scale of emitting particles on Y axis.
  14277. */
  14278. minScaleY: number;
  14279. /**
  14280. * Maximum scale of emitting particles on Y axis.
  14281. */
  14282. maxScaleY: number;
  14283. /**
  14284. * Gets or sets the minimal initial rotation in radians.
  14285. */
  14286. minInitialRotation: number;
  14287. /**
  14288. * Gets or sets the maximal initial rotation in radians.
  14289. */
  14290. maxInitialRotation: number;
  14291. /**
  14292. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14293. */
  14294. minAngularSpeed: number;
  14295. /**
  14296. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14297. */
  14298. maxAngularSpeed: number;
  14299. /**
  14300. * The texture used to render each particle. (this can be a spritesheet)
  14301. */
  14302. particleTexture: Nullable<Texture>;
  14303. /**
  14304. * The layer mask we are rendering the particles through.
  14305. */
  14306. layerMask: number;
  14307. /**
  14308. * This can help using your own shader to render the particle system.
  14309. * The according effect will be created
  14310. */
  14311. customShader: any;
  14312. /**
  14313. * By default particle system starts as soon as they are created. This prevents the
  14314. * automatic start to happen and let you decide when to start emitting particles.
  14315. */
  14316. preventAutoStart: boolean;
  14317. private _noiseTexture;
  14318. /**
  14319. * Gets or sets a texture used to add random noise to particle positions
  14320. */
  14321. noiseTexture: Nullable<ProceduralTexture>;
  14322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14323. noiseStrength: Vector3;
  14324. /**
  14325. * Callback triggered when the particle animation is ending.
  14326. */
  14327. onAnimationEnd: Nullable<() => void>;
  14328. /**
  14329. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14330. */
  14331. blendMode: number;
  14332. /**
  14333. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14334. * to override the particles.
  14335. */
  14336. forceDepthWrite: boolean;
  14337. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  14338. preWarmCycles: number;
  14339. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14340. preWarmStepOffset: number;
  14341. /**
  14342. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14343. */
  14344. spriteCellChangeSpeed: number;
  14345. /**
  14346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14347. */
  14348. startSpriteCellID: number;
  14349. /**
  14350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14351. */
  14352. endSpriteCellID: number;
  14353. /**
  14354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14355. */
  14356. spriteCellWidth: number;
  14357. /**
  14358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14359. */
  14360. spriteCellHeight: number;
  14361. /**
  14362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14363. */
  14364. spriteRandomStartCell: boolean;
  14365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14366. translationPivot: Vector2;
  14367. /** @hidden */
  14368. protected _isAnimationSheetEnabled: boolean;
  14369. /**
  14370. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14371. */
  14372. beginAnimationOnStart: boolean;
  14373. /**
  14374. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14375. */
  14376. beginAnimationFrom: number;
  14377. /**
  14378. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14379. */
  14380. beginAnimationTo: number;
  14381. /**
  14382. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14383. */
  14384. beginAnimationLoop: boolean;
  14385. /**
  14386. * Gets or sets a world offset applied to all particles
  14387. */
  14388. worldOffset: Vector3;
  14389. /**
  14390. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14391. */
  14392. isAnimationSheetEnabled: boolean;
  14393. /**
  14394. * Get hosting scene
  14395. * @returns the scene
  14396. */
  14397. getScene(): Scene;
  14398. /**
  14399. * You can use gravity if you want to give an orientation to your particles.
  14400. */
  14401. gravity: Vector3;
  14402. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14403. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14404. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14405. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14406. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14407. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14408. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14409. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14410. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14411. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14412. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14413. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14414. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14415. /**
  14416. * Defines the delay in milliseconds before starting the system (0 by default)
  14417. */
  14418. startDelay: number;
  14419. /**
  14420. * Gets the current list of drag gradients.
  14421. * You must use addDragGradient and removeDragGradient to udpate this list
  14422. * @returns the list of drag gradients
  14423. */
  14424. getDragGradients(): Nullable<Array<FactorGradient>>;
  14425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14426. limitVelocityDamping: number;
  14427. /**
  14428. * Gets the current list of limit velocity gradients.
  14429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14430. * @returns the list of limit velocity gradients
  14431. */
  14432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14433. /**
  14434. * Gets the current list of color gradients.
  14435. * You must use addColorGradient and removeColorGradient to udpate this list
  14436. * @returns the list of color gradients
  14437. */
  14438. getColorGradients(): Nullable<Array<ColorGradient>>;
  14439. /**
  14440. * Gets the current list of size gradients.
  14441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14442. * @returns the list of size gradients
  14443. */
  14444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14445. /**
  14446. * Gets the current list of color remap gradients.
  14447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14448. * @returns the list of color remap gradients
  14449. */
  14450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14451. /**
  14452. * Gets the current list of alpha remap gradients.
  14453. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14454. * @returns the list of alpha remap gradients
  14455. */
  14456. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14457. /**
  14458. * Gets the current list of life time gradients.
  14459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14460. * @returns the list of life time gradients
  14461. */
  14462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14463. /**
  14464. * Gets the current list of angular speed gradients.
  14465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14466. * @returns the list of angular speed gradients
  14467. */
  14468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14469. /**
  14470. * Gets the current list of velocity gradients.
  14471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14472. * @returns the list of velocity gradients
  14473. */
  14474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14475. /**
  14476. * Gets the current list of start size gradients.
  14477. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14478. * @returns the list of start size gradients
  14479. */
  14480. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of emit rate gradients.
  14483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14484. * @returns the list of emit rate gradients
  14485. */
  14486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14487. /**
  14488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14490. */
  14491. direction1: Vector3;
  14492. /**
  14493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14495. */
  14496. direction2: Vector3;
  14497. /**
  14498. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14499. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14500. */
  14501. minEmitBox: Vector3;
  14502. /**
  14503. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14504. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14505. */
  14506. maxEmitBox: Vector3;
  14507. /**
  14508. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14509. */
  14510. color1: Color4;
  14511. /**
  14512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14513. */
  14514. color2: Color4;
  14515. /**
  14516. * Color the particle will have at the end of its lifetime
  14517. */
  14518. colorDead: Color4;
  14519. /**
  14520. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14521. */
  14522. textureMask: Color4;
  14523. /**
  14524. * The particle emitter type defines the emitter used by the particle system.
  14525. * It can be for example box, sphere, or cone...
  14526. */
  14527. particleEmitterType: IParticleEmitterType;
  14528. /** @hidden */
  14529. _isSubEmitter: boolean;
  14530. /**
  14531. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14532. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14533. */
  14534. billboardMode: number;
  14535. protected _isBillboardBased: boolean;
  14536. /**
  14537. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14538. */
  14539. isBillboardBased: boolean;
  14540. /**
  14541. * The scene the particle system belongs to.
  14542. */
  14543. protected _scene: Scene;
  14544. /**
  14545. * Local cache of defines for image processing.
  14546. */
  14547. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14548. /**
  14549. * Default configuration related to image processing available in the standard Material.
  14550. */
  14551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14552. /**
  14553. * Gets the image processing configuration used either in this material.
  14554. */
  14555. /**
  14556. * Sets the Default image processing configuration used either in the this material.
  14557. *
  14558. * If sets to null, the scene one is in use.
  14559. */
  14560. imageProcessingConfiguration: ImageProcessingConfiguration;
  14561. /**
  14562. * Attaches a new image processing configuration to the Standard Material.
  14563. * @param configuration
  14564. */
  14565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14566. /** @hidden */
  14567. protected _reset(): void;
  14568. /** @hidden */
  14569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14570. /**
  14571. * Instantiates a particle system.
  14572. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14573. * @param name The name of the particle system
  14574. */
  14575. constructor(name: string);
  14576. /**
  14577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14580. * @returns the emitter
  14581. */
  14582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14583. /**
  14584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14585. * @param radius The radius of the hemisphere to emit from
  14586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14587. * @returns the emitter
  14588. */
  14589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14590. /**
  14591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14592. * @param radius The radius of the sphere to emit from
  14593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14594. * @returns the emitter
  14595. */
  14596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14597. /**
  14598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14599. * @param radius The radius of the sphere to emit from
  14600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14602. * @returns the emitter
  14603. */
  14604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14605. /**
  14606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14607. * @param radius The radius of the emission cylinder
  14608. * @param height The height of the emission cylinder
  14609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14611. * @returns the emitter
  14612. */
  14613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14614. /**
  14615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14616. * @param radius The radius of the cylinder to emit from
  14617. * @param height The height of the emission cylinder
  14618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14621. * @returns the emitter
  14622. */
  14623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14626. * @param radius The radius of the cone to emit from
  14627. * @param angle The base angle of the cone
  14628. * @returns the emitter
  14629. */
  14630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14631. /**
  14632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14637. * @returns the emitter
  14638. */
  14639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14640. }
  14641. }
  14642. declare module "babylonjs/Particles/subEmitter" {
  14643. import { Scene } from "babylonjs/scene";
  14644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14645. /**
  14646. * Type of sub emitter
  14647. */
  14648. export enum SubEmitterType {
  14649. /**
  14650. * Attached to the particle over it's lifetime
  14651. */
  14652. ATTACHED = 0,
  14653. /**
  14654. * Created when the particle dies
  14655. */
  14656. END = 1
  14657. }
  14658. /**
  14659. * Sub emitter class used to emit particles from an existing particle
  14660. */
  14661. export class SubEmitter {
  14662. /**
  14663. * the particle system to be used by the sub emitter
  14664. */
  14665. particleSystem: ParticleSystem;
  14666. /**
  14667. * Type of the submitter (Default: END)
  14668. */
  14669. type: SubEmitterType;
  14670. /**
  14671. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  14672. * Note: This only is supported when using an emitter of type Mesh
  14673. */
  14674. inheritDirection: boolean;
  14675. /**
  14676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14677. */
  14678. inheritedVelocityAmount: number;
  14679. /**
  14680. * Creates a sub emitter
  14681. * @param particleSystem the particle system to be used by the sub emitter
  14682. */
  14683. constructor(
  14684. /**
  14685. * the particle system to be used by the sub emitter
  14686. */
  14687. particleSystem: ParticleSystem);
  14688. /**
  14689. * Clones the sub emitter
  14690. * @returns the cloned sub emitter
  14691. */
  14692. clone(): SubEmitter;
  14693. /**
  14694. * Serialize current object to a JSON object
  14695. * @returns the serialized object
  14696. */
  14697. serialize(): any;
  14698. /** @hidden */
  14699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14700. /**
  14701. * Creates a new SubEmitter from a serialized JSON version
  14702. * @param serializationObject defines the JSON object to read from
  14703. * @param scene defines the hosting scene
  14704. * @param rootUrl defines the rootUrl for data loading
  14705. * @returns a new SubEmitter
  14706. */
  14707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14708. /** Release associated resources */
  14709. dispose(): void;
  14710. }
  14711. }
  14712. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14713. /** @hidden */
  14714. export var clipPlaneFragmentDeclaration: {
  14715. name: string;
  14716. shader: string;
  14717. };
  14718. }
  14719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14720. /** @hidden */
  14721. export var imageProcessingDeclaration: {
  14722. name: string;
  14723. shader: string;
  14724. };
  14725. }
  14726. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14727. /** @hidden */
  14728. export var imageProcessingFunctions: {
  14729. name: string;
  14730. shader: string;
  14731. };
  14732. }
  14733. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14734. /** @hidden */
  14735. export var clipPlaneFragment: {
  14736. name: string;
  14737. shader: string;
  14738. };
  14739. }
  14740. declare module "babylonjs/Shaders/particles.fragment" {
  14741. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14742. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14746. /** @hidden */
  14747. export var particlesPixelShader: {
  14748. name: string;
  14749. shader: string;
  14750. };
  14751. }
  14752. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14753. /** @hidden */
  14754. export var clipPlaneVertexDeclaration: {
  14755. name: string;
  14756. shader: string;
  14757. };
  14758. }
  14759. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14760. /** @hidden */
  14761. export var clipPlaneVertex: {
  14762. name: string;
  14763. shader: string;
  14764. };
  14765. }
  14766. declare module "babylonjs/Shaders/particles.vertex" {
  14767. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14768. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14769. /** @hidden */
  14770. export var particlesVertexShader: {
  14771. name: string;
  14772. shader: string;
  14773. };
  14774. }
  14775. declare module "babylonjs/Particles/particleSystem" {
  14776. import { Nullable } from "babylonjs/types";
  14777. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14778. import { Observable } from "babylonjs/Misc/observable";
  14779. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14780. import { Effect } from "babylonjs/Materials/effect";
  14781. import { Scene, IDisposable } from "babylonjs/scene";
  14782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14783. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14784. import { Particle } from "babylonjs/Particles/particle";
  14785. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14786. import "babylonjs/Shaders/particles.fragment";
  14787. import "babylonjs/Shaders/particles.vertex";
  14788. /**
  14789. * This represents a particle system in Babylon.
  14790. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14792. * @example https://doc.babylonjs.com/babylon101/particles
  14793. */
  14794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14795. /**
  14796. * Billboard mode will only apply to Y axis
  14797. */
  14798. static readonly BILLBOARDMODE_Y: number;
  14799. /**
  14800. * Billboard mode will apply to all axes
  14801. */
  14802. static readonly BILLBOARDMODE_ALL: number;
  14803. /**
  14804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14805. */
  14806. static readonly BILLBOARDMODE_STRETCHED: number;
  14807. /**
  14808. * This function can be defined to provide custom update for active particles.
  14809. * This function will be called instead of regular update (age, position, color, etc.).
  14810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14811. */
  14812. updateFunction: (particles: Particle[]) => void;
  14813. private _emitterWorldMatrix;
  14814. /**
  14815. * This function can be defined to specify initial direction for every new particle.
  14816. * It by default use the emitterType defined function
  14817. */
  14818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14819. /**
  14820. * This function can be defined to specify initial position for every new particle.
  14821. * It by default use the emitterType defined function
  14822. */
  14823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14824. /**
  14825. * @hidden
  14826. */
  14827. _inheritedVelocityOffset: Vector3;
  14828. /**
  14829. * An event triggered when the system is disposed
  14830. */
  14831. onDisposeObservable: Observable<ParticleSystem>;
  14832. private _onDisposeObserver;
  14833. /**
  14834. * Sets a callback that will be triggered when the system is disposed
  14835. */
  14836. onDispose: () => void;
  14837. private _particles;
  14838. private _epsilon;
  14839. private _capacity;
  14840. private _stockParticles;
  14841. private _newPartsExcess;
  14842. private _vertexData;
  14843. private _vertexBuffer;
  14844. private _vertexBuffers;
  14845. private _spriteBuffer;
  14846. private _indexBuffer;
  14847. private _effect;
  14848. private _customEffect;
  14849. private _cachedDefines;
  14850. private _scaledColorStep;
  14851. private _colorDiff;
  14852. private _scaledDirection;
  14853. private _scaledGravity;
  14854. private _currentRenderId;
  14855. private _alive;
  14856. private _useInstancing;
  14857. private _started;
  14858. private _stopped;
  14859. private _actualFrame;
  14860. private _scaledUpdateSpeed;
  14861. private _vertexBufferSize;
  14862. /** @hidden */
  14863. _currentEmitRateGradient: Nullable<FactorGradient>;
  14864. /** @hidden */
  14865. _currentEmitRate1: number;
  14866. /** @hidden */
  14867. _currentEmitRate2: number;
  14868. /** @hidden */
  14869. _currentStartSizeGradient: Nullable<FactorGradient>;
  14870. /** @hidden */
  14871. _currentStartSize1: number;
  14872. /** @hidden */
  14873. _currentStartSize2: number;
  14874. private readonly _rawTextureWidth;
  14875. private _rampGradientsTexture;
  14876. private _useRampGradients;
  14877. /** Gets or sets a boolean indicating that ramp gradients must be used
  14878. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14879. */
  14880. useRampGradients: boolean;
  14881. /**
  14882. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  14883. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  14884. */
  14885. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14886. private _subEmitters;
  14887. /**
  14888. * @hidden
  14889. * If the particle systems emitter should be disposed when the particle system is disposed
  14890. */
  14891. _disposeEmitterOnDispose: boolean;
  14892. /**
  14893. * The current active Sub-systems, this property is used by the root particle system only.
  14894. */
  14895. activeSubSystems: Array<ParticleSystem>;
  14896. private _rootParticleSystem;
  14897. /**
  14898. * Gets the current list of active particles
  14899. */
  14900. readonly particles: Particle[];
  14901. /**
  14902. * Returns the string "ParticleSystem"
  14903. * @returns a string containing the class name
  14904. */
  14905. getClassName(): string;
  14906. /**
  14907. * Instantiates a particle system.
  14908. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14909. * @param name The name of the particle system
  14910. * @param capacity The max number of particles alive at the same time
  14911. * @param scene The scene the particle system belongs to
  14912. * @param customEffect a custom effect used to change the way particles are rendered by default
  14913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14914. * @param epsilon Offset used to render the particles
  14915. */
  14916. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14917. private _addFactorGradient;
  14918. private _removeFactorGradient;
  14919. /**
  14920. * Adds a new life time gradient
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the life time factor to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific life time gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Adds a new size gradient
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param factor defines the size factor to affect to the specified gradient
  14937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14938. * @returns the current particle system
  14939. */
  14940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14941. /**
  14942. * Remove a specific size gradient
  14943. * @param gradient defines the gradient to remove
  14944. * @returns the current particle system
  14945. */
  14946. removeSizeGradient(gradient: number): IParticleSystem;
  14947. /**
  14948. * Adds a new color remap gradient
  14949. * @param gradient defines the gradient to use (between 0 and 1)
  14950. * @param min defines the color remap minimal range
  14951. * @param max defines the color remap maximal range
  14952. * @returns the current particle system
  14953. */
  14954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14955. /**
  14956. * Remove a specific color remap gradient
  14957. * @param gradient defines the gradient to remove
  14958. * @returns the current particle system
  14959. */
  14960. removeColorRemapGradient(gradient: number): IParticleSystem;
  14961. /**
  14962. * Adds a new alpha remap gradient
  14963. * @param gradient defines the gradient to use (between 0 and 1)
  14964. * @param min defines the alpha remap minimal range
  14965. * @param max defines the alpha remap maximal range
  14966. * @returns the current particle system
  14967. */
  14968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14969. /**
  14970. * Remove a specific alpha remap gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14975. /**
  14976. * Adds a new angular speed gradient
  14977. * @param gradient defines the gradient to use (between 0 and 1)
  14978. * @param factor defines the angular speed to affect to the specified gradient
  14979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14980. * @returns the current particle system
  14981. */
  14982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14983. /**
  14984. * Remove a specific angular speed gradient
  14985. * @param gradient defines the gradient to remove
  14986. * @returns the current particle system
  14987. */
  14988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14989. /**
  14990. * Adds a new velocity gradient
  14991. * @param gradient defines the gradient to use (between 0 and 1)
  14992. * @param factor defines the velocity to affect to the specified gradient
  14993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14994. * @returns the current particle system
  14995. */
  14996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14997. /**
  14998. * Remove a specific velocity gradient
  14999. * @param gradient defines the gradient to remove
  15000. * @returns the current particle system
  15001. */
  15002. removeVelocityGradient(gradient: number): IParticleSystem;
  15003. /**
  15004. * Adds a new limit velocity gradient
  15005. * @param gradient defines the gradient to use (between 0 and 1)
  15006. * @param factor defines the limit velocity value to affect to the specified gradient
  15007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15008. * @returns the current particle system
  15009. */
  15010. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15011. /**
  15012. * Remove a specific limit velocity gradient
  15013. * @param gradient defines the gradient to remove
  15014. * @returns the current particle system
  15015. */
  15016. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15017. /**
  15018. * Adds a new drag gradient
  15019. * @param gradient defines the gradient to use (between 0 and 1)
  15020. * @param factor defines the drag value to affect to the specified gradient
  15021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15022. * @returns the current particle system
  15023. */
  15024. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15025. /**
  15026. * Remove a specific drag gradient
  15027. * @param gradient defines the gradient to remove
  15028. * @returns the current particle system
  15029. */
  15030. removeDragGradient(gradient: number): IParticleSystem;
  15031. /**
  15032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15033. * @param gradient defines the gradient to use (between 0 and 1)
  15034. * @param factor defines the emit rate value to affect to the specified gradient
  15035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15036. * @returns the current particle system
  15037. */
  15038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15039. /**
  15040. * Remove a specific emit rate gradient
  15041. * @param gradient defines the gradient to remove
  15042. * @returns the current particle system
  15043. */
  15044. removeEmitRateGradient(gradient: number): IParticleSystem;
  15045. /**
  15046. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15047. * @param gradient defines the gradient to use (between 0 and 1)
  15048. * @param factor defines the start size value to affect to the specified gradient
  15049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15050. * @returns the current particle system
  15051. */
  15052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15053. /**
  15054. * Remove a specific start size gradient
  15055. * @param gradient defines the gradient to remove
  15056. * @returns the current particle system
  15057. */
  15058. removeStartSizeGradient(gradient: number): IParticleSystem;
  15059. private _createRampGradientTexture;
  15060. /**
  15061. * Gets the current list of ramp gradients.
  15062. * You must use addRampGradient and removeRampGradient to udpate this list
  15063. * @returns the list of ramp gradients
  15064. */
  15065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15066. /**
  15067. * Adds a new ramp gradient used to remap particle colors
  15068. * @param gradient defines the gradient to use (between 0 and 1)
  15069. * @param color defines the color to affect to the specified gradient
  15070. * @returns the current particle system
  15071. */
  15072. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15073. /**
  15074. * Remove a specific ramp gradient
  15075. * @param gradient defines the gradient to remove
  15076. * @returns the current particle system
  15077. */
  15078. removeRampGradient(gradient: number): ParticleSystem;
  15079. /**
  15080. * Adds a new color gradient
  15081. * @param gradient defines the gradient to use (between 0 and 1)
  15082. * @param color1 defines the color to affect to the specified gradient
  15083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15084. * @returns this particle system
  15085. */
  15086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15087. /**
  15088. * Remove a specific color gradient
  15089. * @param gradient defines the gradient to remove
  15090. * @returns this particle system
  15091. */
  15092. removeColorGradient(gradient: number): IParticleSystem;
  15093. private _fetchR;
  15094. protected _reset(): void;
  15095. private _resetEffect;
  15096. private _createVertexBuffers;
  15097. private _createIndexBuffer;
  15098. /**
  15099. * Gets the maximum number of particles active at the same time.
  15100. * @returns The max number of active particles.
  15101. */
  15102. getCapacity(): number;
  15103. /**
  15104. * Gets whether there are still active particles in the system.
  15105. * @returns True if it is alive, otherwise false.
  15106. */
  15107. isAlive(): boolean;
  15108. /**
  15109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15110. * @returns True if it has been started, otherwise false.
  15111. */
  15112. isStarted(): boolean;
  15113. private _prepareSubEmitterInternalArray;
  15114. /**
  15115. * Starts the particle system and begins to emit
  15116. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15117. */
  15118. start(delay?: number): void;
  15119. /**
  15120. * Stops the particle system.
  15121. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15122. */
  15123. stop(stopSubEmitters?: boolean): void;
  15124. /**
  15125. * Remove all active particles
  15126. */
  15127. reset(): void;
  15128. /**
  15129. * @hidden (for internal use only)
  15130. */
  15131. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15132. /**
  15133. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15134. * Its lifetime will start back at 0.
  15135. */
  15136. recycleParticle: (particle: Particle) => void;
  15137. private _stopSubEmitters;
  15138. private _createParticle;
  15139. private _removeFromRoot;
  15140. private _emitFromParticle;
  15141. private _update;
  15142. /** @hidden */
  15143. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15144. /** @hidden */
  15145. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15146. /** @hidden */
  15147. private _getEffect;
  15148. /**
  15149. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15150. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15151. */
  15152. animate(preWarmOnly?: boolean): void;
  15153. private _appendParticleVertices;
  15154. /**
  15155. * Rebuilds the particle system.
  15156. */
  15157. rebuild(): void;
  15158. /**
  15159. * Is this system ready to be used/rendered
  15160. * @return true if the system is ready
  15161. */
  15162. isReady(): boolean;
  15163. private _render;
  15164. /**
  15165. * Renders the particle system in its current state.
  15166. * @returns the current number of particles
  15167. */
  15168. render(): number;
  15169. /**
  15170. * Disposes the particle system and free the associated resources
  15171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15172. */
  15173. dispose(disposeTexture?: boolean): void;
  15174. /**
  15175. * Clones the particle system.
  15176. * @param name The name of the cloned object
  15177. * @param newEmitter The new emitter to use
  15178. * @returns the cloned particle system
  15179. */
  15180. clone(name: string, newEmitter: any): ParticleSystem;
  15181. /**
  15182. * Serializes the particle system to a JSON object.
  15183. * @returns the JSON object
  15184. */
  15185. serialize(): any;
  15186. /** @hidden */
  15187. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15188. /** @hidden */
  15189. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15190. /**
  15191. * Parses a JSON object to create a particle system.
  15192. * @param parsedParticleSystem The JSON object to parse
  15193. * @param scene The scene to create the particle system in
  15194. * @param rootUrl The root url to use to load external dependencies like texture
  15195. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15196. * @returns the Parsed particle system
  15197. */
  15198. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15199. }
  15200. }
  15201. declare module "babylonjs/Particles/particle" {
  15202. import { Nullable } from "babylonjs/types";
  15203. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15204. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15205. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15206. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15207. /**
  15208. * A particle represents one of the element emitted by a particle system.
  15209. * This is mainly define by its coordinates, direction, velocity and age.
  15210. */
  15211. export class Particle {
  15212. /**
  15213. * The particle system the particle belongs to.
  15214. */
  15215. particleSystem: ParticleSystem;
  15216. private static _Count;
  15217. /**
  15218. * Unique ID of the particle
  15219. */
  15220. id: number;
  15221. /**
  15222. * The world position of the particle in the scene.
  15223. */
  15224. position: Vector3;
  15225. /**
  15226. * The world direction of the particle in the scene.
  15227. */
  15228. direction: Vector3;
  15229. /**
  15230. * The color of the particle.
  15231. */
  15232. color: Color4;
  15233. /**
  15234. * The color change of the particle per step.
  15235. */
  15236. colorStep: Color4;
  15237. /**
  15238. * Defines how long will the life of the particle be.
  15239. */
  15240. lifeTime: number;
  15241. /**
  15242. * The current age of the particle.
  15243. */
  15244. age: number;
  15245. /**
  15246. * The current size of the particle.
  15247. */
  15248. size: number;
  15249. /**
  15250. * The current scale of the particle.
  15251. */
  15252. scale: Vector2;
  15253. /**
  15254. * The current angle of the particle.
  15255. */
  15256. angle: number;
  15257. /**
  15258. * Defines how fast is the angle changing.
  15259. */
  15260. angularSpeed: number;
  15261. /**
  15262. * Defines the cell index used by the particle to be rendered from a sprite.
  15263. */
  15264. cellIndex: number;
  15265. /**
  15266. * The information required to support color remapping
  15267. */
  15268. remapData: Vector4;
  15269. /** @hidden */
  15270. _randomCellOffset?: number;
  15271. /** @hidden */
  15272. _initialDirection: Nullable<Vector3>;
  15273. /** @hidden */
  15274. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15275. /** @hidden */
  15276. _initialStartSpriteCellID: number;
  15277. /** @hidden */
  15278. _initialEndSpriteCellID: number;
  15279. /** @hidden */
  15280. _currentColorGradient: Nullable<ColorGradient>;
  15281. /** @hidden */
  15282. _currentColor1: Color4;
  15283. /** @hidden */
  15284. _currentColor2: Color4;
  15285. /** @hidden */
  15286. _currentSizeGradient: Nullable<FactorGradient>;
  15287. /** @hidden */
  15288. _currentSize1: number;
  15289. /** @hidden */
  15290. _currentSize2: number;
  15291. /** @hidden */
  15292. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15293. /** @hidden */
  15294. _currentAngularSpeed1: number;
  15295. /** @hidden */
  15296. _currentAngularSpeed2: number;
  15297. /** @hidden */
  15298. _currentVelocityGradient: Nullable<FactorGradient>;
  15299. /** @hidden */
  15300. _currentVelocity1: number;
  15301. /** @hidden */
  15302. _currentVelocity2: number;
  15303. /** @hidden */
  15304. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15305. /** @hidden */
  15306. _currentLimitVelocity1: number;
  15307. /** @hidden */
  15308. _currentLimitVelocity2: number;
  15309. /** @hidden */
  15310. _currentDragGradient: Nullable<FactorGradient>;
  15311. /** @hidden */
  15312. _currentDrag1: number;
  15313. /** @hidden */
  15314. _currentDrag2: number;
  15315. /** @hidden */
  15316. _randomNoiseCoordinates1: Vector3;
  15317. /** @hidden */
  15318. _randomNoiseCoordinates2: Vector3;
  15319. /**
  15320. * Creates a new instance Particle
  15321. * @param particleSystem the particle system the particle belongs to
  15322. */
  15323. constructor(
  15324. /**
  15325. * The particle system the particle belongs to.
  15326. */
  15327. particleSystem: ParticleSystem);
  15328. private updateCellInfoFromSystem;
  15329. /**
  15330. * Defines how the sprite cell index is updated for the particle
  15331. */
  15332. updateCellIndex(): void;
  15333. /** @hidden */
  15334. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15335. /** @hidden */
  15336. _inheritParticleInfoToSubEmitters(): void;
  15337. /** @hidden */
  15338. _reset(): void;
  15339. /**
  15340. * Copy the properties of particle to another one.
  15341. * @param other the particle to copy the information to.
  15342. */
  15343. copyTo(other: Particle): void;
  15344. }
  15345. }
  15346. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15347. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15348. import { Effect } from "babylonjs/Materials/effect";
  15349. import { Particle } from "babylonjs/Particles/particle";
  15350. /**
  15351. * Particle emitter represents a volume emitting particles.
  15352. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15353. */
  15354. export interface IParticleEmitterType {
  15355. /**
  15356. * Called by the particle System when the direction is computed for the created particle.
  15357. * @param worldMatrix is the world matrix of the particle system
  15358. * @param directionToUpdate is the direction vector to update with the result
  15359. * @param particle is the particle we are computed the direction for
  15360. */
  15361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15362. /**
  15363. * Called by the particle System when the position is computed for the created particle.
  15364. * @param worldMatrix is the world matrix of the particle system
  15365. * @param positionToUpdate is the position vector to update with the result
  15366. * @param particle is the particle we are computed the position for
  15367. */
  15368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15369. /**
  15370. * Clones the current emitter and returns a copy of it
  15371. * @returns the new emitter
  15372. */
  15373. clone(): IParticleEmitterType;
  15374. /**
  15375. * Called by the GPUParticleSystem to setup the update shader
  15376. * @param effect defines the update shader
  15377. */
  15378. applyToShader(effect: Effect): void;
  15379. /**
  15380. * Returns a string to use to update the GPU particles update shader
  15381. * @returns the effect defines string
  15382. */
  15383. getEffectDefines(): string;
  15384. /**
  15385. * Returns a string representing the class name
  15386. * @returns a string containing the class name
  15387. */
  15388. getClassName(): string;
  15389. /**
  15390. * Serializes the particle system to a JSON object.
  15391. * @returns the JSON object
  15392. */
  15393. serialize(): any;
  15394. /**
  15395. * Parse properties from a JSON object
  15396. * @param serializationObject defines the JSON object
  15397. */
  15398. parse(serializationObject: any): void;
  15399. }
  15400. }
  15401. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15402. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15403. import { Effect } from "babylonjs/Materials/effect";
  15404. import { Particle } from "babylonjs/Particles/particle";
  15405. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15406. /**
  15407. * Particle emitter emitting particles from the inside of a box.
  15408. * It emits the particles randomly between 2 given directions.
  15409. */
  15410. export class BoxParticleEmitter implements IParticleEmitterType {
  15411. /**
  15412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15413. */
  15414. direction1: Vector3;
  15415. /**
  15416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15417. */
  15418. direction2: Vector3;
  15419. /**
  15420. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15421. */
  15422. minEmitBox: Vector3;
  15423. /**
  15424. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15425. */
  15426. maxEmitBox: Vector3;
  15427. /**
  15428. * Creates a new instance BoxParticleEmitter
  15429. */
  15430. constructor();
  15431. /**
  15432. * Called by the particle System when the direction is computed for the created particle.
  15433. * @param worldMatrix is the world matrix of the particle system
  15434. * @param directionToUpdate is the direction vector to update with the result
  15435. * @param particle is the particle we are computed the direction for
  15436. */
  15437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15438. /**
  15439. * Called by the particle System when the position is computed for the created particle.
  15440. * @param worldMatrix is the world matrix of the particle system
  15441. * @param positionToUpdate is the position vector to update with the result
  15442. * @param particle is the particle we are computed the position for
  15443. */
  15444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15445. /**
  15446. * Clones the current emitter and returns a copy of it
  15447. * @returns the new emitter
  15448. */
  15449. clone(): BoxParticleEmitter;
  15450. /**
  15451. * Called by the GPUParticleSystem to setup the update shader
  15452. * @param effect defines the update shader
  15453. */
  15454. applyToShader(effect: Effect): void;
  15455. /**
  15456. * Returns a string to use to update the GPU particles update shader
  15457. * @returns a string containng the defines string
  15458. */
  15459. getEffectDefines(): string;
  15460. /**
  15461. * Returns the string "BoxParticleEmitter"
  15462. * @returns a string containing the class name
  15463. */
  15464. getClassName(): string;
  15465. /**
  15466. * Serializes the particle system to a JSON object.
  15467. * @returns the JSON object
  15468. */
  15469. serialize(): any;
  15470. /**
  15471. * Parse properties from a JSON object
  15472. * @param serializationObject defines the JSON object
  15473. */
  15474. parse(serializationObject: any): void;
  15475. }
  15476. }
  15477. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15478. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15479. import { Effect } from "babylonjs/Materials/effect";
  15480. import { Particle } from "babylonjs/Particles/particle";
  15481. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15482. /**
  15483. * Particle emitter emitting particles from the inside of a cone.
  15484. * It emits the particles alongside the cone volume from the base to the particle.
  15485. * The emission direction might be randomized.
  15486. */
  15487. export class ConeParticleEmitter implements IParticleEmitterType {
  15488. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15489. directionRandomizer: number;
  15490. private _radius;
  15491. private _angle;
  15492. private _height;
  15493. /**
  15494. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15495. */
  15496. radiusRange: number;
  15497. /**
  15498. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15499. */
  15500. heightRange: number;
  15501. /**
  15502. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15503. */
  15504. emitFromSpawnPointOnly: boolean;
  15505. /**
  15506. * Gets or sets the radius of the emission cone
  15507. */
  15508. radius: number;
  15509. /**
  15510. * Gets or sets the angle of the emission cone
  15511. */
  15512. angle: number;
  15513. private _buildHeight;
  15514. /**
  15515. * Creates a new instance ConeParticleEmitter
  15516. * @param radius the radius of the emission cone (1 by default)
  15517. * @param angle the cone base angle (PI by default)
  15518. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15519. */
  15520. constructor(radius?: number, angle?: number,
  15521. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15522. directionRandomizer?: number);
  15523. /**
  15524. * Called by the particle System when the direction is computed for the created particle.
  15525. * @param worldMatrix is the world matrix of the particle system
  15526. * @param directionToUpdate is the direction vector to update with the result
  15527. * @param particle is the particle we are computed the direction for
  15528. */
  15529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15530. /**
  15531. * Called by the particle System when the position is computed for the created particle.
  15532. * @param worldMatrix is the world matrix of the particle system
  15533. * @param positionToUpdate is the position vector to update with the result
  15534. * @param particle is the particle we are computed the position for
  15535. */
  15536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15537. /**
  15538. * Clones the current emitter and returns a copy of it
  15539. * @returns the new emitter
  15540. */
  15541. clone(): ConeParticleEmitter;
  15542. /**
  15543. * Called by the GPUParticleSystem to setup the update shader
  15544. * @param effect defines the update shader
  15545. */
  15546. applyToShader(effect: Effect): void;
  15547. /**
  15548. * Returns a string to use to update the GPU particles update shader
  15549. * @returns a string containng the defines string
  15550. */
  15551. getEffectDefines(): string;
  15552. /**
  15553. * Returns the string "ConeParticleEmitter"
  15554. * @returns a string containing the class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Serializes the particle system to a JSON object.
  15559. * @returns the JSON object
  15560. */
  15561. serialize(): any;
  15562. /**
  15563. * Parse properties from a JSON object
  15564. * @param serializationObject defines the JSON object
  15565. */
  15566. parse(serializationObject: any): void;
  15567. }
  15568. }
  15569. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15570. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15571. import { Effect } from "babylonjs/Materials/effect";
  15572. import { Particle } from "babylonjs/Particles/particle";
  15573. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15574. /**
  15575. * Particle emitter emitting particles from the inside of a cylinder.
  15576. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15577. */
  15578. export class CylinderParticleEmitter implements IParticleEmitterType {
  15579. /**
  15580. * The radius of the emission cylinder.
  15581. */
  15582. radius: number;
  15583. /**
  15584. * The height of the emission cylinder.
  15585. */
  15586. height: number;
  15587. /**
  15588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15589. */
  15590. radiusRange: number;
  15591. /**
  15592. * How much to randomize the particle direction [0-1].
  15593. */
  15594. directionRandomizer: number;
  15595. /**
  15596. * Creates a new instance CylinderParticleEmitter
  15597. * @param radius the radius of the emission cylinder (1 by default)
  15598. * @param height the height of the emission cylinder (1 by default)
  15599. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15600. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15601. */
  15602. constructor(
  15603. /**
  15604. * The radius of the emission cylinder.
  15605. */
  15606. radius?: number,
  15607. /**
  15608. * The height of the emission cylinder.
  15609. */
  15610. height?: number,
  15611. /**
  15612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15613. */
  15614. radiusRange?: number,
  15615. /**
  15616. * How much to randomize the particle direction [0-1].
  15617. */
  15618. directionRandomizer?: number);
  15619. /**
  15620. * Called by the particle System when the direction is computed for the created particle.
  15621. * @param worldMatrix is the world matrix of the particle system
  15622. * @param directionToUpdate is the direction vector to update with the result
  15623. * @param particle is the particle we are computed the direction for
  15624. */
  15625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15626. /**
  15627. * Called by the particle System when the position is computed for the created particle.
  15628. * @param worldMatrix is the world matrix of the particle system
  15629. * @param positionToUpdate is the position vector to update with the result
  15630. * @param particle is the particle we are computed the position for
  15631. */
  15632. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15633. /**
  15634. * Clones the current emitter and returns a copy of it
  15635. * @returns the new emitter
  15636. */
  15637. clone(): CylinderParticleEmitter;
  15638. /**
  15639. * Called by the GPUParticleSystem to setup the update shader
  15640. * @param effect defines the update shader
  15641. */
  15642. applyToShader(effect: Effect): void;
  15643. /**
  15644. * Returns a string to use to update the GPU particles update shader
  15645. * @returns a string containng the defines string
  15646. */
  15647. getEffectDefines(): string;
  15648. /**
  15649. * Returns the string "CylinderParticleEmitter"
  15650. * @returns a string containing the class name
  15651. */
  15652. getClassName(): string;
  15653. /**
  15654. * Serializes the particle system to a JSON object.
  15655. * @returns the JSON object
  15656. */
  15657. serialize(): any;
  15658. /**
  15659. * Parse properties from a JSON object
  15660. * @param serializationObject defines the JSON object
  15661. */
  15662. parse(serializationObject: any): void;
  15663. }
  15664. /**
  15665. * Particle emitter emitting particles from the inside of a cylinder.
  15666. * It emits the particles randomly between two vectors.
  15667. */
  15668. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15669. /**
  15670. * The min limit of the emission direction.
  15671. */
  15672. direction1: Vector3;
  15673. /**
  15674. * The max limit of the emission direction.
  15675. */
  15676. direction2: Vector3;
  15677. /**
  15678. * Creates a new instance CylinderDirectedParticleEmitter
  15679. * @param radius the radius of the emission cylinder (1 by default)
  15680. * @param height the height of the emission cylinder (1 by default)
  15681. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15682. * @param direction1 the min limit of the emission direction (up vector by default)
  15683. * @param direction2 the max limit of the emission direction (up vector by default)
  15684. */
  15685. constructor(radius?: number, height?: number, radiusRange?: number,
  15686. /**
  15687. * The min limit of the emission direction.
  15688. */
  15689. direction1?: Vector3,
  15690. /**
  15691. * The max limit of the emission direction.
  15692. */
  15693. direction2?: Vector3);
  15694. /**
  15695. * Called by the particle System when the direction is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param directionToUpdate is the direction vector to update with the result
  15698. * @param particle is the particle we are computed the direction for
  15699. */
  15700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Clones the current emitter and returns a copy of it
  15703. * @returns the new emitter
  15704. */
  15705. clone(): CylinderDirectedParticleEmitter;
  15706. /**
  15707. * Called by the GPUParticleSystem to setup the update shader
  15708. * @param effect defines the update shader
  15709. */
  15710. applyToShader(effect: Effect): void;
  15711. /**
  15712. * Returns a string to use to update the GPU particles update shader
  15713. * @returns a string containng the defines string
  15714. */
  15715. getEffectDefines(): string;
  15716. /**
  15717. * Returns the string "CylinderDirectedParticleEmitter"
  15718. * @returns a string containing the class name
  15719. */
  15720. getClassName(): string;
  15721. /**
  15722. * Serializes the particle system to a JSON object.
  15723. * @returns the JSON object
  15724. */
  15725. serialize(): any;
  15726. /**
  15727. * Parse properties from a JSON object
  15728. * @param serializationObject defines the JSON object
  15729. */
  15730. parse(serializationObject: any): void;
  15731. }
  15732. }
  15733. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15734. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15735. import { Effect } from "babylonjs/Materials/effect";
  15736. import { Particle } from "babylonjs/Particles/particle";
  15737. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15738. /**
  15739. * Particle emitter emitting particles from the inside of a hemisphere.
  15740. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15741. */
  15742. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15743. /**
  15744. * The radius of the emission hemisphere.
  15745. */
  15746. radius: number;
  15747. /**
  15748. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15749. */
  15750. radiusRange: number;
  15751. /**
  15752. * How much to randomize the particle direction [0-1].
  15753. */
  15754. directionRandomizer: number;
  15755. /**
  15756. * Creates a new instance HemisphericParticleEmitter
  15757. * @param radius the radius of the emission hemisphere (1 by default)
  15758. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15759. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15760. */
  15761. constructor(
  15762. /**
  15763. * The radius of the emission hemisphere.
  15764. */
  15765. radius?: number,
  15766. /**
  15767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15768. */
  15769. radiusRange?: number,
  15770. /**
  15771. * How much to randomize the particle direction [0-1].
  15772. */
  15773. directionRandomizer?: number);
  15774. /**
  15775. * Called by the particle System when the direction is computed for the created particle.
  15776. * @param worldMatrix is the world matrix of the particle system
  15777. * @param directionToUpdate is the direction vector to update with the result
  15778. * @param particle is the particle we are computed the direction for
  15779. */
  15780. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15781. /**
  15782. * Called by the particle System when the position is computed for the created particle.
  15783. * @param worldMatrix is the world matrix of the particle system
  15784. * @param positionToUpdate is the position vector to update with the result
  15785. * @param particle is the particle we are computed the position for
  15786. */
  15787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15788. /**
  15789. * Clones the current emitter and returns a copy of it
  15790. * @returns the new emitter
  15791. */
  15792. clone(): HemisphericParticleEmitter;
  15793. /**
  15794. * Called by the GPUParticleSystem to setup the update shader
  15795. * @param effect defines the update shader
  15796. */
  15797. applyToShader(effect: Effect): void;
  15798. /**
  15799. * Returns a string to use to update the GPU particles update shader
  15800. * @returns a string containng the defines string
  15801. */
  15802. getEffectDefines(): string;
  15803. /**
  15804. * Returns the string "HemisphericParticleEmitter"
  15805. * @returns a string containing the class name
  15806. */
  15807. getClassName(): string;
  15808. /**
  15809. * Serializes the particle system to a JSON object.
  15810. * @returns the JSON object
  15811. */
  15812. serialize(): any;
  15813. /**
  15814. * Parse properties from a JSON object
  15815. * @param serializationObject defines the JSON object
  15816. */
  15817. parse(serializationObject: any): void;
  15818. }
  15819. }
  15820. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15821. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15822. import { Effect } from "babylonjs/Materials/effect";
  15823. import { Particle } from "babylonjs/Particles/particle";
  15824. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15825. /**
  15826. * Particle emitter emitting particles from a point.
  15827. * It emits the particles randomly between 2 given directions.
  15828. */
  15829. export class PointParticleEmitter implements IParticleEmitterType {
  15830. /**
  15831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15832. */
  15833. direction1: Vector3;
  15834. /**
  15835. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15836. */
  15837. direction2: Vector3;
  15838. /**
  15839. * Creates a new instance PointParticleEmitter
  15840. */
  15841. constructor();
  15842. /**
  15843. * Called by the particle System when the direction is computed for the created particle.
  15844. * @param worldMatrix is the world matrix of the particle system
  15845. * @param directionToUpdate is the direction vector to update with the result
  15846. * @param particle is the particle we are computed the direction for
  15847. */
  15848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15849. /**
  15850. * Called by the particle System when the position is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param positionToUpdate is the position vector to update with the result
  15853. * @param particle is the particle we are computed the position for
  15854. */
  15855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Clones the current emitter and returns a copy of it
  15858. * @returns the new emitter
  15859. */
  15860. clone(): PointParticleEmitter;
  15861. /**
  15862. * Called by the GPUParticleSystem to setup the update shader
  15863. * @param effect defines the update shader
  15864. */
  15865. applyToShader(effect: Effect): void;
  15866. /**
  15867. * Returns a string to use to update the GPU particles update shader
  15868. * @returns a string containng the defines string
  15869. */
  15870. getEffectDefines(): string;
  15871. /**
  15872. * Returns the string "PointParticleEmitter"
  15873. * @returns a string containing the class name
  15874. */
  15875. getClassName(): string;
  15876. /**
  15877. * Serializes the particle system to a JSON object.
  15878. * @returns the JSON object
  15879. */
  15880. serialize(): any;
  15881. /**
  15882. * Parse properties from a JSON object
  15883. * @param serializationObject defines the JSON object
  15884. */
  15885. parse(serializationObject: any): void;
  15886. }
  15887. }
  15888. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15889. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15890. import { Effect } from "babylonjs/Materials/effect";
  15891. import { Particle } from "babylonjs/Particles/particle";
  15892. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15893. /**
  15894. * Particle emitter emitting particles from the inside of a sphere.
  15895. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15896. */
  15897. export class SphereParticleEmitter implements IParticleEmitterType {
  15898. /**
  15899. * The radius of the emission sphere.
  15900. */
  15901. radius: number;
  15902. /**
  15903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15904. */
  15905. radiusRange: number;
  15906. /**
  15907. * How much to randomize the particle direction [0-1].
  15908. */
  15909. directionRandomizer: number;
  15910. /**
  15911. * Creates a new instance SphereParticleEmitter
  15912. * @param radius the radius of the emission sphere (1 by default)
  15913. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15914. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15915. */
  15916. constructor(
  15917. /**
  15918. * The radius of the emission sphere.
  15919. */
  15920. radius?: number,
  15921. /**
  15922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15923. */
  15924. radiusRange?: number,
  15925. /**
  15926. * How much to randomize the particle direction [0-1].
  15927. */
  15928. directionRandomizer?: number);
  15929. /**
  15930. * Called by the particle System when the direction is computed for the created particle.
  15931. * @param worldMatrix is the world matrix of the particle system
  15932. * @param directionToUpdate is the direction vector to update with the result
  15933. * @param particle is the particle we are computed the direction for
  15934. */
  15935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15936. /**
  15937. * Called by the particle System when the position is computed for the created particle.
  15938. * @param worldMatrix is the world matrix of the particle system
  15939. * @param positionToUpdate is the position vector to update with the result
  15940. * @param particle is the particle we are computed the position for
  15941. */
  15942. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15943. /**
  15944. * Clones the current emitter and returns a copy of it
  15945. * @returns the new emitter
  15946. */
  15947. clone(): SphereParticleEmitter;
  15948. /**
  15949. * Called by the GPUParticleSystem to setup the update shader
  15950. * @param effect defines the update shader
  15951. */
  15952. applyToShader(effect: Effect): void;
  15953. /**
  15954. * Returns a string to use to update the GPU particles update shader
  15955. * @returns a string containng the defines string
  15956. */
  15957. getEffectDefines(): string;
  15958. /**
  15959. * Returns the string "SphereParticleEmitter"
  15960. * @returns a string containing the class name
  15961. */
  15962. getClassName(): string;
  15963. /**
  15964. * Serializes the particle system to a JSON object.
  15965. * @returns the JSON object
  15966. */
  15967. serialize(): any;
  15968. /**
  15969. * Parse properties from a JSON object
  15970. * @param serializationObject defines the JSON object
  15971. */
  15972. parse(serializationObject: any): void;
  15973. }
  15974. /**
  15975. * Particle emitter emitting particles from the inside of a sphere.
  15976. * It emits the particles randomly between two vectors.
  15977. */
  15978. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15979. /**
  15980. * The min limit of the emission direction.
  15981. */
  15982. direction1: Vector3;
  15983. /**
  15984. * The max limit of the emission direction.
  15985. */
  15986. direction2: Vector3;
  15987. /**
  15988. * Creates a new instance SphereDirectedParticleEmitter
  15989. * @param radius the radius of the emission sphere (1 by default)
  15990. * @param direction1 the min limit of the emission direction (up vector by default)
  15991. * @param direction2 the max limit of the emission direction (up vector by default)
  15992. */
  15993. constructor(radius?: number,
  15994. /**
  15995. * The min limit of the emission direction.
  15996. */
  15997. direction1?: Vector3,
  15998. /**
  15999. * The max limit of the emission direction.
  16000. */
  16001. direction2?: Vector3);
  16002. /**
  16003. * Called by the particle System when the direction is computed for the created particle.
  16004. * @param worldMatrix is the world matrix of the particle system
  16005. * @param directionToUpdate is the direction vector to update with the result
  16006. * @param particle is the particle we are computed the direction for
  16007. */
  16008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16009. /**
  16010. * Clones the current emitter and returns a copy of it
  16011. * @returns the new emitter
  16012. */
  16013. clone(): SphereDirectedParticleEmitter;
  16014. /**
  16015. * Called by the GPUParticleSystem to setup the update shader
  16016. * @param effect defines the update shader
  16017. */
  16018. applyToShader(effect: Effect): void;
  16019. /**
  16020. * Returns a string to use to update the GPU particles update shader
  16021. * @returns a string containng the defines string
  16022. */
  16023. getEffectDefines(): string;
  16024. /**
  16025. * Returns the string "SphereDirectedParticleEmitter"
  16026. * @returns a string containing the class name
  16027. */
  16028. getClassName(): string;
  16029. /**
  16030. * Serializes the particle system to a JSON object.
  16031. * @returns the JSON object
  16032. */
  16033. serialize(): any;
  16034. /**
  16035. * Parse properties from a JSON object
  16036. * @param serializationObject defines the JSON object
  16037. */
  16038. parse(serializationObject: any): void;
  16039. }
  16040. }
  16041. declare module "babylonjs/Particles/EmitterTypes/index" {
  16042. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16043. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16044. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16045. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16046. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16047. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16048. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16049. }
  16050. declare module "babylonjs/Particles/IParticleSystem" {
  16051. import { Nullable } from "babylonjs/types";
  16052. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16055. import { Texture } from "babylonjs/Materials/Textures/texture";
  16056. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16057. import { Scene } from "babylonjs/scene";
  16058. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16059. import { Animation } from "babylonjs/Animations/animation";
  16060. /**
  16061. * Interface representing a particle system in Babylon.js.
  16062. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16063. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16064. */
  16065. export interface IParticleSystem {
  16066. /**
  16067. * List of animations used by the particle system.
  16068. */
  16069. animations: Animation[];
  16070. /**
  16071. * The id of the Particle system.
  16072. */
  16073. id: string;
  16074. /**
  16075. * The name of the Particle system.
  16076. */
  16077. name: string;
  16078. /**
  16079. * The emitter represents the Mesh or position we are attaching the particle system to.
  16080. */
  16081. emitter: Nullable<AbstractMesh | Vector3>;
  16082. /**
  16083. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16084. */
  16085. isBillboardBased: boolean;
  16086. /**
  16087. * The rendering group used by the Particle system to chose when to render.
  16088. */
  16089. renderingGroupId: number;
  16090. /**
  16091. * The layer mask we are rendering the particles through.
  16092. */
  16093. layerMask: number;
  16094. /**
  16095. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16096. */
  16097. updateSpeed: number;
  16098. /**
  16099. * The amount of time the particle system is running (depends of the overall update speed).
  16100. */
  16101. targetStopDuration: number;
  16102. /**
  16103. * The texture used to render each particle. (this can be a spritesheet)
  16104. */
  16105. particleTexture: Nullable<Texture>;
  16106. /**
  16107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16108. */
  16109. blendMode: number;
  16110. /**
  16111. * Minimum life time of emitting particles.
  16112. */
  16113. minLifeTime: number;
  16114. /**
  16115. * Maximum life time of emitting particles.
  16116. */
  16117. maxLifeTime: number;
  16118. /**
  16119. * Minimum Size of emitting particles.
  16120. */
  16121. minSize: number;
  16122. /**
  16123. * Maximum Size of emitting particles.
  16124. */
  16125. maxSize: number;
  16126. /**
  16127. * Minimum scale of emitting particles on X axis.
  16128. */
  16129. minScaleX: number;
  16130. /**
  16131. * Maximum scale of emitting particles on X axis.
  16132. */
  16133. maxScaleX: number;
  16134. /**
  16135. * Minimum scale of emitting particles on Y axis.
  16136. */
  16137. minScaleY: number;
  16138. /**
  16139. * Maximum scale of emitting particles on Y axis.
  16140. */
  16141. maxScaleY: number;
  16142. /**
  16143. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16144. */
  16145. color1: Color4;
  16146. /**
  16147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16148. */
  16149. color2: Color4;
  16150. /**
  16151. * Color the particle will have at the end of its lifetime.
  16152. */
  16153. colorDead: Color4;
  16154. /**
  16155. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16156. */
  16157. emitRate: number;
  16158. /**
  16159. * You can use gravity if you want to give an orientation to your particles.
  16160. */
  16161. gravity: Vector3;
  16162. /**
  16163. * Minimum power of emitting particles.
  16164. */
  16165. minEmitPower: number;
  16166. /**
  16167. * Maximum power of emitting particles.
  16168. */
  16169. maxEmitPower: number;
  16170. /**
  16171. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16172. */
  16173. minAngularSpeed: number;
  16174. /**
  16175. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16176. */
  16177. maxAngularSpeed: number;
  16178. /**
  16179. * Gets or sets the minimal initial rotation in radians.
  16180. */
  16181. minInitialRotation: number;
  16182. /**
  16183. * Gets or sets the maximal initial rotation in radians.
  16184. */
  16185. maxInitialRotation: number;
  16186. /**
  16187. * The particle emitter type defines the emitter used by the particle system.
  16188. * It can be for example box, sphere, or cone...
  16189. */
  16190. particleEmitterType: Nullable<IParticleEmitterType>;
  16191. /**
  16192. * Defines the delay in milliseconds before starting the system (0 by default)
  16193. */
  16194. startDelay: number;
  16195. /**
  16196. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  16197. */
  16198. preWarmCycles: number;
  16199. /**
  16200. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16201. */
  16202. preWarmStepOffset: number;
  16203. /**
  16204. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16205. */
  16206. spriteCellChangeSpeed: number;
  16207. /**
  16208. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16209. */
  16210. startSpriteCellID: number;
  16211. /**
  16212. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16213. */
  16214. endSpriteCellID: number;
  16215. /**
  16216. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16217. */
  16218. spriteCellWidth: number;
  16219. /**
  16220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16221. */
  16222. spriteCellHeight: number;
  16223. /**
  16224. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16225. */
  16226. spriteRandomStartCell: boolean;
  16227. /**
  16228. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16229. */
  16230. isAnimationSheetEnabled: boolean;
  16231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16232. translationPivot: Vector2;
  16233. /**
  16234. * Gets or sets a texture used to add random noise to particle positions
  16235. */
  16236. noiseTexture: Nullable<BaseTexture>;
  16237. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16238. noiseStrength: Vector3;
  16239. /**
  16240. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16241. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16242. */
  16243. billboardMode: number;
  16244. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16245. limitVelocityDamping: number;
  16246. /**
  16247. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16248. */
  16249. beginAnimationOnStart: boolean;
  16250. /**
  16251. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16252. */
  16253. beginAnimationFrom: number;
  16254. /**
  16255. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16256. */
  16257. beginAnimationTo: number;
  16258. /**
  16259. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16260. */
  16261. beginAnimationLoop: boolean;
  16262. /**
  16263. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16264. */
  16265. disposeOnStop: boolean;
  16266. /**
  16267. * Gets the maximum number of particles active at the same time.
  16268. * @returns The max number of active particles.
  16269. */
  16270. getCapacity(): number;
  16271. /**
  16272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16273. * @returns True if it has been started, otherwise false.
  16274. */
  16275. isStarted(): boolean;
  16276. /**
  16277. * Animates the particle system for this frame.
  16278. */
  16279. animate(): void;
  16280. /**
  16281. * Renders the particle system in its current state.
  16282. * @returns the current number of particles
  16283. */
  16284. render(): number;
  16285. /**
  16286. * Dispose the particle system and frees its associated resources.
  16287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16288. */
  16289. dispose(disposeTexture?: boolean): void;
  16290. /**
  16291. * Clones the particle system.
  16292. * @param name The name of the cloned object
  16293. * @param newEmitter The new emitter to use
  16294. * @returns the cloned particle system
  16295. */
  16296. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16297. /**
  16298. * Serializes the particle system to a JSON object.
  16299. * @returns the JSON object
  16300. */
  16301. serialize(): any;
  16302. /**
  16303. * Rebuild the particle system
  16304. */
  16305. rebuild(): void;
  16306. /**
  16307. * Starts the particle system and begins to emit
  16308. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. start(delay?: number): void;
  16311. /**
  16312. * Stops the particle system.
  16313. */
  16314. stop(): void;
  16315. /**
  16316. * Remove all active particles
  16317. */
  16318. reset(): void;
  16319. /**
  16320. * Is this system ready to be used/rendered
  16321. * @return true if the system is ready
  16322. */
  16323. isReady(): boolean;
  16324. /**
  16325. * Adds a new color gradient
  16326. * @param gradient defines the gradient to use (between 0 and 1)
  16327. * @param color1 defines the color to affect to the specified gradient
  16328. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16329. * @returns the current particle system
  16330. */
  16331. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16332. /**
  16333. * Remove a specific color gradient
  16334. * @param gradient defines the gradient to remove
  16335. * @returns the current particle system
  16336. */
  16337. removeColorGradient(gradient: number): IParticleSystem;
  16338. /**
  16339. * Adds a new size gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the size factor to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific size gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeSizeGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Gets the current list of color gradients.
  16354. * You must use addColorGradient and removeColorGradient to udpate this list
  16355. * @returns the list of color gradients
  16356. */
  16357. getColorGradients(): Nullable<Array<ColorGradient>>;
  16358. /**
  16359. * Gets the current list of size gradients.
  16360. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16361. * @returns the list of size gradients
  16362. */
  16363. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Gets the current list of angular speed gradients.
  16366. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16367. * @returns the list of angular speed gradients
  16368. */
  16369. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16370. /**
  16371. * Adds a new angular speed gradient
  16372. * @param gradient defines the gradient to use (between 0 and 1)
  16373. * @param factor defines the angular speed to affect to the specified gradient
  16374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16375. * @returns the current particle system
  16376. */
  16377. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16378. /**
  16379. * Remove a specific angular speed gradient
  16380. * @param gradient defines the gradient to remove
  16381. * @returns the current particle system
  16382. */
  16383. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16384. /**
  16385. * Gets the current list of velocity gradients.
  16386. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16387. * @returns the list of velocity gradients
  16388. */
  16389. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Adds a new velocity gradient
  16392. * @param gradient defines the gradient to use (between 0 and 1)
  16393. * @param factor defines the velocity to affect to the specified gradient
  16394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16395. * @returns the current particle system
  16396. */
  16397. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16398. /**
  16399. * Remove a specific velocity gradient
  16400. * @param gradient defines the gradient to remove
  16401. * @returns the current particle system
  16402. */
  16403. removeVelocityGradient(gradient: number): IParticleSystem;
  16404. /**
  16405. * Gets the current list of limit velocity gradients.
  16406. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16407. * @returns the list of limit velocity gradients
  16408. */
  16409. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16410. /**
  16411. * Adds a new limit velocity gradient
  16412. * @param gradient defines the gradient to use (between 0 and 1)
  16413. * @param factor defines the limit velocity to affect to the specified gradient
  16414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16415. * @returns the current particle system
  16416. */
  16417. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16418. /**
  16419. * Remove a specific limit velocity gradient
  16420. * @param gradient defines the gradient to remove
  16421. * @returns the current particle system
  16422. */
  16423. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16424. /**
  16425. * Adds a new drag gradient
  16426. * @param gradient defines the gradient to use (between 0 and 1)
  16427. * @param factor defines the drag to affect to the specified gradient
  16428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16429. * @returns the current particle system
  16430. */
  16431. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16432. /**
  16433. * Remove a specific drag gradient
  16434. * @param gradient defines the gradient to remove
  16435. * @returns the current particle system
  16436. */
  16437. removeDragGradient(gradient: number): IParticleSystem;
  16438. /**
  16439. * Gets the current list of drag gradients.
  16440. * You must use addDragGradient and removeDragGradient to udpate this list
  16441. * @returns the list of drag gradients
  16442. */
  16443. getDragGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16446. * @param gradient defines the gradient to use (between 0 and 1)
  16447. * @param factor defines the emit rate to affect to the specified gradient
  16448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16449. * @returns the current particle system
  16450. */
  16451. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16452. /**
  16453. * Remove a specific emit rate gradient
  16454. * @param gradient defines the gradient to remove
  16455. * @returns the current particle system
  16456. */
  16457. removeEmitRateGradient(gradient: number): IParticleSystem;
  16458. /**
  16459. * Gets the current list of emit rate gradients.
  16460. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16461. * @returns the list of emit rate gradients
  16462. */
  16463. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16466. * @param gradient defines the gradient to use (between 0 and 1)
  16467. * @param factor defines the start size to affect to the specified gradient
  16468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16469. * @returns the current particle system
  16470. */
  16471. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16472. /**
  16473. * Remove a specific start size gradient
  16474. * @param gradient defines the gradient to remove
  16475. * @returns the current particle system
  16476. */
  16477. removeStartSizeGradient(gradient: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of start size gradients.
  16480. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16481. * @returns the list of start size gradients
  16482. */
  16483. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Adds a new life time gradient
  16486. * @param gradient defines the gradient to use (between 0 and 1)
  16487. * @param factor defines the life time factor to affect to the specified gradient
  16488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16489. * @returns the current particle system
  16490. */
  16491. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16492. /**
  16493. * Remove a specific life time gradient
  16494. * @param gradient defines the gradient to remove
  16495. * @returns the current particle system
  16496. */
  16497. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of life time gradients.
  16500. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16501. * @returns the list of life time gradients
  16502. */
  16503. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of color gradients.
  16506. * You must use addColorGradient and removeColorGradient to udpate this list
  16507. * @returns the list of color gradients
  16508. */
  16509. getColorGradients(): Nullable<Array<ColorGradient>>;
  16510. /**
  16511. * Adds a new ramp gradient used to remap particle colors
  16512. * @param gradient defines the gradient to use (between 0 and 1)
  16513. * @param color defines the color to affect to the specified gradient
  16514. * @returns the current particle system
  16515. */
  16516. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16517. /**
  16518. * Gets the current list of ramp gradients.
  16519. * You must use addRampGradient and removeRampGradient to udpate this list
  16520. * @returns the list of ramp gradients
  16521. */
  16522. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16523. /** Gets or sets a boolean indicating that ramp gradients must be used
  16524. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16525. */
  16526. useRampGradients: boolean;
  16527. /**
  16528. * Adds a new color remap gradient
  16529. * @param gradient defines the gradient to use (between 0 and 1)
  16530. * @param min defines the color remap minimal range
  16531. * @param max defines the color remap maximal range
  16532. * @returns the current particle system
  16533. */
  16534. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16535. /**
  16536. * Gets the current list of color remap gradients.
  16537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16538. * @returns the list of color remap gradients
  16539. */
  16540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16541. /**
  16542. * Adds a new alpha remap gradient
  16543. * @param gradient defines the gradient to use (between 0 and 1)
  16544. * @param min defines the alpha remap minimal range
  16545. * @param max defines the alpha remap maximal range
  16546. * @returns the current particle system
  16547. */
  16548. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16549. /**
  16550. * Gets the current list of alpha remap gradients.
  16551. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16552. * @returns the list of alpha remap gradients
  16553. */
  16554. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16555. /**
  16556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16559. * @returns the emitter
  16560. */
  16561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16562. /**
  16563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16564. * @param radius The radius of the hemisphere to emit from
  16565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16566. * @returns the emitter
  16567. */
  16568. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16569. /**
  16570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16571. * @param radius The radius of the sphere to emit from
  16572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16573. * @returns the emitter
  16574. */
  16575. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16576. /**
  16577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16578. * @param radius The radius of the sphere to emit from
  16579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16581. * @returns the emitter
  16582. */
  16583. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16584. /**
  16585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16586. * @param radius The radius of the emission cylinder
  16587. * @param height The height of the emission cylinder
  16588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16590. * @returns the emitter
  16591. */
  16592. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16593. /**
  16594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16595. * @param radius The radius of the cylinder to emit from
  16596. * @param height The height of the emission cylinder
  16597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16600. * @returns the emitter
  16601. */
  16602. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16603. /**
  16604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16605. * @param radius The radius of the cone to emit from
  16606. * @param angle The base angle of the cone
  16607. * @returns the emitter
  16608. */
  16609. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16610. /**
  16611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16616. * @returns the emitter
  16617. */
  16618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16619. /**
  16620. * Get hosting scene
  16621. * @returns the scene
  16622. */
  16623. getScene(): Scene;
  16624. }
  16625. }
  16626. declare module "babylonjs/Meshes/instancedMesh" {
  16627. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16628. import { Vector3 } from "babylonjs/Maths/math";
  16629. import { Camera } from "babylonjs/Cameras/camera";
  16630. import { Node } from "babylonjs/node";
  16631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16632. import { Mesh } from "babylonjs/Meshes/mesh";
  16633. import { Material } from "babylonjs/Materials/material";
  16634. import { Skeleton } from "babylonjs/Bones/skeleton";
  16635. /**
  16636. * Creates an instance based on a source mesh.
  16637. */
  16638. export class InstancedMesh extends AbstractMesh {
  16639. private _sourceMesh;
  16640. private _currentLOD;
  16641. /** @hidden */
  16642. _indexInSourceMeshInstanceArray: number;
  16643. constructor(name: string, source: Mesh);
  16644. /**
  16645. * Returns the string "InstancedMesh".
  16646. */
  16647. getClassName(): string;
  16648. /**
  16649. * If the source mesh receives shadows
  16650. */
  16651. readonly receiveShadows: boolean;
  16652. /**
  16653. * The material of the source mesh
  16654. */
  16655. readonly material: Nullable<Material>;
  16656. /**
  16657. * Visibility of the source mesh
  16658. */
  16659. readonly visibility: number;
  16660. /**
  16661. * Skeleton of the source mesh
  16662. */
  16663. readonly skeleton: Nullable<Skeleton>;
  16664. /**
  16665. * Rendering ground id of the source mesh
  16666. */
  16667. renderingGroupId: number;
  16668. /**
  16669. * Returns the total number of vertices (integer).
  16670. */
  16671. getTotalVertices(): number;
  16672. /**
  16673. * Returns a positive integer : the total number of indices in this mesh geometry.
  16674. * @returns the numner of indices or zero if the mesh has no geometry.
  16675. */
  16676. getTotalIndices(): number;
  16677. /**
  16678. * The source mesh of the instance
  16679. */
  16680. readonly sourceMesh: Mesh;
  16681. /**
  16682. * Is this node ready to be used/rendered
  16683. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16684. * @return {boolean} is it ready
  16685. */
  16686. isReady(completeCheck?: boolean): boolean;
  16687. /**
  16688. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16689. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16690. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16691. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16692. */
  16693. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16694. /**
  16695. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16696. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16697. * The `data` are either a numeric array either a Float32Array.
  16698. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16699. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16700. * Note that a new underlying VertexBuffer object is created each call.
  16701. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16702. *
  16703. * Possible `kind` values :
  16704. * - VertexBuffer.PositionKind
  16705. * - VertexBuffer.UVKind
  16706. * - VertexBuffer.UV2Kind
  16707. * - VertexBuffer.UV3Kind
  16708. * - VertexBuffer.UV4Kind
  16709. * - VertexBuffer.UV5Kind
  16710. * - VertexBuffer.UV6Kind
  16711. * - VertexBuffer.ColorKind
  16712. * - VertexBuffer.MatricesIndicesKind
  16713. * - VertexBuffer.MatricesIndicesExtraKind
  16714. * - VertexBuffer.MatricesWeightsKind
  16715. * - VertexBuffer.MatricesWeightsExtraKind
  16716. *
  16717. * Returns the Mesh.
  16718. */
  16719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16720. /**
  16721. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16722. * If the mesh has no geometry, it is simply returned as it is.
  16723. * The `data` are either a numeric array either a Float32Array.
  16724. * No new underlying VertexBuffer object is created.
  16725. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16726. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16727. *
  16728. * Possible `kind` values :
  16729. * - VertexBuffer.PositionKind
  16730. * - VertexBuffer.UVKind
  16731. * - VertexBuffer.UV2Kind
  16732. * - VertexBuffer.UV3Kind
  16733. * - VertexBuffer.UV4Kind
  16734. * - VertexBuffer.UV5Kind
  16735. * - VertexBuffer.UV6Kind
  16736. * - VertexBuffer.ColorKind
  16737. * - VertexBuffer.MatricesIndicesKind
  16738. * - VertexBuffer.MatricesIndicesExtraKind
  16739. * - VertexBuffer.MatricesWeightsKind
  16740. * - VertexBuffer.MatricesWeightsExtraKind
  16741. *
  16742. * Returns the Mesh.
  16743. */
  16744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16745. /**
  16746. * Sets the mesh indices.
  16747. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16748. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16749. * This method creates a new index buffer each call.
  16750. * Returns the Mesh.
  16751. */
  16752. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16753. /**
  16754. * Boolean : True if the mesh owns the requested kind of data.
  16755. */
  16756. isVerticesDataPresent(kind: string): boolean;
  16757. /**
  16758. * Returns an array of indices (IndicesArray).
  16759. */
  16760. getIndices(): Nullable<IndicesArray>;
  16761. readonly _positions: Nullable<Vector3[]>;
  16762. /**
  16763. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16764. * This means the mesh underlying bounding box and sphere are recomputed.
  16765. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16766. * @returns the current mesh
  16767. */
  16768. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16769. /** @hidden */
  16770. _preActivate(): InstancedMesh;
  16771. /** @hidden */
  16772. _activate(renderId: number): InstancedMesh;
  16773. /**
  16774. * Returns the current associated LOD AbstractMesh.
  16775. */
  16776. getLOD(camera: Camera): AbstractMesh;
  16777. /** @hidden */
  16778. _syncSubMeshes(): InstancedMesh;
  16779. /** @hidden */
  16780. _generatePointsArray(): boolean;
  16781. /**
  16782. * Creates a new InstancedMesh from the current mesh.
  16783. * - name (string) : the cloned mesh name
  16784. * - newParent (optional Node) : the optional Node to parent the clone to.
  16785. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16786. *
  16787. * Returns the clone.
  16788. */
  16789. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16790. /**
  16791. * Disposes the InstancedMesh.
  16792. * Returns nothing.
  16793. */
  16794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16795. }
  16796. }
  16797. declare module "babylonjs/Materials/shaderMaterial" {
  16798. import { Scene } from "babylonjs/scene";
  16799. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16801. import { Mesh } from "babylonjs/Meshes/mesh";
  16802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16803. import { Texture } from "babylonjs/Materials/Textures/texture";
  16804. import { Material } from "babylonjs/Materials/material";
  16805. /**
  16806. * Defines the options associated with the creation of a shader material.
  16807. */
  16808. export interface IShaderMaterialOptions {
  16809. /**
  16810. * Does the material work in alpha blend mode
  16811. */
  16812. needAlphaBlending: boolean;
  16813. /**
  16814. * Does the material work in alpha test mode
  16815. */
  16816. needAlphaTesting: boolean;
  16817. /**
  16818. * The list of attribute names used in the shader
  16819. */
  16820. attributes: string[];
  16821. /**
  16822. * The list of unifrom names used in the shader
  16823. */
  16824. uniforms: string[];
  16825. /**
  16826. * The list of UBO names used in the shader
  16827. */
  16828. uniformBuffers: string[];
  16829. /**
  16830. * The list of sampler names used in the shader
  16831. */
  16832. samplers: string[];
  16833. /**
  16834. * The list of defines used in the shader
  16835. */
  16836. defines: string[];
  16837. }
  16838. /**
  16839. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16840. *
  16841. * This returned material effects how the mesh will look based on the code in the shaders.
  16842. *
  16843. * @see http://doc.babylonjs.com/how_to/shader_material
  16844. */
  16845. export class ShaderMaterial extends Material {
  16846. private _shaderPath;
  16847. private _options;
  16848. private _textures;
  16849. private _textureArrays;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors3Arrays;
  16855. private _colors4;
  16856. private _vectors2;
  16857. private _vectors3;
  16858. private _vectors4;
  16859. private _matrices;
  16860. private _matrices3x3;
  16861. private _matrices2x2;
  16862. private _vectors2Arrays;
  16863. private _vectors3Arrays;
  16864. private _cachedWorldViewMatrix;
  16865. private _renderId;
  16866. /**
  16867. * Instantiate a new shader material.
  16868. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16869. * This returned material effects how the mesh will look based on the code in the shaders.
  16870. * @see http://doc.babylonjs.com/how_to/shader_material
  16871. * @param name Define the name of the material in the scene
  16872. * @param scene Define the scene the material belongs to
  16873. * @param shaderPath Defines the route to the shader code in one of three ways:
  16874. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16875. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16876. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16877. * @param options Define the options used to create the shader
  16878. */
  16879. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16880. /**
  16881. * Gets the options used to compile the shader.
  16882. * They can be modified to trigger a new compilation
  16883. */
  16884. readonly options: IShaderMaterialOptions;
  16885. /**
  16886. * Gets the current class name of the material e.g. "ShaderMaterial"
  16887. * Mainly use in serialization.
  16888. * @returns the class name
  16889. */
  16890. getClassName(): string;
  16891. /**
  16892. * Specifies if the material will require alpha blending
  16893. * @returns a boolean specifying if alpha blending is needed
  16894. */
  16895. needAlphaBlending(): boolean;
  16896. /**
  16897. * Specifies if this material should be rendered in alpha test mode
  16898. * @returns a boolean specifying if an alpha test is needed.
  16899. */
  16900. needAlphaTesting(): boolean;
  16901. private _checkUniform;
  16902. /**
  16903. * Set a texture in the shader.
  16904. * @param name Define the name of the uniform samplers as defined in the shader
  16905. * @param texture Define the texture to bind to this sampler
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setTexture(name: string, texture: Texture): ShaderMaterial;
  16909. /**
  16910. * Set a texture array in the shader.
  16911. * @param name Define the name of the uniform sampler array as defined in the shader
  16912. * @param textures Define the list of textures to bind to this sampler
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16916. /**
  16917. * Set a float in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloat(name: string, value: number): ShaderMaterial;
  16923. /**
  16924. * Set a int in the shader.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setInt(name: string, value: number): ShaderMaterial;
  16930. /**
  16931. * Set an array of floats in the shader.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setFloats(name: string, value: number[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec3 in the shader from a Color3.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor3(name: string, value: Color3): ShaderMaterial;
  16944. /**
  16945. * Set a vec3 array in the shader from a Color3 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec4 in the shader from a Color4.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setColor4(name: string, value: Color4): ShaderMaterial;
  16958. /**
  16959. * Set a vec2 in the shader from a Vector2.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector2(name: string, value: Vector2): ShaderMaterial;
  16965. /**
  16966. * Set a vec3 in the shader from a Vector3.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector3(name: string, value: Vector3): ShaderMaterial;
  16972. /**
  16973. * Set a vec4 in the shader from a Vector4.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setVector4(name: string, value: Vector4): ShaderMaterial;
  16979. /**
  16980. * Set a mat4 in the shader from a Matrix.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. private _checkCache;
  17015. /**
  17016. * Checks if the material is ready to render the requested mesh
  17017. * @param mesh Define the mesh to render
  17018. * @param useInstances Define whether or not the material is used with instances
  17019. * @returns true if ready, otherwise false
  17020. */
  17021. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17022. /**
  17023. * Binds the world matrix to the material
  17024. * @param world defines the world transformation matrix
  17025. */
  17026. bindOnlyWorldMatrix(world: Matrix): void;
  17027. /**
  17028. * Binds the material to the mesh
  17029. * @param world defines the world transformation matrix
  17030. * @param mesh defines the mesh to bind the material to
  17031. */
  17032. bind(world: Matrix, mesh?: Mesh): void;
  17033. /**
  17034. * Gets the active textures from the material
  17035. * @returns an array of textures
  17036. */
  17037. getActiveTextures(): BaseTexture[];
  17038. /**
  17039. * Specifies if the material uses a texture
  17040. * @param texture defines the texture to check against the material
  17041. * @returns a boolean specifying if the material uses the texture
  17042. */
  17043. hasTexture(texture: BaseTexture): boolean;
  17044. /**
  17045. * Makes a duplicate of the material, and gives it a new name
  17046. * @param name defines the new name for the duplicated material
  17047. * @returns the cloned material
  17048. */
  17049. clone(name: string): ShaderMaterial;
  17050. /**
  17051. * Disposes the material
  17052. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17053. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17054. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17055. */
  17056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17057. /**
  17058. * Serializes this material in a JSON representation
  17059. * @returns the serialized material object
  17060. */
  17061. serialize(): any;
  17062. /**
  17063. * Creates a shader material from parsed shader material data
  17064. * @param source defines the JSON represnetation of the material
  17065. * @param scene defines the hosting scene
  17066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17067. * @returns a new material
  17068. */
  17069. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17070. }
  17071. }
  17072. declare module "babylonjs/Shaders/color.fragment" {
  17073. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17075. /** @hidden */
  17076. export var colorPixelShader: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module "babylonjs/Shaders/color.vertex" {
  17082. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17083. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17084. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17085. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17086. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17088. /** @hidden */
  17089. export var colorVertexShader: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Meshes/linesMesh" {
  17095. import { Nullable } from "babylonjs/types";
  17096. import { Scene } from "babylonjs/scene";
  17097. import { Color3 } from "babylonjs/Maths/math";
  17098. import { Node } from "babylonjs/node";
  17099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17100. import { Mesh } from "babylonjs/Meshes/mesh";
  17101. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17102. import { Effect } from "babylonjs/Materials/effect";
  17103. import { Material } from "babylonjs/Materials/material";
  17104. import "babylonjs/Shaders/color.fragment";
  17105. import "babylonjs/Shaders/color.vertex";
  17106. /**
  17107. * Line mesh
  17108. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17109. */
  17110. export class LinesMesh extends Mesh {
  17111. /**
  17112. * If vertex color should be applied to the mesh
  17113. */
  17114. useVertexColor?: boolean | undefined;
  17115. /**
  17116. * If vertex alpha should be applied to the mesh
  17117. */
  17118. useVertexAlpha?: boolean | undefined;
  17119. /**
  17120. * Color of the line (Default: White)
  17121. */
  17122. color: Color3;
  17123. /**
  17124. * Alpha of the line (Default: 1)
  17125. */
  17126. alpha: number;
  17127. /**
  17128. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17129. * This margin is expressed in world space coordinates, so its value may vary.
  17130. * Default value is 0.1
  17131. */
  17132. intersectionThreshold: number;
  17133. private _colorShader;
  17134. /**
  17135. * Creates a new LinesMesh
  17136. * @param name defines the name
  17137. * @param scene defines the hosting scene
  17138. * @param parent defines the parent mesh if any
  17139. * @param source defines the optional source LinesMesh used to clone data from
  17140. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17141. * When false, achieved by calling a clone(), also passing False.
  17142. * This will make creation of children, recursive.
  17143. * @param useVertexColor defines if this LinesMesh supports vertex color
  17144. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17145. */
  17146. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17147. /**
  17148. * If vertex color should be applied to the mesh
  17149. */
  17150. useVertexColor?: boolean | undefined,
  17151. /**
  17152. * If vertex alpha should be applied to the mesh
  17153. */
  17154. useVertexAlpha?: boolean | undefined);
  17155. private _addClipPlaneDefine;
  17156. private _removeClipPlaneDefine;
  17157. isReady(): boolean;
  17158. /**
  17159. * Returns the string "LineMesh"
  17160. */
  17161. getClassName(): string;
  17162. /**
  17163. * @hidden
  17164. */
  17165. /**
  17166. * @hidden
  17167. */
  17168. material: Material;
  17169. /**
  17170. * @hidden
  17171. */
  17172. readonly checkCollisions: boolean;
  17173. /** @hidden */
  17174. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17175. /** @hidden */
  17176. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17177. /**
  17178. * Disposes of the line mesh
  17179. * @param doNotRecurse If children should be disposed
  17180. */
  17181. dispose(doNotRecurse?: boolean): void;
  17182. /**
  17183. * Returns a new LineMesh object cloned from the current one.
  17184. */
  17185. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17186. /**
  17187. * Creates a new InstancedLinesMesh object from the mesh model.
  17188. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17189. * @param name defines the name of the new instance
  17190. * @returns a new InstancedLinesMesh
  17191. */
  17192. createInstance(name: string): InstancedLinesMesh;
  17193. }
  17194. /**
  17195. * Creates an instance based on a source LinesMesh
  17196. */
  17197. export class InstancedLinesMesh extends InstancedMesh {
  17198. /**
  17199. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17200. * This margin is expressed in world space coordinates, so its value may vary.
  17201. * Initilized with the intersectionThreshold value of the source LinesMesh
  17202. */
  17203. intersectionThreshold: number;
  17204. constructor(name: string, source: LinesMesh);
  17205. /**
  17206. * Returns the string "InstancedLinesMesh".
  17207. */
  17208. getClassName(): string;
  17209. }
  17210. }
  17211. declare module "babylonjs/Shaders/line.fragment" {
  17212. /** @hidden */
  17213. export var linePixelShader: {
  17214. name: string;
  17215. shader: string;
  17216. };
  17217. }
  17218. declare module "babylonjs/Shaders/line.vertex" {
  17219. /** @hidden */
  17220. export var lineVertexShader: {
  17221. name: string;
  17222. shader: string;
  17223. };
  17224. }
  17225. declare module "babylonjs/Rendering/edgesRenderer" {
  17226. import { Nullable } from "babylonjs/types";
  17227. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17229. import { Vector3 } from "babylonjs/Maths/math";
  17230. import { IDisposable } from "babylonjs/scene";
  17231. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17232. import "babylonjs/Shaders/line.fragment";
  17233. import "babylonjs/Shaders/line.vertex";
  17234. module "babylonjs/Meshes/abstractMesh" {
  17235. interface AbstractMesh {
  17236. /**
  17237. * Disables the mesh edge rendering mode
  17238. * @returns the currentAbstractMesh
  17239. */
  17240. disableEdgesRendering(): AbstractMesh;
  17241. /**
  17242. * Enables the edge rendering mode on the mesh.
  17243. * This mode makes the mesh edges visible
  17244. * @param epsilon defines the maximal distance between two angles to detect a face
  17245. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17246. * @returns the currentAbstractMesh
  17247. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17248. */
  17249. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17250. /**
  17251. * Gets the edgesRenderer associated with the mesh
  17252. */
  17253. edgesRenderer: Nullable<EdgesRenderer>;
  17254. }
  17255. }
  17256. module "babylonjs/Meshes/linesMesh" {
  17257. interface LinesMesh {
  17258. /**
  17259. * Enables the edge rendering mode on the mesh.
  17260. * This mode makes the mesh edges visible
  17261. * @param epsilon defines the maximal distance between two angles to detect a face
  17262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17263. * @returns the currentAbstractMesh
  17264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17265. */
  17266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17267. }
  17268. }
  17269. module "babylonjs/Meshes/linesMesh" {
  17270. interface InstancedLinesMesh {
  17271. /**
  17272. * Enables the edge rendering mode on the mesh.
  17273. * This mode makes the mesh edges visible
  17274. * @param epsilon defines the maximal distance between two angles to detect a face
  17275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17276. * @returns the current InstancedLinesMesh
  17277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17278. */
  17279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17280. }
  17281. }
  17282. /**
  17283. * Defines the minimum contract an Edges renderer should follow.
  17284. */
  17285. export interface IEdgesRenderer extends IDisposable {
  17286. /**
  17287. * Gets or sets a boolean indicating if the edgesRenderer is active
  17288. */
  17289. isEnabled: boolean;
  17290. /**
  17291. * Renders the edges of the attached mesh,
  17292. */
  17293. render(): void;
  17294. /**
  17295. * Checks wether or not the edges renderer is ready to render.
  17296. * @return true if ready, otherwise false.
  17297. */
  17298. isReady(): boolean;
  17299. }
  17300. /**
  17301. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17302. */
  17303. export class EdgesRenderer implements IEdgesRenderer {
  17304. /**
  17305. * Define the size of the edges with an orthographic camera
  17306. */
  17307. edgesWidthScalerForOrthographic: number;
  17308. /**
  17309. * Define the size of the edges with a perspective camera
  17310. */
  17311. edgesWidthScalerForPerspective: number;
  17312. protected _source: AbstractMesh;
  17313. protected _linesPositions: number[];
  17314. protected _linesNormals: number[];
  17315. protected _linesIndices: number[];
  17316. protected _epsilon: number;
  17317. protected _indicesCount: number;
  17318. protected _lineShader: ShaderMaterial;
  17319. protected _ib: WebGLBuffer;
  17320. protected _buffers: {
  17321. [key: string]: Nullable<VertexBuffer>;
  17322. };
  17323. protected _checkVerticesInsteadOfIndices: boolean;
  17324. private _meshRebuildObserver;
  17325. private _meshDisposeObserver;
  17326. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17327. isEnabled: boolean;
  17328. /**
  17329. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17330. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17331. * @param source Mesh used to create edges
  17332. * @param epsilon sum of angles in adjacency to check for edge
  17333. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17334. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17335. */
  17336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17337. protected _prepareRessources(): void;
  17338. /** @hidden */
  17339. _rebuild(): void;
  17340. /**
  17341. * Releases the required resources for the edges renderer
  17342. */
  17343. dispose(): void;
  17344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17346. /**
  17347. * Checks if the pair of p0 and p1 is en edge
  17348. * @param faceIndex
  17349. * @param edge
  17350. * @param faceNormals
  17351. * @param p0
  17352. * @param p1
  17353. * @private
  17354. */
  17355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17356. /**
  17357. * push line into the position, normal and index buffer
  17358. * @protected
  17359. */
  17360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17361. /**
  17362. * Generates lines edges from adjacencjes
  17363. * @private
  17364. */
  17365. _generateEdgesLines(): void;
  17366. /**
  17367. * Checks wether or not the edges renderer is ready to render.
  17368. * @return true if ready, otherwise false.
  17369. */
  17370. isReady(): boolean;
  17371. /**
  17372. * Renders the edges of the attached mesh,
  17373. */
  17374. render(): void;
  17375. }
  17376. /**
  17377. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17378. */
  17379. export class LineEdgesRenderer extends EdgesRenderer {
  17380. /**
  17381. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17382. * @param source LineMesh used to generate edges
  17383. * @param epsilon not important (specified angle for edge detection)
  17384. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17385. */
  17386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17387. /**
  17388. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17389. */
  17390. _generateEdgesLines(): void;
  17391. }
  17392. }
  17393. declare module "babylonjs/Rendering/renderingGroup" {
  17394. import { SmartArray } from "babylonjs/Misc/smartArray";
  17395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17397. import { Nullable } from "babylonjs/types";
  17398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17399. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17400. import { Material } from "babylonjs/Materials/material";
  17401. import { Scene } from "babylonjs/scene";
  17402. /**
  17403. * This represents the object necessary to create a rendering group.
  17404. * This is exclusively used and created by the rendering manager.
  17405. * To modify the behavior, you use the available helpers in your scene or meshes.
  17406. * @hidden
  17407. */
  17408. export class RenderingGroup {
  17409. index: number;
  17410. private _scene;
  17411. private _opaqueSubMeshes;
  17412. private _transparentSubMeshes;
  17413. private _alphaTestSubMeshes;
  17414. private _depthOnlySubMeshes;
  17415. private _particleSystems;
  17416. private _spriteManagers;
  17417. private _opaqueSortCompareFn;
  17418. private _alphaTestSortCompareFn;
  17419. private _transparentSortCompareFn;
  17420. private _renderOpaque;
  17421. private _renderAlphaTest;
  17422. private _renderTransparent;
  17423. private _edgesRenderers;
  17424. onBeforeTransparentRendering: () => void;
  17425. /**
  17426. * Set the opaque sort comparison function.
  17427. * If null the sub meshes will be render in the order they were created
  17428. */
  17429. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17430. /**
  17431. * Set the alpha test sort comparison function.
  17432. * If null the sub meshes will be render in the order they were created
  17433. */
  17434. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17435. /**
  17436. * Set the transparent sort comparison function.
  17437. * If null the sub meshes will be render in the order they were created
  17438. */
  17439. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17440. /**
  17441. * Creates a new rendering group.
  17442. * @param index The rendering group index
  17443. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17444. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17445. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17446. */
  17447. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17448. /**
  17449. * Render all the sub meshes contained in the group.
  17450. * @param customRenderFunction Used to override the default render behaviour of the group.
  17451. * @returns true if rendered some submeshes.
  17452. */
  17453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17454. /**
  17455. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17456. * @param subMeshes The submeshes to render
  17457. */
  17458. private renderOpaqueSorted;
  17459. /**
  17460. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17461. * @param subMeshes The submeshes to render
  17462. */
  17463. private renderAlphaTestSorted;
  17464. /**
  17465. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17466. * @param subMeshes The submeshes to render
  17467. */
  17468. private renderTransparentSorted;
  17469. /**
  17470. * Renders the submeshes in a specified order.
  17471. * @param subMeshes The submeshes to sort before render
  17472. * @param sortCompareFn The comparison function use to sort
  17473. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17474. * @param transparent Specifies to activate blending if true
  17475. */
  17476. private static renderSorted;
  17477. /**
  17478. * Renders the submeshes in the order they were dispatched (no sort applied).
  17479. * @param subMeshes The submeshes to render
  17480. */
  17481. private static renderUnsorted;
  17482. /**
  17483. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17484. * are rendered back to front if in the same alpha index.
  17485. *
  17486. * @param a The first submesh
  17487. * @param b The second submesh
  17488. * @returns The result of the comparison
  17489. */
  17490. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17491. /**
  17492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17493. * are rendered back to front.
  17494. *
  17495. * @param a The first submesh
  17496. * @param b The second submesh
  17497. * @returns The result of the comparison
  17498. */
  17499. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17500. /**
  17501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17502. * are rendered front to back (prevent overdraw).
  17503. *
  17504. * @param a The first submesh
  17505. * @param b The second submesh
  17506. * @returns The result of the comparison
  17507. */
  17508. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17509. /**
  17510. * Resets the different lists of submeshes to prepare a new frame.
  17511. */
  17512. prepare(): void;
  17513. dispose(): void;
  17514. /**
  17515. * Inserts the submesh in its correct queue depending on its material.
  17516. * @param subMesh The submesh to dispatch
  17517. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17518. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17519. */
  17520. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17521. dispatchSprites(spriteManager: ISpriteManager): void;
  17522. dispatchParticles(particleSystem: IParticleSystem): void;
  17523. private _renderParticles;
  17524. private _renderSprites;
  17525. }
  17526. }
  17527. declare module "babylonjs/Rendering/renderingManager" {
  17528. import { Nullable } from "babylonjs/types";
  17529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17531. import { SmartArray } from "babylonjs/Misc/smartArray";
  17532. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17533. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17534. import { Material } from "babylonjs/Materials/material";
  17535. import { Scene } from "babylonjs/scene";
  17536. import { Camera } from "babylonjs/Cameras/camera";
  17537. /**
  17538. * Interface describing the different options available in the rendering manager
  17539. * regarding Auto Clear between groups.
  17540. */
  17541. export interface IRenderingManagerAutoClearSetup {
  17542. /**
  17543. * Defines whether or not autoclear is enable.
  17544. */
  17545. autoClear: boolean;
  17546. /**
  17547. * Defines whether or not to autoclear the depth buffer.
  17548. */
  17549. depth: boolean;
  17550. /**
  17551. * Defines whether or not to autoclear the stencil buffer.
  17552. */
  17553. stencil: boolean;
  17554. }
  17555. /**
  17556. * This class is used by the onRenderingGroupObservable
  17557. */
  17558. export class RenderingGroupInfo {
  17559. /**
  17560. * The Scene that being rendered
  17561. */
  17562. scene: Scene;
  17563. /**
  17564. * The camera currently used for the rendering pass
  17565. */
  17566. camera: Nullable<Camera>;
  17567. /**
  17568. * The ID of the renderingGroup being processed
  17569. */
  17570. renderingGroupId: number;
  17571. }
  17572. /**
  17573. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17574. * It is enable to manage the different groups as well as the different necessary sort functions.
  17575. * This should not be used directly aside of the few static configurations
  17576. */
  17577. export class RenderingManager {
  17578. /**
  17579. * The max id used for rendering groups (not included)
  17580. */
  17581. static MAX_RENDERINGGROUPS: number;
  17582. /**
  17583. * The min id used for rendering groups (included)
  17584. */
  17585. static MIN_RENDERINGGROUPS: number;
  17586. /**
  17587. * Used to globally prevent autoclearing scenes.
  17588. */
  17589. static AUTOCLEAR: boolean;
  17590. /**
  17591. * @hidden
  17592. */
  17593. _useSceneAutoClearSetup: boolean;
  17594. private _scene;
  17595. private _renderingGroups;
  17596. private _depthStencilBufferAlreadyCleaned;
  17597. private _autoClearDepthStencil;
  17598. private _customOpaqueSortCompareFn;
  17599. private _customAlphaTestSortCompareFn;
  17600. private _customTransparentSortCompareFn;
  17601. private _renderingGroupInfo;
  17602. /**
  17603. * Instantiates a new rendering group for a particular scene
  17604. * @param scene Defines the scene the groups belongs to
  17605. */
  17606. constructor(scene: Scene);
  17607. private _clearDepthStencilBuffer;
  17608. /**
  17609. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17610. * @hidden
  17611. */
  17612. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17613. /**
  17614. * Resets the different information of the group to prepare a new frame
  17615. * @hidden
  17616. */
  17617. reset(): void;
  17618. /**
  17619. * Dispose and release the group and its associated resources.
  17620. * @hidden
  17621. */
  17622. dispose(): void;
  17623. /**
  17624. * Clear the info related to rendering groups preventing retention points during dispose.
  17625. */
  17626. freeRenderingGroups(): void;
  17627. private _prepareRenderingGroup;
  17628. /**
  17629. * Add a sprite manager to the rendering manager in order to render it this frame.
  17630. * @param spriteManager Define the sprite manager to render
  17631. */
  17632. dispatchSprites(spriteManager: ISpriteManager): void;
  17633. /**
  17634. * Add a particle system to the rendering manager in order to render it this frame.
  17635. * @param particleSystem Define the particle system to render
  17636. */
  17637. dispatchParticles(particleSystem: IParticleSystem): void;
  17638. /**
  17639. * Add a submesh to the manager in order to render it this frame
  17640. * @param subMesh The submesh to dispatch
  17641. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17642. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17643. */
  17644. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17645. /**
  17646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17647. * This allowed control for front to back rendering or reversly depending of the special needs.
  17648. *
  17649. * @param renderingGroupId The rendering group id corresponding to its index
  17650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17653. */
  17654. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17655. /**
  17656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17657. *
  17658. * @param renderingGroupId The rendering group id corresponding to its index
  17659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17662. */
  17663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17664. /**
  17665. * Gets the current auto clear configuration for one rendering group of the rendering
  17666. * manager.
  17667. * @param index the rendering group index to get the information for
  17668. * @returns The auto clear setup for the requested rendering group
  17669. */
  17670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17671. }
  17672. }
  17673. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17674. import { Observable } from "babylonjs/Misc/observable";
  17675. import { SmartArray } from "babylonjs/Misc/smartArray";
  17676. import { Nullable } from "babylonjs/types";
  17677. import { Camera } from "babylonjs/Cameras/camera";
  17678. import { Scene } from "babylonjs/scene";
  17679. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17680. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17684. import { Texture } from "babylonjs/Materials/Textures/texture";
  17685. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17686. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17687. import { Engine } from "babylonjs/Engines/engine";
  17688. /**
  17689. * This Helps creating a texture that will be created from a camera in your scene.
  17690. * It is basically a dynamic texture that could be used to create special effects for instance.
  17691. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17692. */
  17693. export class RenderTargetTexture extends Texture {
  17694. isCube: boolean;
  17695. /**
  17696. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17697. */
  17698. static readonly REFRESHRATE_RENDER_ONCE: number;
  17699. /**
  17700. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17701. */
  17702. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17703. /**
  17704. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17705. * the central point of your effect and can save a lot of performances.
  17706. */
  17707. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17708. /**
  17709. * Use this predicate to dynamically define the list of mesh you want to render.
  17710. * If set, the renderList property will be overwritten.
  17711. */
  17712. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17713. private _renderList;
  17714. /**
  17715. * Use this list to define the list of mesh you want to render.
  17716. */
  17717. renderList: Nullable<Array<AbstractMesh>>;
  17718. private _hookArray;
  17719. /**
  17720. * Define if particles should be rendered in your texture.
  17721. */
  17722. renderParticles: boolean;
  17723. /**
  17724. * Define if sprites should be rendered in your texture.
  17725. */
  17726. renderSprites: boolean;
  17727. /**
  17728. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17729. */
  17730. coordinatesMode: number;
  17731. /**
  17732. * Define the camera used to render the texture.
  17733. */
  17734. activeCamera: Nullable<Camera>;
  17735. /**
  17736. * Override the render function of the texture with your own one.
  17737. */
  17738. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17739. /**
  17740. * Define if camera post processes should be use while rendering the texture.
  17741. */
  17742. useCameraPostProcesses: boolean;
  17743. /**
  17744. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17745. */
  17746. ignoreCameraViewport: boolean;
  17747. private _postProcessManager;
  17748. private _postProcesses;
  17749. private _resizeObserver;
  17750. /**
  17751. * An event triggered when the texture is unbind.
  17752. */
  17753. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17754. /**
  17755. * An event triggered when the texture is unbind.
  17756. */
  17757. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17758. private _onAfterUnbindObserver;
  17759. /**
  17760. * Set a after unbind callback in the texture.
  17761. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17762. */
  17763. onAfterUnbind: () => void;
  17764. /**
  17765. * An event triggered before rendering the texture
  17766. */
  17767. onBeforeRenderObservable: Observable<number>;
  17768. private _onBeforeRenderObserver;
  17769. /**
  17770. * Set a before render callback in the texture.
  17771. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17772. */
  17773. onBeforeRender: (faceIndex: number) => void;
  17774. /**
  17775. * An event triggered after rendering the texture
  17776. */
  17777. onAfterRenderObservable: Observable<number>;
  17778. private _onAfterRenderObserver;
  17779. /**
  17780. * Set a after render callback in the texture.
  17781. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17782. */
  17783. onAfterRender: (faceIndex: number) => void;
  17784. /**
  17785. * An event triggered after the texture clear
  17786. */
  17787. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17788. private _onClearObserver;
  17789. /**
  17790. * Set a clear callback in the texture.
  17791. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17792. */
  17793. onClear: (Engine: Engine) => void;
  17794. /**
  17795. * Define the clear color of the Render Target if it should be different from the scene.
  17796. */
  17797. clearColor: Color4;
  17798. protected _size: number | {
  17799. width: number;
  17800. height: number;
  17801. };
  17802. protected _initialSizeParameter: number | {
  17803. width: number;
  17804. height: number;
  17805. } | {
  17806. ratio: number;
  17807. };
  17808. protected _sizeRatio: Nullable<number>;
  17809. /** @hidden */
  17810. _generateMipMaps: boolean;
  17811. protected _renderingManager: RenderingManager;
  17812. /** @hidden */
  17813. _waitingRenderList: string[];
  17814. protected _doNotChangeAspectRatio: boolean;
  17815. protected _currentRefreshId: number;
  17816. protected _refreshRate: number;
  17817. protected _textureMatrix: Matrix;
  17818. protected _samples: number;
  17819. protected _renderTargetOptions: RenderTargetCreationOptions;
  17820. /**
  17821. * Gets render target creation options that were used.
  17822. */
  17823. readonly renderTargetOptions: RenderTargetCreationOptions;
  17824. protected _engine: Engine;
  17825. protected _onRatioRescale(): void;
  17826. /**
  17827. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17828. * It must define where the camera used to render the texture is set
  17829. */
  17830. boundingBoxPosition: Vector3;
  17831. private _boundingBoxSize;
  17832. /**
  17833. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17834. * When defined, the cubemap will switch to local mode
  17835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17836. * @example https://www.babylonjs-playground.com/#RNASML
  17837. */
  17838. boundingBoxSize: Vector3;
  17839. /**
  17840. * In case the RTT has been created with a depth texture, get the associated
  17841. * depth texture.
  17842. * Otherwise, return null.
  17843. */
  17844. depthStencilTexture: Nullable<InternalTexture>;
  17845. /**
  17846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17847. * or used a shadow, depth texture...
  17848. * @param name The friendly name of the texture
  17849. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  17850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17851. * @param generateMipMaps True if mip maps need to be generated after render.
  17852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17853. * @param type The type of the buffer in the RTT (int, half float, float...)
  17854. * @param isCube True if a cube texture needs to be created
  17855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17856. * @param generateDepthBuffer True to generate a depth buffer
  17857. * @param generateStencilBuffer True to generate a stencil buffer
  17858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17861. */
  17862. constructor(name: string, size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17868. /**
  17869. * Creates a depth stencil texture.
  17870. * This is only available in WebGL 2 or with the depth texture extension available.
  17871. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17872. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17873. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17874. */
  17875. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17876. private _processSizeParameter;
  17877. /**
  17878. * Define the number of samples to use in case of MSAA.
  17879. * It defaults to one meaning no MSAA has been enabled.
  17880. */
  17881. samples: number;
  17882. /**
  17883. * Resets the refresh counter of the texture and start bak from scratch.
  17884. * Could be useful to regenerate the texture if it is setup to render only once.
  17885. */
  17886. resetRefreshCounter(): void;
  17887. /**
  17888. * Define the refresh rate of the texture or the rendering frequency.
  17889. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17890. */
  17891. refreshRate: number;
  17892. /**
  17893. * Adds a post process to the render target rendering passes.
  17894. * @param postProcess define the post process to add
  17895. */
  17896. addPostProcess(postProcess: PostProcess): void;
  17897. /**
  17898. * Clear all the post processes attached to the render target
  17899. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17900. */
  17901. clearPostProcesses(dispose?: boolean): void;
  17902. /**
  17903. * Remove one of the post process from the list of attached post processes to the texture
  17904. * @param postProcess define the post process to remove from the list
  17905. */
  17906. removePostProcess(postProcess: PostProcess): void;
  17907. /** @hidden */
  17908. _shouldRender(): boolean;
  17909. /**
  17910. * Gets the actual render size of the texture.
  17911. * @returns the width of the render size
  17912. */
  17913. getRenderSize(): number;
  17914. /**
  17915. * Gets the actual render width of the texture.
  17916. * @returns the width of the render size
  17917. */
  17918. getRenderWidth(): number;
  17919. /**
  17920. * Gets the actual render height of the texture.
  17921. * @returns the height of the render size
  17922. */
  17923. getRenderHeight(): number;
  17924. /**
  17925. * Get if the texture can be rescaled or not.
  17926. */
  17927. readonly canRescale: boolean;
  17928. /**
  17929. * Resize the texture using a ratio.
  17930. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17931. */
  17932. scale(ratio: number): void;
  17933. /**
  17934. * Get the texture reflection matrix used to rotate/transform the reflection.
  17935. * @returns the reflection matrix
  17936. */
  17937. getReflectionTextureMatrix(): Matrix;
  17938. /**
  17939. * Resize the texture to a new desired size.
  17940. * Be carrefull as it will recreate all the data in the new texture.
  17941. * @param size Define the new size. It can be:
  17942. * - a number for squared texture,
  17943. * - an object containing { width: number, height: number }
  17944. * - or an object containing a ratio { ratio: number }
  17945. */
  17946. resize(size: number | {
  17947. width: number;
  17948. height: number;
  17949. } | {
  17950. ratio: number;
  17951. }): void;
  17952. /**
  17953. * Renders all the objects from the render list into the texture.
  17954. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17955. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17956. */
  17957. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17958. private _bestReflectionRenderTargetDimension;
  17959. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17960. private renderToTarget;
  17961. /**
  17962. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17963. * This allowed control for front to back rendering or reversly depending of the special needs.
  17964. *
  17965. * @param renderingGroupId The rendering group id corresponding to its index
  17966. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17967. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17968. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17969. */
  17970. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17971. /**
  17972. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17973. *
  17974. * @param renderingGroupId The rendering group id corresponding to its index
  17975. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17976. */
  17977. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17978. /**
  17979. * Clones the texture.
  17980. * @returns the cloned texture
  17981. */
  17982. clone(): RenderTargetTexture;
  17983. /**
  17984. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17985. * @returns The JSON representation of the texture
  17986. */
  17987. serialize(): any;
  17988. /**
  17989. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17990. */
  17991. disposeFramebufferObjects(): void;
  17992. /**
  17993. * Dispose the texture and release its associated resources.
  17994. */
  17995. dispose(): void;
  17996. /** @hidden */
  17997. _rebuild(): void;
  17998. /**
  17999. * Clear the info related to rendering groups preventing retention point in material dispose.
  18000. */
  18001. freeRenderingGroups(): void;
  18002. }
  18003. }
  18004. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18005. import { Scene } from "babylonjs/scene";
  18006. import { Plane } from "babylonjs/Maths/math";
  18007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18008. /**
  18009. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18010. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18011. * You can then easily use it as a reflectionTexture on a flat surface.
  18012. * In case the surface is not a plane, please consider relying on reflection probes.
  18013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18014. */
  18015. export class MirrorTexture extends RenderTargetTexture {
  18016. private scene;
  18017. /**
  18018. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18019. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  18020. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18021. */
  18022. mirrorPlane: Plane;
  18023. /**
  18024. * Define the blur ratio used to blur the reflection if needed.
  18025. */
  18026. blurRatio: number;
  18027. /**
  18028. * Define the adaptive blur kernel used to blur the reflection if needed.
  18029. * This will autocompute the closest best match for the `blurKernel`
  18030. */
  18031. adaptiveBlurKernel: number;
  18032. /**
  18033. * Define the blur kernel used to blur the reflection if needed.
  18034. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18035. */
  18036. blurKernel: number;
  18037. /**
  18038. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18039. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18040. */
  18041. blurKernelX: number;
  18042. /**
  18043. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18044. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18045. */
  18046. blurKernelY: number;
  18047. private _autoComputeBlurKernel;
  18048. protected _onRatioRescale(): void;
  18049. private _updateGammaSpace;
  18050. private _imageProcessingConfigChangeObserver;
  18051. private _transformMatrix;
  18052. private _mirrorMatrix;
  18053. private _savedViewMatrix;
  18054. private _blurX;
  18055. private _blurY;
  18056. private _adaptiveBlurKernel;
  18057. private _blurKernelX;
  18058. private _blurKernelY;
  18059. private _blurRatio;
  18060. /**
  18061. * Instantiates a Mirror Texture.
  18062. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18063. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18064. * You can then easily use it as a reflectionTexture on a flat surface.
  18065. * In case the surface is not a plane, please consider relying on reflection probes.
  18066. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18067. * @param name
  18068. * @param size
  18069. * @param scene
  18070. * @param generateMipMaps
  18071. * @param type
  18072. * @param samplingMode
  18073. * @param generateDepthBuffer
  18074. */
  18075. constructor(name: string, size: number | {
  18076. width: number;
  18077. height: number;
  18078. } | {
  18079. ratio: number;
  18080. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18081. private _preparePostProcesses;
  18082. /**
  18083. * Clone the mirror texture.
  18084. * @returns the cloned texture
  18085. */
  18086. clone(): MirrorTexture;
  18087. /**
  18088. * Serialize the texture to a JSON representation you could use in Parse later on
  18089. * @returns the serialized JSON representation
  18090. */
  18091. serialize(): any;
  18092. /**
  18093. * Dispose the texture and release its associated resources.
  18094. */
  18095. dispose(): void;
  18096. }
  18097. }
  18098. declare module "babylonjs/Materials/Textures/texture" {
  18099. import { Observable } from "babylonjs/Misc/observable";
  18100. import { Nullable } from "babylonjs/types";
  18101. import { Scene } from "babylonjs/scene";
  18102. import { Matrix } from "babylonjs/Maths/math";
  18103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18104. /**
  18105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18107. */
  18108. export class Texture extends BaseTexture {
  18109. /** @hidden */
  18110. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18111. /** @hidden */
  18112. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18113. /** @hidden */
  18114. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18115. /** nearest is mag = nearest and min = nearest and mip = linear */
  18116. static readonly NEAREST_SAMPLINGMODE: number;
  18117. /** nearest is mag = nearest and min = nearest and mip = linear */
  18118. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18119. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18120. static readonly BILINEAR_SAMPLINGMODE: number;
  18121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18122. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18123. /** Trilinear is mag = linear and min = linear and mip = linear */
  18124. static readonly TRILINEAR_SAMPLINGMODE: number;
  18125. /** Trilinear is mag = linear and min = linear and mip = linear */
  18126. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18127. /** mag = nearest and min = nearest and mip = nearest */
  18128. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18129. /** mag = nearest and min = linear and mip = nearest */
  18130. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18131. /** mag = nearest and min = linear and mip = linear */
  18132. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18133. /** mag = nearest and min = linear and mip = none */
  18134. static readonly NEAREST_LINEAR: number;
  18135. /** mag = nearest and min = nearest and mip = none */
  18136. static readonly NEAREST_NEAREST: number;
  18137. /** mag = linear and min = nearest and mip = nearest */
  18138. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18139. /** mag = linear and min = nearest and mip = linear */
  18140. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18141. /** mag = linear and min = linear and mip = none */
  18142. static readonly LINEAR_LINEAR: number;
  18143. /** mag = linear and min = nearest and mip = none */
  18144. static readonly LINEAR_NEAREST: number;
  18145. /** Explicit coordinates mode */
  18146. static readonly EXPLICIT_MODE: number;
  18147. /** Spherical coordinates mode */
  18148. static readonly SPHERICAL_MODE: number;
  18149. /** Planar coordinates mode */
  18150. static readonly PLANAR_MODE: number;
  18151. /** Cubic coordinates mode */
  18152. static readonly CUBIC_MODE: number;
  18153. /** Projection coordinates mode */
  18154. static readonly PROJECTION_MODE: number;
  18155. /** Inverse Cubic coordinates mode */
  18156. static readonly SKYBOX_MODE: number;
  18157. /** Inverse Cubic coordinates mode */
  18158. static readonly INVCUBIC_MODE: number;
  18159. /** Equirectangular coordinates mode */
  18160. static readonly EQUIRECTANGULAR_MODE: number;
  18161. /** Equirectangular Fixed coordinates mode */
  18162. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18163. /** Equirectangular Fixed Mirrored coordinates mode */
  18164. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18165. /** Texture is not repeating outside of 0..1 UVs */
  18166. static readonly CLAMP_ADDRESSMODE: number;
  18167. /** Texture is repeating outside of 0..1 UVs */
  18168. static readonly WRAP_ADDRESSMODE: number;
  18169. /** Texture is repeating and mirrored */
  18170. static readonly MIRROR_ADDRESSMODE: number;
  18171. /**
  18172. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  18173. */
  18174. static UseSerializedUrlIfAny: boolean;
  18175. /**
  18176. * Define the url of the texture.
  18177. */
  18178. url: Nullable<string>;
  18179. /**
  18180. * Define an offset on the texture to offset the u coordinates of the UVs
  18181. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18182. */
  18183. uOffset: number;
  18184. /**
  18185. * Define an offset on the texture to offset the v coordinates of the UVs
  18186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18187. */
  18188. vOffset: number;
  18189. /**
  18190. * Define an offset on the texture to scale the u coordinates of the UVs
  18191. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18192. */
  18193. uScale: number;
  18194. /**
  18195. * Define an offset on the texture to scale the v coordinates of the UVs
  18196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18197. */
  18198. vScale: number;
  18199. /**
  18200. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18201. * @see http://doc.babylonjs.com/how_to/more_materials
  18202. */
  18203. uAng: number;
  18204. /**
  18205. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18206. * @see http://doc.babylonjs.com/how_to/more_materials
  18207. */
  18208. vAng: number;
  18209. /**
  18210. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18211. * @see http://doc.babylonjs.com/how_to/more_materials
  18212. */
  18213. wAng: number;
  18214. /**
  18215. * Defines the center of rotation (U)
  18216. */
  18217. uRotationCenter: number;
  18218. /**
  18219. * Defines the center of rotation (V)
  18220. */
  18221. vRotationCenter: number;
  18222. /**
  18223. * Defines the center of rotation (W)
  18224. */
  18225. wRotationCenter: number;
  18226. /**
  18227. * Are mip maps generated for this texture or not.
  18228. */
  18229. readonly noMipmap: boolean;
  18230. private _noMipmap;
  18231. /** @hidden */
  18232. _invertY: boolean;
  18233. private _rowGenerationMatrix;
  18234. private _cachedTextureMatrix;
  18235. private _projectionModeMatrix;
  18236. private _t0;
  18237. private _t1;
  18238. private _t2;
  18239. private _cachedUOffset;
  18240. private _cachedVOffset;
  18241. private _cachedUScale;
  18242. private _cachedVScale;
  18243. private _cachedUAng;
  18244. private _cachedVAng;
  18245. private _cachedWAng;
  18246. private _cachedProjectionMatrixId;
  18247. private _cachedCoordinatesMode;
  18248. /** @hidden */
  18249. protected _initialSamplingMode: number;
  18250. /** @hidden */
  18251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18252. private _deleteBuffer;
  18253. protected _format: Nullable<number>;
  18254. private _delayedOnLoad;
  18255. private _delayedOnError;
  18256. /**
  18257. * Observable triggered once the texture has been loaded.
  18258. */
  18259. onLoadObservable: Observable<Texture>;
  18260. protected _isBlocking: boolean;
  18261. /**
  18262. * Is the texture preventing material to render while loading.
  18263. * If false, a default texture will be used instead of the loading one during the preparation step.
  18264. */
  18265. isBlocking: boolean;
  18266. /**
  18267. * Get the current sampling mode associated with the texture.
  18268. */
  18269. readonly samplingMode: number;
  18270. /**
  18271. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18272. */
  18273. readonly invertY: boolean;
  18274. /**
  18275. * Instantiates a new texture.
  18276. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18277. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18278. * @param url define the url of the picture to load as a texture
  18279. * @param scene define the scene the texture will belong to
  18280. * @param noMipmap define if the texture will require mip maps or not
  18281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18283. * @param onLoad define a callback triggered when the texture has been loaded
  18284. * @param onError define a callback triggered when an error occurred during the loading session
  18285. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18286. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18288. */
  18289. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18290. /**
  18291. * Update the url (and optional buffer) of this texture if url was null during construction.
  18292. * @param url the url of the texture
  18293. * @param buffer the buffer of the texture (defaults to null)
  18294. * @param onLoad callback called when the texture is loaded (defaults to null)
  18295. */
  18296. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18297. /**
  18298. * Finish the loading sequence of a texture flagged as delayed load.
  18299. * @hidden
  18300. */
  18301. delayLoad(): void;
  18302. private _prepareRowForTextureGeneration;
  18303. /**
  18304. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18305. * @returns the transform matrix of the texture.
  18306. */
  18307. getTextureMatrix(): Matrix;
  18308. /**
  18309. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18310. * @returns The reflection texture transform
  18311. */
  18312. getReflectionTextureMatrix(): Matrix;
  18313. /**
  18314. * Clones the texture.
  18315. * @returns the cloned texture
  18316. */
  18317. clone(): Texture;
  18318. /**
  18319. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18320. * @returns The JSON representation of the texture
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Get the current class name of the texture useful for serialization or dynamic coding.
  18325. * @returns "Texture"
  18326. */
  18327. getClassName(): string;
  18328. /**
  18329. * Dispose the texture and release its associated resources.
  18330. */
  18331. dispose(): void;
  18332. /**
  18333. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18334. * @param parsedTexture Define the JSON representation of the texture
  18335. * @param scene Define the scene the parsed texture should be instantiated in
  18336. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18337. * @returns The parsed texture if successful
  18338. */
  18339. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18340. /**
  18341. * Creates a texture from its base 64 representation.
  18342. * @param data Define the base64 payload without the data: prefix
  18343. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18344. * @param scene Define the scene the texture should belong to
  18345. * @param noMipmap Forces the texture to not create mip map information if true
  18346. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18347. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18348. * @param onLoad define a callback triggered when the texture has been loaded
  18349. * @param onError define a callback triggered when an error occurred during the loading session
  18350. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18351. * @returns the created texture
  18352. */
  18353. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18354. /**
  18355. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18356. * @param data Define the base64 payload without the data: prefix
  18357. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18358. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18359. * @param scene Define the scene the texture should belong to
  18360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18361. * @param noMipmap Forces the texture to not create mip map information if true
  18362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18364. * @param onLoad define a callback triggered when the texture has been loaded
  18365. * @param onError define a callback triggered when an error occurred during the loading session
  18366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18367. * @returns the created texture
  18368. */
  18369. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  18370. }
  18371. }
  18372. declare module "babylonjs/Materials/Textures/rawTexture" {
  18373. import { Scene } from "babylonjs/scene";
  18374. import { Texture } from "babylonjs/Materials/Textures/texture";
  18375. /**
  18376. * Raw texture can help creating a texture directly from an array of data.
  18377. * This can be super useful if you either get the data from an uncompressed source or
  18378. * if you wish to create your texture pixel by pixel.
  18379. */
  18380. export class RawTexture extends Texture {
  18381. /**
  18382. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18383. */
  18384. format: number;
  18385. private _engine;
  18386. /**
  18387. * Instantiates a new RawTexture.
  18388. * Raw texture can help creating a texture directly from an array of data.
  18389. * This can be super useful if you either get the data from an uncompressed source or
  18390. * if you wish to create your texture pixel by pixel.
  18391. * @param data define the array of data to use to create the texture
  18392. * @param width define the width of the texture
  18393. * @param height define the height of the texture
  18394. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18395. * @param scene define the scene the texture belongs to
  18396. * @param generateMipMaps define whether mip maps should be generated or not
  18397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18399. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18400. */
  18401. constructor(data: ArrayBufferView, width: number, height: number,
  18402. /**
  18403. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18404. */
  18405. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18406. /**
  18407. * Updates the texture underlying data.
  18408. * @param data Define the new data of the texture
  18409. */
  18410. update(data: ArrayBufferView): void;
  18411. /**
  18412. * Creates a luminance texture from some data.
  18413. * @param data Define the texture data
  18414. * @param width Define the width of the texture
  18415. * @param height Define the height of the texture
  18416. * @param scene Define the scene the texture belongs to
  18417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18420. * @returns the luminance texture
  18421. */
  18422. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18423. /**
  18424. * Creates a luminance alpha texture from some data.
  18425. * @param data Define the texture data
  18426. * @param width Define the width of the texture
  18427. * @param height Define the height of the texture
  18428. * @param scene Define the scene the texture belongs to
  18429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18432. * @returns the luminance alpha texture
  18433. */
  18434. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18435. /**
  18436. * Creates an alpha texture from some data.
  18437. * @param data Define the texture data
  18438. * @param width Define the width of the texture
  18439. * @param height Define the height of the texture
  18440. * @param scene Define the scene the texture belongs to
  18441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18444. * @returns the alpha texture
  18445. */
  18446. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18447. /**
  18448. * Creates a RGB texture from some data.
  18449. * @param data Define the texture data
  18450. * @param width Define the width of the texture
  18451. * @param height Define the height of the texture
  18452. * @param scene Define the scene the texture belongs to
  18453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18456. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18457. * @returns the RGB alpha texture
  18458. */
  18459. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18460. /**
  18461. * Creates a RGBA texture from some data.
  18462. * @param data Define the texture data
  18463. * @param width Define the width of the texture
  18464. * @param height Define the height of the texture
  18465. * @param scene Define the scene the texture belongs to
  18466. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18467. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18468. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18469. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18470. * @returns the RGBA texture
  18471. */
  18472. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18473. /**
  18474. * Creates a R texture from some data.
  18475. * @param data Define the texture data
  18476. * @param width Define the width of the texture
  18477. * @param height Define the height of the texture
  18478. * @param scene Define the scene the texture belongs to
  18479. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18480. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18481. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18482. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18483. * @returns the R texture
  18484. */
  18485. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18486. }
  18487. }
  18488. declare module "babylonjs/Animations/runtimeAnimation" {
  18489. import { Animation } from "babylonjs/Animations/animation";
  18490. import { Animatable } from "babylonjs/Animations/animatable";
  18491. import { Scene } from "babylonjs/scene";
  18492. /**
  18493. * Defines a runtime animation
  18494. */
  18495. export class RuntimeAnimation {
  18496. private _events;
  18497. /**
  18498. * The current frame of the runtime animation
  18499. */
  18500. private _currentFrame;
  18501. /**
  18502. * The animation used by the runtime animation
  18503. */
  18504. private _animation;
  18505. /**
  18506. * The target of the runtime animation
  18507. */
  18508. private _target;
  18509. /**
  18510. * The initiating animatable
  18511. */
  18512. private _host;
  18513. /**
  18514. * The original value of the runtime animation
  18515. */
  18516. private _originalValue;
  18517. /**
  18518. * The original blend value of the runtime animation
  18519. */
  18520. private _originalBlendValue;
  18521. /**
  18522. * The offsets cache of the runtime animation
  18523. */
  18524. private _offsetsCache;
  18525. /**
  18526. * The high limits cache of the runtime animation
  18527. */
  18528. private _highLimitsCache;
  18529. /**
  18530. * Specifies if the runtime animation has been stopped
  18531. */
  18532. private _stopped;
  18533. /**
  18534. * The blending factor of the runtime animation
  18535. */
  18536. private _blendingFactor;
  18537. /**
  18538. * The BabylonJS scene
  18539. */
  18540. private _scene;
  18541. /**
  18542. * The current value of the runtime animation
  18543. */
  18544. private _currentValue;
  18545. /** @hidden */
  18546. _workValue: any;
  18547. /**
  18548. * The active target of the runtime animation
  18549. */
  18550. private _activeTarget;
  18551. /**
  18552. * The target path of the runtime animation
  18553. */
  18554. private _targetPath;
  18555. /**
  18556. * The weight of the runtime animation
  18557. */
  18558. private _weight;
  18559. /**
  18560. * The ratio offset of the runtime animation
  18561. */
  18562. private _ratioOffset;
  18563. /**
  18564. * The previous delay of the runtime animation
  18565. */
  18566. private _previousDelay;
  18567. /**
  18568. * The previous ratio of the runtime animation
  18569. */
  18570. private _previousRatio;
  18571. /**
  18572. * Gets the current frame of the runtime animation
  18573. */
  18574. readonly currentFrame: number;
  18575. /**
  18576. * Gets the weight of the runtime animation
  18577. */
  18578. readonly weight: number;
  18579. /**
  18580. * Gets the current value of the runtime animation
  18581. */
  18582. readonly currentValue: any;
  18583. /**
  18584. * Gets the target path of the runtime animation
  18585. */
  18586. readonly targetPath: string;
  18587. /**
  18588. * Gets the actual target of the runtime animation
  18589. */
  18590. readonly target: any;
  18591. /**
  18592. * Create a new RuntimeAnimation object
  18593. * @param target defines the target of the animation
  18594. * @param animation defines the source animation object
  18595. * @param scene defines the hosting scene
  18596. * @param host defines the initiating Animatable
  18597. */
  18598. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18599. /**
  18600. * Gets the animation from the runtime animation
  18601. */
  18602. readonly animation: Animation;
  18603. /**
  18604. * Resets the runtime animation to the beginning
  18605. * @param restoreOriginal defines whether to restore the target property to the original value
  18606. */
  18607. reset(restoreOriginal?: boolean): void;
  18608. /**
  18609. * Specifies if the runtime animation is stopped
  18610. * @returns Boolean specifying if the runtime animation is stopped
  18611. */
  18612. isStopped(): boolean;
  18613. /**
  18614. * Disposes of the runtime animation
  18615. */
  18616. dispose(): void;
  18617. /**
  18618. * Interpolates the animation from the current frame
  18619. * @param currentFrame The frame to interpolate the animation to
  18620. * @param repeatCount The number of times that the animation should loop
  18621. * @param loopMode The type of looping mode to use
  18622. * @param offsetValue Animation offset value
  18623. * @param highLimitValue The high limit value
  18624. * @returns The interpolated value
  18625. */
  18626. private _interpolate;
  18627. /**
  18628. * Apply the interpolated value to the target
  18629. * @param currentValue defines the value computed by the animation
  18630. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18631. */
  18632. setValue(currentValue: any, weight?: number): void;
  18633. private _setValue;
  18634. /**
  18635. * Gets the loop pmode of the runtime animation
  18636. * @returns Loop Mode
  18637. */
  18638. private _getCorrectLoopMode;
  18639. /**
  18640. * Move the current animation to a given frame
  18641. * @param frame defines the frame to move to
  18642. */
  18643. goToFrame(frame: number): void;
  18644. /**
  18645. * @hidden Internal use only
  18646. */
  18647. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18648. /**
  18649. * Execute the current animation
  18650. * @param delay defines the delay to add to the current frame
  18651. * @param from defines the lower bound of the animation range
  18652. * @param to defines the upper bound of the animation range
  18653. * @param loop defines if the current animation must loop
  18654. * @param speedRatio defines the current speed ratio
  18655. * @param weight defines the weight of the animation (default is -1 so no weight)
  18656. * @param onLoop optional callback called when animation loops
  18657. * @returns a boolean indicating if the animation is running
  18658. */
  18659. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18660. }
  18661. }
  18662. declare module "babylonjs/Animations/animatable" {
  18663. import { Animation } from "babylonjs/Animations/animation";
  18664. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18665. import { Nullable } from "babylonjs/types";
  18666. import { Observable } from "babylonjs/Misc/observable";
  18667. import { Scene } from "babylonjs/scene";
  18668. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18669. import { Node } from "babylonjs/node";
  18670. /**
  18671. * Class used to store an actual running animation
  18672. */
  18673. export class Animatable {
  18674. /** defines the target object */
  18675. target: any;
  18676. /** defines the starting frame number (default is 0) */
  18677. fromFrame: number;
  18678. /** defines the ending frame number (default is 100) */
  18679. toFrame: number;
  18680. /** defines if the animation must loop (default is false) */
  18681. loopAnimation: boolean;
  18682. /** defines a callback to call when animation ends if it is not looping */
  18683. onAnimationEnd?: (() => void) | null | undefined;
  18684. /** defines a callback to call when animation loops */
  18685. onAnimationLoop?: (() => void) | null | undefined;
  18686. private _localDelayOffset;
  18687. private _pausedDelay;
  18688. private _runtimeAnimations;
  18689. private _paused;
  18690. private _scene;
  18691. private _speedRatio;
  18692. private _weight;
  18693. private _syncRoot;
  18694. /**
  18695. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18696. * This will only apply for non looping animation (default is true)
  18697. */
  18698. disposeOnEnd: boolean;
  18699. /**
  18700. * Gets a boolean indicating if the animation has started
  18701. */
  18702. animationStarted: boolean;
  18703. /**
  18704. * Observer raised when the animation ends
  18705. */
  18706. onAnimationEndObservable: Observable<Animatable>;
  18707. /**
  18708. * Observer raised when the animation loops
  18709. */
  18710. onAnimationLoopObservable: Observable<Animatable>;
  18711. /**
  18712. * Gets the root Animatable used to synchronize and normalize animations
  18713. */
  18714. readonly syncRoot: Animatable;
  18715. /**
  18716. * Gets the current frame of the first RuntimeAnimation
  18717. * Used to synchronize Animatables
  18718. */
  18719. readonly masterFrame: number;
  18720. /**
  18721. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18722. */
  18723. weight: number;
  18724. /**
  18725. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18726. */
  18727. speedRatio: number;
  18728. /**
  18729. * Creates a new Animatable
  18730. * @param scene defines the hosting scene
  18731. * @param target defines the target object
  18732. * @param fromFrame defines the starting frame number (default is 0)
  18733. * @param toFrame defines the ending frame number (default is 100)
  18734. * @param loopAnimation defines if the animation must loop (default is false)
  18735. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18736. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18737. * @param animations defines a group of animation to add to the new Animatable
  18738. * @param onAnimationLoop defines a callback to call when animation loops
  18739. */
  18740. constructor(scene: Scene,
  18741. /** defines the target object */
  18742. target: any,
  18743. /** defines the starting frame number (default is 0) */
  18744. fromFrame?: number,
  18745. /** defines the ending frame number (default is 100) */
  18746. toFrame?: number,
  18747. /** defines if the animation must loop (default is false) */
  18748. loopAnimation?: boolean, speedRatio?: number,
  18749. /** defines a callback to call when animation ends if it is not looping */
  18750. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18751. /** defines a callback to call when animation loops */
  18752. onAnimationLoop?: (() => void) | null | undefined);
  18753. /**
  18754. * Synchronize and normalize current Animatable with a source Animatable
  18755. * This is useful when using animation weights and when animations are not of the same length
  18756. * @param root defines the root Animatable to synchronize with
  18757. * @returns the current Animatable
  18758. */
  18759. syncWith(root: Animatable): Animatable;
  18760. /**
  18761. * Gets the list of runtime animations
  18762. * @returns an array of RuntimeAnimation
  18763. */
  18764. getAnimations(): RuntimeAnimation[];
  18765. /**
  18766. * Adds more animations to the current animatable
  18767. * @param target defines the target of the animations
  18768. * @param animations defines the new animations to add
  18769. */
  18770. appendAnimations(target: any, animations: Animation[]): void;
  18771. /**
  18772. * Gets the source animation for a specific property
  18773. * @param property defines the propertyu to look for
  18774. * @returns null or the source animation for the given property
  18775. */
  18776. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18777. /**
  18778. * Gets the runtime animation for a specific property
  18779. * @param property defines the propertyu to look for
  18780. * @returns null or the runtime animation for the given property
  18781. */
  18782. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18783. /**
  18784. * Resets the animatable to its original state
  18785. */
  18786. reset(): void;
  18787. /**
  18788. * Allows the animatable to blend with current running animations
  18789. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18790. * @param blendingSpeed defines the blending speed to use
  18791. */
  18792. enableBlending(blendingSpeed: number): void;
  18793. /**
  18794. * Disable animation blending
  18795. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18796. */
  18797. disableBlending(): void;
  18798. /**
  18799. * Jump directly to a given frame
  18800. * @param frame defines the frame to jump to
  18801. */
  18802. goToFrame(frame: number): void;
  18803. /**
  18804. * Pause the animation
  18805. */
  18806. pause(): void;
  18807. /**
  18808. * Restart the animation
  18809. */
  18810. restart(): void;
  18811. private _raiseOnAnimationEnd;
  18812. /**
  18813. * Stop and delete the current animation
  18814. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18815. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  18816. */
  18817. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18818. /**
  18819. * Wait asynchronously for the animation to end
  18820. * @returns a promise which will be fullfilled when the animation ends
  18821. */
  18822. waitAsync(): Promise<Animatable>;
  18823. /** @hidden */
  18824. _animate(delay: number): boolean;
  18825. }
  18826. module "babylonjs/scene" {
  18827. interface Scene {
  18828. /** @hidden */
  18829. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18830. /** @hidden */
  18831. _processLateAnimationBindingsForMatrices(holder: {
  18832. totalWeight: number;
  18833. animations: RuntimeAnimation[];
  18834. originalValue: Matrix;
  18835. }): any;
  18836. /** @hidden */
  18837. _processLateAnimationBindingsForQuaternions(holder: {
  18838. totalWeight: number;
  18839. animations: RuntimeAnimation[];
  18840. originalValue: Quaternion;
  18841. }, refQuaternion: Quaternion): Quaternion;
  18842. /** @hidden */
  18843. _processLateAnimationBindings(): void;
  18844. /**
  18845. * Will start the animation sequence of a given target
  18846. * @param target defines the target
  18847. * @param from defines from which frame should animation start
  18848. * @param to defines until which frame should animation run.
  18849. * @param weight defines the weight to apply to the animation (1.0 by default)
  18850. * @param loop defines if the animation loops
  18851. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18852. * @param onAnimationEnd defines the function to be executed when the animation ends
  18853. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18854. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18855. * @param onAnimationLoop defines the callback to call when an animation loops
  18856. * @returns the animatable object created for this animation
  18857. */
  18858. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18859. /**
  18860. * Will start the animation sequence of a given target
  18861. * @param target defines the target
  18862. * @param from defines from which frame should animation start
  18863. * @param to defines until which frame should animation run.
  18864. * @param loop defines if the animation loops
  18865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18866. * @param onAnimationEnd defines the function to be executed when the animation ends
  18867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18870. * @param onAnimationLoop defines the callback to call when an animation loops
  18871. * @returns the animatable object created for this animation
  18872. */
  18873. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18874. /**
  18875. * Will start the animation sequence of a given target and its hierarchy
  18876. * @param target defines the target
  18877. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  18878. * @param from defines from which frame should animation start
  18879. * @param to defines until which frame should animation run.
  18880. * @param loop defines if the animation loops
  18881. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18882. * @param onAnimationEnd defines the function to be executed when the animation ends
  18883. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18884. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18885. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18886. * @param onAnimationLoop defines the callback to call when an animation loops
  18887. * @returns the list of created animatables
  18888. */
  18889. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  18890. /**
  18891. * Begin a new animation on a given node
  18892. * @param target defines the target where the animation will take place
  18893. * @param animations defines the list of animations to start
  18894. * @param from defines the initial value
  18895. * @param to defines the final value
  18896. * @param loop defines if you want animation to loop (off by default)
  18897. * @param speedRatio defines the speed ratio to apply to all animations
  18898. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18899. * @param onAnimationLoop defines the callback to call when an animation loops
  18900. * @returns the list of created animatables
  18901. */
  18902. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18903. /**
  18904. * Begin a new animation on a given node and its hierarchy
  18905. * @param target defines the root node where the animation will take place
  18906. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  18907. * @param animations defines the list of animations to start
  18908. * @param from defines the initial value
  18909. * @param to defines the final value
  18910. * @param loop defines if you want animation to loop (off by default)
  18911. * @param speedRatio defines the speed ratio to apply to all animations
  18912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18913. * @param onAnimationLoop defines the callback to call when an animation loops
  18914. * @returns the list of animatables created for all nodes
  18915. */
  18916. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18917. /**
  18918. * Gets the animatable associated with a specific target
  18919. * @param target defines the target of the animatable
  18920. * @returns the required animatable if found
  18921. */
  18922. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18923. /**
  18924. * Gets all animatables associated with a given target
  18925. * @param target defines the target to look animatables for
  18926. * @returns an array of Animatables
  18927. */
  18928. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18929. /**
  18930. * Will stop the animation of the given target
  18931. * @param target - the target
  18932. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18933. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  18934. */
  18935. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18936. /**
  18937. * Stops and removes all animations that have been applied to the scene
  18938. */
  18939. stopAllAnimations(): void;
  18940. }
  18941. }
  18942. module "babylonjs/Bones/bone" {
  18943. interface Bone {
  18944. /**
  18945. * Copy an animation range from another bone
  18946. * @param source defines the source bone
  18947. * @param rangeName defines the range name to copy
  18948. * @param frameOffset defines the frame offset
  18949. * @param rescaleAsRequired defines if rescaling must be applied if required
  18950. * @param skelDimensionsRatio defines the scaling ratio
  18951. * @returns true if operation was successful
  18952. */
  18953. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18954. }
  18955. }
  18956. }
  18957. declare module "babylonjs/Bones/skeleton" {
  18958. import { Bone } from "babylonjs/Bones/bone";
  18959. import { IAnimatable } from "babylonjs/Misc/tools";
  18960. import { Observable } from "babylonjs/Misc/observable";
  18961. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18962. import { Scene } from "babylonjs/scene";
  18963. import { Nullable } from "babylonjs/types";
  18964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18966. import { Animatable } from "babylonjs/Animations/animatable";
  18967. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18968. import { Animation } from "babylonjs/Animations/animation";
  18969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18970. /**
  18971. * Class used to handle skinning animations
  18972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18973. */
  18974. export class Skeleton implements IAnimatable {
  18975. /** defines the skeleton name */
  18976. name: string;
  18977. /** defines the skeleton Id */
  18978. id: string;
  18979. /**
  18980. * Defines the list of child bones
  18981. */
  18982. bones: Bone[];
  18983. /**
  18984. * Defines an estimate of the dimension of the skeleton at rest
  18985. */
  18986. dimensionsAtRest: Vector3;
  18987. /**
  18988. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18989. */
  18990. needInitialSkinMatrix: boolean;
  18991. /**
  18992. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18993. */
  18994. overrideMesh: Nullable<AbstractMesh>;
  18995. /**
  18996. * Gets the list of animations attached to this skeleton
  18997. */
  18998. animations: Array<Animation>;
  18999. private _scene;
  19000. private _isDirty;
  19001. private _transformMatrices;
  19002. private _transformMatrixTexture;
  19003. private _meshesWithPoseMatrix;
  19004. private _animatables;
  19005. private _identity;
  19006. private _synchronizedWithMesh;
  19007. private _ranges;
  19008. private _lastAbsoluteTransformsUpdateId;
  19009. private _canUseTextureForBones;
  19010. /** @hidden */
  19011. _numBonesWithLinkedTransformNode: number;
  19012. /**
  19013. * Specifies if the skeleton should be serialized
  19014. */
  19015. doNotSerialize: boolean;
  19016. private _useTextureToStoreBoneMatrices;
  19017. /**
  19018. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19019. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19020. */
  19021. useTextureToStoreBoneMatrices: boolean;
  19022. private _animationPropertiesOverride;
  19023. /**
  19024. * Gets or sets the animation properties override
  19025. */
  19026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19027. /**
  19028. * An observable triggered before computing the skeleton's matrices
  19029. */
  19030. onBeforeComputeObservable: Observable<Skeleton>;
  19031. /**
  19032. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19033. */
  19034. readonly isUsingTextureForMatrices: boolean;
  19035. /**
  19036. * Creates a new skeleton
  19037. * @param name defines the skeleton name
  19038. * @param id defines the skeleton Id
  19039. * @param scene defines the hosting scene
  19040. */
  19041. constructor(
  19042. /** defines the skeleton name */
  19043. name: string,
  19044. /** defines the skeleton Id */
  19045. id: string, scene: Scene);
  19046. /**
  19047. * Gets the current object class name.
  19048. * @return the class name
  19049. */
  19050. getClassName(): string;
  19051. /**
  19052. * Returns an array containing the root bones
  19053. * @returns an array containing the root bones
  19054. */
  19055. getChildren(): Array<Bone>;
  19056. /**
  19057. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19058. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19059. * @returns a Float32Array containing matrices data
  19060. */
  19061. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19062. /**
  19063. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19064. * @returns a raw texture containing the data
  19065. */
  19066. getTransformMatrixTexture(): Nullable<RawTexture>;
  19067. /**
  19068. * Gets the current hosting scene
  19069. * @returns a scene object
  19070. */
  19071. getScene(): Scene;
  19072. /**
  19073. * Gets a string representing the current skeleton data
  19074. * @param fullDetails defines a boolean indicating if we want a verbose version
  19075. * @returns a string representing the current skeleton data
  19076. */
  19077. toString(fullDetails?: boolean): string;
  19078. /**
  19079. * Get bone's index searching by name
  19080. * @param name defines bone's name to search for
  19081. * @return the indice of the bone. Returns -1 if not found
  19082. */
  19083. getBoneIndexByName(name: string): number;
  19084. /**
  19085. * Creater a new animation range
  19086. * @param name defines the name of the range
  19087. * @param from defines the start key
  19088. * @param to defines the end key
  19089. */
  19090. createAnimationRange(name: string, from: number, to: number): void;
  19091. /**
  19092. * Delete a specific animation range
  19093. * @param name defines the name of the range
  19094. * @param deleteFrames defines if frames must be removed as well
  19095. */
  19096. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19097. /**
  19098. * Gets a specific animation range
  19099. * @param name defines the name of the range to look for
  19100. * @returns the requested animation range or null if not found
  19101. */
  19102. getAnimationRange(name: string): Nullable<AnimationRange>;
  19103. /**
  19104. * Gets the list of all animation ranges defined on this skeleton
  19105. * @returns an array
  19106. */
  19107. getAnimationRanges(): Nullable<AnimationRange>[];
  19108. /**
  19109. * Copy animation range from a source skeleton.
  19110. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19111. * @param source defines the source skeleton
  19112. * @param name defines the name of the range to copy
  19113. * @param rescaleAsRequired defines if rescaling must be applied if required
  19114. * @returns true if operation was successful
  19115. */
  19116. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19117. /**
  19118. * Forces the skeleton to go to rest pose
  19119. */
  19120. returnToRest(): void;
  19121. private _getHighestAnimationFrame;
  19122. /**
  19123. * Begin a specific animation range
  19124. * @param name defines the name of the range to start
  19125. * @param loop defines if looping must be turned on (false by default)
  19126. * @param speedRatio defines the speed ratio to apply (1 by default)
  19127. * @param onAnimationEnd defines a callback which will be called when animation will end
  19128. * @returns a new animatable
  19129. */
  19130. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19131. /** @hidden */
  19132. _markAsDirty(): void;
  19133. /** @hidden */
  19134. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19135. /** @hidden */
  19136. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19137. private _computeTransformMatrices;
  19138. /**
  19139. * Build all resources required to render a skeleton
  19140. */
  19141. prepare(): void;
  19142. /**
  19143. * Gets the list of animatables currently running for this skeleton
  19144. * @returns an array of animatables
  19145. */
  19146. getAnimatables(): IAnimatable[];
  19147. /**
  19148. * Clone the current skeleton
  19149. * @param name defines the name of the new skeleton
  19150. * @param id defines the id of the enw skeleton
  19151. * @returns the new skeleton
  19152. */
  19153. clone(name: string, id: string): Skeleton;
  19154. /**
  19155. * Enable animation blending for this skeleton
  19156. * @param blendingSpeed defines the blending speed to apply
  19157. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19158. */
  19159. enableBlending(blendingSpeed?: number): void;
  19160. /**
  19161. * Releases all resources associated with the current skeleton
  19162. */
  19163. dispose(): void;
  19164. /**
  19165. * Serialize the skeleton in a JSON object
  19166. * @returns a JSON object
  19167. */
  19168. serialize(): any;
  19169. /**
  19170. * Creates a new skeleton from serialized data
  19171. * @param parsedSkeleton defines the serialized data
  19172. * @param scene defines the hosting scene
  19173. * @returns a new skeleton
  19174. */
  19175. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19176. /**
  19177. * Compute all node absolute transforms
  19178. * @param forceUpdate defines if computation must be done even if cache is up to date
  19179. */
  19180. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19181. /**
  19182. * Gets the root pose matrix
  19183. * @returns a matrix
  19184. */
  19185. getPoseMatrix(): Nullable<Matrix>;
  19186. /**
  19187. * Sorts bones per internal index
  19188. */
  19189. sortBones(): void;
  19190. private _sortBones;
  19191. }
  19192. }
  19193. declare module "babylonjs/Morph/morphTarget" {
  19194. import { IAnimatable } from "babylonjs/Misc/tools";
  19195. import { Observable } from "babylonjs/Misc/observable";
  19196. import { Nullable, FloatArray } from "babylonjs/types";
  19197. import { Scene } from "babylonjs/scene";
  19198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19199. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19200. /**
  19201. * Defines a target to use with MorphTargetManager
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19203. */
  19204. export class MorphTarget implements IAnimatable {
  19205. /** defines the name of the target */
  19206. name: string;
  19207. /**
  19208. * Gets or sets the list of animations
  19209. */
  19210. animations: import("babylonjs/Animations/animation").Animation[];
  19211. private _scene;
  19212. private _positions;
  19213. private _normals;
  19214. private _tangents;
  19215. private _influence;
  19216. /**
  19217. * Observable raised when the influence changes
  19218. */
  19219. onInfluenceChanged: Observable<boolean>;
  19220. /** @hidden */
  19221. _onDataLayoutChanged: Observable<void>;
  19222. /**
  19223. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19224. */
  19225. influence: number;
  19226. /**
  19227. * Gets or sets the id of the morph Target
  19228. */
  19229. id: string;
  19230. private _animationPropertiesOverride;
  19231. /**
  19232. * Gets or sets the animation properties override
  19233. */
  19234. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19235. /**
  19236. * Creates a new MorphTarget
  19237. * @param name defines the name of the target
  19238. * @param influence defines the influence to use
  19239. * @param scene defines the scene the morphtarget belongs to
  19240. */
  19241. constructor(
  19242. /** defines the name of the target */
  19243. name: string, influence?: number, scene?: Nullable<Scene>);
  19244. /**
  19245. * Gets a boolean defining if the target contains position data
  19246. */
  19247. readonly hasPositions: boolean;
  19248. /**
  19249. * Gets a boolean defining if the target contains normal data
  19250. */
  19251. readonly hasNormals: boolean;
  19252. /**
  19253. * Gets a boolean defining if the target contains tangent data
  19254. */
  19255. readonly hasTangents: boolean;
  19256. /**
  19257. * Affects position data to this target
  19258. * @param data defines the position data to use
  19259. */
  19260. setPositions(data: Nullable<FloatArray>): void;
  19261. /**
  19262. * Gets the position data stored in this target
  19263. * @returns a FloatArray containing the position data (or null if not present)
  19264. */
  19265. getPositions(): Nullable<FloatArray>;
  19266. /**
  19267. * Affects normal data to this target
  19268. * @param data defines the normal data to use
  19269. */
  19270. setNormals(data: Nullable<FloatArray>): void;
  19271. /**
  19272. * Gets the normal data stored in this target
  19273. * @returns a FloatArray containing the normal data (or null if not present)
  19274. */
  19275. getNormals(): Nullable<FloatArray>;
  19276. /**
  19277. * Affects tangent data to this target
  19278. * @param data defines the tangent data to use
  19279. */
  19280. setTangents(data: Nullable<FloatArray>): void;
  19281. /**
  19282. * Gets the tangent data stored in this target
  19283. * @returns a FloatArray containing the tangent data (or null if not present)
  19284. */
  19285. getTangents(): Nullable<FloatArray>;
  19286. /**
  19287. * Serializes the current target into a Serialization object
  19288. * @returns the serialized object
  19289. */
  19290. serialize(): any;
  19291. /**
  19292. * Returns the string "MorphTarget"
  19293. * @returns "MorphTarget"
  19294. */
  19295. getClassName(): string;
  19296. /**
  19297. * Creates a new target from serialized data
  19298. * @param serializationObject defines the serialized data to use
  19299. * @returns a new MorphTarget
  19300. */
  19301. static Parse(serializationObject: any): MorphTarget;
  19302. /**
  19303. * Creates a MorphTarget from mesh data
  19304. * @param mesh defines the source mesh
  19305. * @param name defines the name to use for the new target
  19306. * @param influence defines the influence to attach to the target
  19307. * @returns a new MorphTarget
  19308. */
  19309. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19310. }
  19311. }
  19312. declare module "babylonjs/Morph/morphTargetManager" {
  19313. import { Nullable } from "babylonjs/types";
  19314. import { Scene } from "babylonjs/scene";
  19315. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19316. /**
  19317. * This class is used to deform meshes using morphing between different targets
  19318. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19319. */
  19320. export class MorphTargetManager {
  19321. private _targets;
  19322. private _targetInfluenceChangedObservers;
  19323. private _targetDataLayoutChangedObservers;
  19324. private _activeTargets;
  19325. private _scene;
  19326. private _influences;
  19327. private _supportsNormals;
  19328. private _supportsTangents;
  19329. private _vertexCount;
  19330. private _uniqueId;
  19331. private _tempInfluences;
  19332. /**
  19333. * Creates a new MorphTargetManager
  19334. * @param scene defines the current scene
  19335. */
  19336. constructor(scene?: Nullable<Scene>);
  19337. /**
  19338. * Gets the unique ID of this manager
  19339. */
  19340. readonly uniqueId: number;
  19341. /**
  19342. * Gets the number of vertices handled by this manager
  19343. */
  19344. readonly vertexCount: number;
  19345. /**
  19346. * Gets a boolean indicating if this manager supports morphing of normals
  19347. */
  19348. readonly supportsNormals: boolean;
  19349. /**
  19350. * Gets a boolean indicating if this manager supports morphing of tangents
  19351. */
  19352. readonly supportsTangents: boolean;
  19353. /**
  19354. * Gets the number of targets stored in this manager
  19355. */
  19356. readonly numTargets: number;
  19357. /**
  19358. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19359. */
  19360. readonly numInfluencers: number;
  19361. /**
  19362. * Gets the list of influences (one per target)
  19363. */
  19364. readonly influences: Float32Array;
  19365. /**
  19366. * Gets the active target at specified index. An active target is a target with an influence > 0
  19367. * @param index defines the index to check
  19368. * @returns the requested target
  19369. */
  19370. getActiveTarget(index: number): MorphTarget;
  19371. /**
  19372. * Gets the target at specified index
  19373. * @param index defines the index to check
  19374. * @returns the requested target
  19375. */
  19376. getTarget(index: number): MorphTarget;
  19377. /**
  19378. * Add a new target to this manager
  19379. * @param target defines the target to add
  19380. */
  19381. addTarget(target: MorphTarget): void;
  19382. /**
  19383. * Removes a target from the manager
  19384. * @param target defines the target to remove
  19385. */
  19386. removeTarget(target: MorphTarget): void;
  19387. /**
  19388. * Serializes the current manager into a Serialization object
  19389. * @returns the serialized object
  19390. */
  19391. serialize(): any;
  19392. private _syncActiveTargets;
  19393. /**
  19394. * Syncrhonize the targets with all the meshes using this morph target manager
  19395. */
  19396. synchronize(): void;
  19397. /**
  19398. * Creates a new MorphTargetManager from serialized data
  19399. * @param serializationObject defines the serialized data
  19400. * @param scene defines the hosting scene
  19401. * @returns the new MorphTargetManager
  19402. */
  19403. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19404. }
  19405. }
  19406. declare module "babylonjs/Meshes/groundMesh" {
  19407. import { Scene } from "babylonjs/scene";
  19408. import { Vector3 } from "babylonjs/Maths/math";
  19409. import { Mesh } from "babylonjs/Meshes/mesh";
  19410. /**
  19411. * Mesh representing the gorund
  19412. */
  19413. export class GroundMesh extends Mesh {
  19414. /** If octree should be generated */
  19415. generateOctree: boolean;
  19416. private _heightQuads;
  19417. /** @hidden */
  19418. _subdivisionsX: number;
  19419. /** @hidden */
  19420. _subdivisionsY: number;
  19421. /** @hidden */
  19422. _width: number;
  19423. /** @hidden */
  19424. _height: number;
  19425. /** @hidden */
  19426. _minX: number;
  19427. /** @hidden */
  19428. _maxX: number;
  19429. /** @hidden */
  19430. _minZ: number;
  19431. /** @hidden */
  19432. _maxZ: number;
  19433. constructor(name: string, scene: Scene);
  19434. /**
  19435. * "GroundMesh"
  19436. * @returns "GroundMesh"
  19437. */
  19438. getClassName(): string;
  19439. /**
  19440. * The minimum of x and y subdivisions
  19441. */
  19442. readonly subdivisions: number;
  19443. /**
  19444. * X subdivisions
  19445. */
  19446. readonly subdivisionsX: number;
  19447. /**
  19448. * Y subdivisions
  19449. */
  19450. readonly subdivisionsY: number;
  19451. /**
  19452. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19454. * @param chunksCount the number of subdivisions for x and y
  19455. * @param octreeBlocksSize (Default: 32)
  19456. */
  19457. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19458. /**
  19459. * Returns a height (y) value in the Worl system :
  19460. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19461. * @param x x coordinate
  19462. * @param z z coordinate
  19463. * @returns the ground y position if (x, z) are outside the ground surface.
  19464. */
  19465. getHeightAtCoordinates(x: number, z: number): number;
  19466. /**
  19467. * Returns a normalized vector (Vector3) orthogonal to the ground
  19468. * at the ground coordinates (x, z) expressed in the World system.
  19469. * @param x x coordinate
  19470. * @param z z coordinate
  19471. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19472. */
  19473. getNormalAtCoordinates(x: number, z: number): Vector3;
  19474. /**
  19475. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19476. * at the ground coordinates (x, z) expressed in the World system.
  19477. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19478. * @param x x coordinate
  19479. * @param z z coordinate
  19480. * @param ref vector to store the result
  19481. * @returns the GroundMesh.
  19482. */
  19483. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19484. /**
  19485. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19486. * if the ground has been updated.
  19487. * This can be used in the render loop.
  19488. * @returns the GroundMesh.
  19489. */
  19490. updateCoordinateHeights(): GroundMesh;
  19491. private _getFacetAt;
  19492. private _initHeightQuads;
  19493. private _computeHeightQuads;
  19494. /**
  19495. * Serializes this ground mesh
  19496. * @param serializationObject object to write serialization to
  19497. */
  19498. serialize(serializationObject: any): void;
  19499. /**
  19500. * Parses a serialized ground mesh
  19501. * @param parsedMesh the serialized mesh
  19502. * @param scene the scene to create the ground mesh in
  19503. * @returns the created ground mesh
  19504. */
  19505. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19506. }
  19507. }
  19508. declare module "babylonjs/Physics/physicsJoint" {
  19509. import { Vector3 } from "babylonjs/Maths/math";
  19510. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19511. /**
  19512. * Interface for Physics-Joint data
  19513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19514. */
  19515. export interface PhysicsJointData {
  19516. /**
  19517. * The main pivot of the joint
  19518. */
  19519. mainPivot?: Vector3;
  19520. /**
  19521. * The connected pivot of the joint
  19522. */
  19523. connectedPivot?: Vector3;
  19524. /**
  19525. * The main axis of the joint
  19526. */
  19527. mainAxis?: Vector3;
  19528. /**
  19529. * The connected axis of the joint
  19530. */
  19531. connectedAxis?: Vector3;
  19532. /**
  19533. * The collision of the joint
  19534. */
  19535. collision?: boolean;
  19536. /**
  19537. * Native Oimo/Cannon/Energy data
  19538. */
  19539. nativeParams?: any;
  19540. }
  19541. /**
  19542. * This is a holder class for the physics joint created by the physics plugin
  19543. * It holds a set of functions to control the underlying joint
  19544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19545. */
  19546. export class PhysicsJoint {
  19547. /**
  19548. * The type of the physics joint
  19549. */
  19550. type: number;
  19551. /**
  19552. * The data for the physics joint
  19553. */
  19554. jointData: PhysicsJointData;
  19555. private _physicsJoint;
  19556. protected _physicsPlugin: IPhysicsEnginePlugin;
  19557. /**
  19558. * Initializes the physics joint
  19559. * @param type The type of the physics joint
  19560. * @param jointData The data for the physics joint
  19561. */
  19562. constructor(
  19563. /**
  19564. * The type of the physics joint
  19565. */
  19566. type: number,
  19567. /**
  19568. * The data for the physics joint
  19569. */
  19570. jointData: PhysicsJointData);
  19571. /**
  19572. * Gets the physics joint
  19573. */
  19574. /**
  19575. * Sets the physics joint
  19576. */
  19577. physicsJoint: any;
  19578. /**
  19579. * Sets the physics plugin
  19580. */
  19581. physicsPlugin: IPhysicsEnginePlugin;
  19582. /**
  19583. * Execute a function that is physics-plugin specific.
  19584. * @param {Function} func the function that will be executed.
  19585. * It accepts two parameters: the physics world and the physics joint
  19586. */
  19587. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19588. /**
  19589. * Distance-Joint type
  19590. */
  19591. static DistanceJoint: number;
  19592. /**
  19593. * Hinge-Joint type
  19594. */
  19595. static HingeJoint: number;
  19596. /**
  19597. * Ball-and-Socket joint type
  19598. */
  19599. static BallAndSocketJoint: number;
  19600. /**
  19601. * Wheel-Joint type
  19602. */
  19603. static WheelJoint: number;
  19604. /**
  19605. * Slider-Joint type
  19606. */
  19607. static SliderJoint: number;
  19608. /**
  19609. * Prismatic-Joint type
  19610. */
  19611. static PrismaticJoint: number;
  19612. /**
  19613. * Universal-Joint type
  19614. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19615. */
  19616. static UniversalJoint: number;
  19617. /**
  19618. * Hinge-Joint 2 type
  19619. */
  19620. static Hinge2Joint: number;
  19621. /**
  19622. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19623. */
  19624. static PointToPointJoint: number;
  19625. /**
  19626. * Spring-Joint type
  19627. */
  19628. static SpringJoint: number;
  19629. /**
  19630. * Lock-Joint type
  19631. */
  19632. static LockJoint: number;
  19633. }
  19634. /**
  19635. * A class representing a physics distance joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export class DistanceJoint extends PhysicsJoint {
  19639. /**
  19640. *
  19641. * @param jointData The data for the Distance-Joint
  19642. */
  19643. constructor(jointData: DistanceJointData);
  19644. /**
  19645. * Update the predefined distance.
  19646. * @param maxDistance The maximum preferred distance
  19647. * @param minDistance The minimum preferred distance
  19648. */
  19649. updateDistance(maxDistance: number, minDistance?: number): void;
  19650. }
  19651. /**
  19652. * Represents a Motor-Enabled Joint
  19653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19654. */
  19655. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19656. /**
  19657. * Initializes the Motor-Enabled Joint
  19658. * @param type The type of the joint
  19659. * @param jointData The physica joint data for the joint
  19660. */
  19661. constructor(type: number, jointData: PhysicsJointData);
  19662. /**
  19663. * Set the motor values.
  19664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19665. * @param force the force to apply
  19666. * @param maxForce max force for this motor.
  19667. */
  19668. setMotor(force?: number, maxForce?: number): void;
  19669. /**
  19670. * Set the motor's limits.
  19671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19672. * @param upperLimit The upper limit of the motor
  19673. * @param lowerLimit The lower limit of the motor
  19674. */
  19675. setLimit(upperLimit: number, lowerLimit?: number): void;
  19676. }
  19677. /**
  19678. * This class represents a single physics Hinge-Joint
  19679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export class HingeJoint extends MotorEnabledJoint {
  19682. /**
  19683. * Initializes the Hinge-Joint
  19684. * @param jointData The joint data for the Hinge-Joint
  19685. */
  19686. constructor(jointData: PhysicsJointData);
  19687. /**
  19688. * Set the motor values.
  19689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19690. * @param {number} force the force to apply
  19691. * @param {number} maxForce max force for this motor.
  19692. */
  19693. setMotor(force?: number, maxForce?: number): void;
  19694. /**
  19695. * Set the motor's limits.
  19696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19697. * @param upperLimit The upper limit of the motor
  19698. * @param lowerLimit The lower limit of the motor
  19699. */
  19700. setLimit(upperLimit: number, lowerLimit?: number): void;
  19701. }
  19702. /**
  19703. * This class represents a dual hinge physics joint (same as wheel joint)
  19704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19705. */
  19706. export class Hinge2Joint extends MotorEnabledJoint {
  19707. /**
  19708. * Initializes the Hinge2-Joint
  19709. * @param jointData The joint data for the Hinge2-Joint
  19710. */
  19711. constructor(jointData: PhysicsJointData);
  19712. /**
  19713. * Set the motor values.
  19714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19715. * @param {number} targetSpeed the speed the motor is to reach
  19716. * @param {number} maxForce max force for this motor.
  19717. * @param {motorIndex} the motor's index, 0 or 1.
  19718. */
  19719. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19720. /**
  19721. * Set the motor limits.
  19722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19723. * @param {number} upperLimit the upper limit
  19724. * @param {number} lowerLimit lower limit
  19725. * @param {motorIndex} the motor's index, 0 or 1.
  19726. */
  19727. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19728. }
  19729. /**
  19730. * Interface for a motor enabled joint
  19731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19732. */
  19733. export interface IMotorEnabledJoint {
  19734. /**
  19735. * Physics joint
  19736. */
  19737. physicsJoint: any;
  19738. /**
  19739. * Sets the motor of the motor-enabled joint
  19740. * @param force The force of the motor
  19741. * @param maxForce The maximum force of the motor
  19742. * @param motorIndex The index of the motor
  19743. */
  19744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19745. /**
  19746. * Sets the limit of the motor
  19747. * @param upperLimit The upper limit of the motor
  19748. * @param lowerLimit The lower limit of the motor
  19749. * @param motorIndex The index of the motor
  19750. */
  19751. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19752. }
  19753. /**
  19754. * Joint data for a Distance-Joint
  19755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface DistanceJointData extends PhysicsJointData {
  19758. /**
  19759. * Max distance the 2 joint objects can be apart
  19760. */
  19761. maxDistance: number;
  19762. }
  19763. /**
  19764. * Joint data from a spring joint
  19765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19766. */
  19767. export interface SpringJointData extends PhysicsJointData {
  19768. /**
  19769. * Length of the spring
  19770. */
  19771. length: number;
  19772. /**
  19773. * Stiffness of the spring
  19774. */
  19775. stiffness: number;
  19776. /**
  19777. * Damping of the spring
  19778. */
  19779. damping: number;
  19780. /** this callback will be called when applying the force to the impostors. */
  19781. forceApplicationCallback: () => void;
  19782. }
  19783. }
  19784. declare module "babylonjs/Physics/IPhysicsEngine" {
  19785. import { Nullable } from "babylonjs/types";
  19786. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19788. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19789. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19790. /**
  19791. * Interface used to describe a physics joint
  19792. */
  19793. export interface PhysicsImpostorJoint {
  19794. /** Defines the main impostor to which the joint is linked */
  19795. mainImpostor: PhysicsImpostor;
  19796. /** Defines the impostor that is connected to the main impostor using this joint */
  19797. connectedImpostor: PhysicsImpostor;
  19798. /** Defines the joint itself */
  19799. joint: PhysicsJoint;
  19800. }
  19801. /** @hidden */
  19802. export interface IPhysicsEnginePlugin {
  19803. world: any;
  19804. name: string;
  19805. setGravity(gravity: Vector3): void;
  19806. setTimeStep(timeStep: number): void;
  19807. getTimeStep(): number;
  19808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19812. removePhysicsBody(impostor: PhysicsImpostor): void;
  19813. generateJoint(joint: PhysicsImpostorJoint): void;
  19814. removeJoint(joint: PhysicsImpostorJoint): void;
  19815. isSupported(): boolean;
  19816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19818. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19823. getBodyMass(impostor: PhysicsImpostor): number;
  19824. getBodyFriction(impostor: PhysicsImpostor): number;
  19825. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19826. getBodyRestitution(impostor: PhysicsImpostor): number;
  19827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19828. sleepBody(impostor: PhysicsImpostor): void;
  19829. wakeUpBody(impostor: PhysicsImpostor): void;
  19830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19831. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19833. getRadius(impostor: PhysicsImpostor): number;
  19834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19835. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19836. dispose(): void;
  19837. }
  19838. /**
  19839. * Interface used to define a physics engine
  19840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export interface IPhysicsEngine {
  19843. /**
  19844. * Gets the gravity vector used by the simulation
  19845. */
  19846. gravity: Vector3;
  19847. /**
  19848. * Sets the gravity vector used by the simulation
  19849. * @param gravity defines the gravity vector to use
  19850. */
  19851. setGravity(gravity: Vector3): void;
  19852. /**
  19853. * Set the time step of the physics engine.
  19854. * Default is 1/60.
  19855. * To slow it down, enter 1/600 for example.
  19856. * To speed it up, 1/30
  19857. * @param newTimeStep the new timestep to apply to this world.
  19858. */
  19859. setTimeStep(newTimeStep: number): void;
  19860. /**
  19861. * Get the time step of the physics engine.
  19862. * @returns the current time step
  19863. */
  19864. getTimeStep(): number;
  19865. /**
  19866. * Release all resources
  19867. */
  19868. dispose(): void;
  19869. /**
  19870. * Gets the name of the current physics plugin
  19871. * @returns the name of the plugin
  19872. */
  19873. getPhysicsPluginName(): string;
  19874. /**
  19875. * Adding a new impostor for the impostor tracking.
  19876. * This will be done by the impostor itself.
  19877. * @param impostor the impostor to add
  19878. */
  19879. addImpostor(impostor: PhysicsImpostor): void;
  19880. /**
  19881. * Remove an impostor from the engine.
  19882. * This impostor and its mesh will not longer be updated by the physics engine.
  19883. * @param impostor the impostor to remove
  19884. */
  19885. removeImpostor(impostor: PhysicsImpostor): void;
  19886. /**
  19887. * Add a joint to the physics engine
  19888. * @param mainImpostor defines the main impostor to which the joint is added.
  19889. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19890. * @param joint defines the joint that will connect both impostors.
  19891. */
  19892. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19893. /**
  19894. * Removes a joint from the simulation
  19895. * @param mainImpostor defines the impostor used with the joint
  19896. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19897. * @param joint defines the joint to remove
  19898. */
  19899. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19900. /**
  19901. * Gets the current plugin used to run the simulation
  19902. * @returns current plugin
  19903. */
  19904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19905. /**
  19906. * Gets the list of physic impostors
  19907. * @returns an array of PhysicsImpostor
  19908. */
  19909. getImpostors(): Array<PhysicsImpostor>;
  19910. /**
  19911. * Gets the impostor for a physics enabled object
  19912. * @param object defines the object impersonated by the impostor
  19913. * @returns the PhysicsImpostor or null if not found
  19914. */
  19915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19916. /**
  19917. * Gets the impostor for a physics body object
  19918. * @param body defines physics body used by the impostor
  19919. * @returns the PhysicsImpostor or null if not found
  19920. */
  19921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19922. /**
  19923. * Called by the scene. No need to call it.
  19924. * @param delta defines the timespam between frames
  19925. */
  19926. _step(delta: number): void;
  19927. }
  19928. }
  19929. declare module "babylonjs/Physics/physicsImpostor" {
  19930. import { Nullable, IndicesArray } from "babylonjs/types";
  19931. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19932. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19934. import { Scene } from "babylonjs/scene";
  19935. import { Bone } from "babylonjs/Bones/bone";
  19936. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19937. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19938. /**
  19939. * The interface for the physics imposter parameters
  19940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19941. */
  19942. export interface PhysicsImpostorParameters {
  19943. /**
  19944. * The mass of the physics imposter
  19945. */
  19946. mass: number;
  19947. /**
  19948. * The friction of the physics imposter
  19949. */
  19950. friction?: number;
  19951. /**
  19952. * The coefficient of restitution of the physics imposter
  19953. */
  19954. restitution?: number;
  19955. /**
  19956. * The native options of the physics imposter
  19957. */
  19958. nativeOptions?: any;
  19959. /**
  19960. * Specifies if the parent should be ignored
  19961. */
  19962. ignoreParent?: boolean;
  19963. /**
  19964. * Specifies if bi-directional transformations should be disabled
  19965. */
  19966. disableBidirectionalTransformation?: boolean;
  19967. }
  19968. /**
  19969. * Interface for a physics-enabled object
  19970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19971. */
  19972. export interface IPhysicsEnabledObject {
  19973. /**
  19974. * The position of the physics-enabled object
  19975. */
  19976. position: Vector3;
  19977. /**
  19978. * The rotation of the physics-enabled object
  19979. */
  19980. rotationQuaternion: Nullable<Quaternion>;
  19981. /**
  19982. * The scale of the physics-enabled object
  19983. */
  19984. scaling: Vector3;
  19985. /**
  19986. * The rotation of the physics-enabled object
  19987. */
  19988. rotation?: Vector3;
  19989. /**
  19990. * The parent of the physics-enabled object
  19991. */
  19992. parent?: any;
  19993. /**
  19994. * The bounding info of the physics-enabled object
  19995. * @returns The bounding info of the physics-enabled object
  19996. */
  19997. getBoundingInfo(): BoundingInfo;
  19998. /**
  19999. * Computes the world matrix
  20000. * @param force Specifies if the world matrix should be computed by force
  20001. * @returns A world matrix
  20002. */
  20003. computeWorldMatrix(force: boolean): Matrix;
  20004. /**
  20005. * Gets the world matrix
  20006. * @returns A world matrix
  20007. */
  20008. getWorldMatrix?(): Matrix;
  20009. /**
  20010. * Gets the child meshes
  20011. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20012. * @returns An array of abstract meshes
  20013. */
  20014. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20015. /**
  20016. * Gets the vertex data
  20017. * @param kind The type of vertex data
  20018. * @returns A nullable array of numbers, or a float32 array
  20019. */
  20020. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20021. /**
  20022. * Gets the indices from the mesh
  20023. * @returns A nullable array of index arrays
  20024. */
  20025. getIndices?(): Nullable<IndicesArray>;
  20026. /**
  20027. * Gets the scene from the mesh
  20028. * @returns the indices array or null
  20029. */
  20030. getScene?(): Scene;
  20031. /**
  20032. * Gets the absolute position from the mesh
  20033. * @returns the absolute position
  20034. */
  20035. getAbsolutePosition(): Vector3;
  20036. /**
  20037. * Gets the absolute pivot point from the mesh
  20038. * @returns the absolute pivot point
  20039. */
  20040. getAbsolutePivotPoint(): Vector3;
  20041. /**
  20042. * Rotates the mesh
  20043. * @param axis The axis of rotation
  20044. * @param amount The amount of rotation
  20045. * @param space The space of the rotation
  20046. * @returns The rotation transform node
  20047. */
  20048. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20049. /**
  20050. * Translates the mesh
  20051. * @param axis The axis of translation
  20052. * @param distance The distance of translation
  20053. * @param space The space of the translation
  20054. * @returns The transform node
  20055. */
  20056. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20057. /**
  20058. * Sets the absolute position of the mesh
  20059. * @param absolutePosition The absolute position of the mesh
  20060. * @returns The transform node
  20061. */
  20062. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20063. /**
  20064. * Gets the class name of the mesh
  20065. * @returns The class name
  20066. */
  20067. getClassName(): string;
  20068. }
  20069. /**
  20070. * Represents a physics imposter
  20071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20072. */
  20073. export class PhysicsImpostor {
  20074. /**
  20075. * The physics-enabled object used as the physics imposter
  20076. */
  20077. object: IPhysicsEnabledObject;
  20078. /**
  20079. * The type of the physics imposter
  20080. */
  20081. type: number;
  20082. private _options;
  20083. private _scene?;
  20084. /**
  20085. * The default object size of the imposter
  20086. */
  20087. static DEFAULT_OBJECT_SIZE: Vector3;
  20088. /**
  20089. * The identity quaternion of the imposter
  20090. */
  20091. static IDENTITY_QUATERNION: Quaternion;
  20092. /** @hidden */
  20093. _pluginData: any;
  20094. private _physicsEngine;
  20095. private _physicsBody;
  20096. private _bodyUpdateRequired;
  20097. private _onBeforePhysicsStepCallbacks;
  20098. private _onAfterPhysicsStepCallbacks;
  20099. /** @hidden */
  20100. _onPhysicsCollideCallbacks: Array<{
  20101. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20102. otherImpostors: Array<PhysicsImpostor>;
  20103. }>;
  20104. private _deltaPosition;
  20105. private _deltaRotation;
  20106. private _deltaRotationConjugated;
  20107. private _parent;
  20108. private _isDisposed;
  20109. private static _tmpVecs;
  20110. private static _tmpQuat;
  20111. /**
  20112. * Specifies if the physics imposter is disposed
  20113. */
  20114. readonly isDisposed: boolean;
  20115. /**
  20116. * Gets the mass of the physics imposter
  20117. */
  20118. mass: number;
  20119. /**
  20120. * Gets the coefficient of friction
  20121. */
  20122. /**
  20123. * Sets the coefficient of friction
  20124. */
  20125. friction: number;
  20126. /**
  20127. * Gets the coefficient of restitution
  20128. */
  20129. /**
  20130. * Sets the coefficient of restitution
  20131. */
  20132. restitution: number;
  20133. /**
  20134. * The unique id of the physics imposter
  20135. * set by the physics engine when adding this impostor to the array
  20136. */
  20137. uniqueId: number;
  20138. private _joints;
  20139. /**
  20140. * Initializes the physics imposter
  20141. * @param object The physics-enabled object used as the physics imposter
  20142. * @param type The type of the physics imposter
  20143. * @param _options The options for the physics imposter
  20144. * @param _scene The Babylon scene
  20145. */
  20146. constructor(
  20147. /**
  20148. * The physics-enabled object used as the physics imposter
  20149. */
  20150. object: IPhysicsEnabledObject,
  20151. /**
  20152. * The type of the physics imposter
  20153. */
  20154. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20155. /**
  20156. * This function will completly initialize this impostor.
  20157. * It will create a new body - but only if this mesh has no parent.
  20158. * If it has, this impostor will not be used other than to define the impostor
  20159. * of the child mesh.
  20160. * @hidden
  20161. */
  20162. _init(): void;
  20163. private _getPhysicsParent;
  20164. /**
  20165. * Should a new body be generated.
  20166. * @returns boolean specifying if body initialization is required
  20167. */
  20168. isBodyInitRequired(): boolean;
  20169. /**
  20170. * Sets the updated scaling
  20171. * @param updated Specifies if the scaling is updated
  20172. */
  20173. setScalingUpdated(): void;
  20174. /**
  20175. * Force a regeneration of this or the parent's impostor's body.
  20176. * Use under cautious - This will remove all joints already implemented.
  20177. */
  20178. forceUpdate(): void;
  20179. /**
  20180. * Gets the body that holds this impostor. Either its own, or its parent.
  20181. */
  20182. /**
  20183. * Set the physics body. Used mainly by the physics engine/plugin
  20184. */
  20185. physicsBody: any;
  20186. /**
  20187. * Get the parent of the physics imposter
  20188. * @returns Physics imposter or null
  20189. */
  20190. /**
  20191. * Sets the parent of the physics imposter
  20192. */
  20193. parent: Nullable<PhysicsImpostor>;
  20194. /**
  20195. * Resets the update flags
  20196. */
  20197. resetUpdateFlags(): void;
  20198. /**
  20199. * Gets the object extend size
  20200. * @returns the object extend size
  20201. */
  20202. getObjectExtendSize(): Vector3;
  20203. /**
  20204. * Gets the object center
  20205. * @returns The object center
  20206. */
  20207. getObjectCenter(): Vector3;
  20208. /**
  20209. * Get a specific parametes from the options parameter
  20210. * @param paramName The object parameter name
  20211. * @returns The object parameter
  20212. */
  20213. getParam(paramName: string): any;
  20214. /**
  20215. * Sets a specific parameter in the options given to the physics plugin
  20216. * @param paramName The parameter name
  20217. * @param value The value of the parameter
  20218. */
  20219. setParam(paramName: string, value: number): void;
  20220. /**
  20221. * Specifically change the body's mass option. Won't recreate the physics body object
  20222. * @param mass The mass of the physics imposter
  20223. */
  20224. setMass(mass: number): void;
  20225. /**
  20226. * Gets the linear velocity
  20227. * @returns linear velocity or null
  20228. */
  20229. getLinearVelocity(): Nullable<Vector3>;
  20230. /**
  20231. * Sets the linear velocity
  20232. * @param velocity linear velocity or null
  20233. */
  20234. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20235. /**
  20236. * Gets the angular velocity
  20237. * @returns angular velocity or null
  20238. */
  20239. getAngularVelocity(): Nullable<Vector3>;
  20240. /**
  20241. * Sets the angular velocity
  20242. * @param velocity The velocity or null
  20243. */
  20244. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20245. /**
  20246. * Execute a function with the physics plugin native code
  20247. * Provide a function the will have two variables - the world object and the physics body object
  20248. * @param func The function to execute with the physics plugin native code
  20249. */
  20250. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20251. /**
  20252. * Register a function that will be executed before the physics world is stepping forward
  20253. * @param func The function to execute before the physics world is stepped forward
  20254. */
  20255. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20256. /**
  20257. * Unregister a function that will be executed before the physics world is stepping forward
  20258. * @param func The function to execute before the physics world is stepped forward
  20259. */
  20260. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20261. /**
  20262. * Register a function that will be executed after the physics step
  20263. * @param func The function to execute after physics step
  20264. */
  20265. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20266. /**
  20267. * Unregisters a function that will be executed after the physics step
  20268. * @param func The function to execute after physics step
  20269. */
  20270. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20271. /**
  20272. * register a function that will be executed when this impostor collides against a different body
  20273. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20274. * @param func Callback that is executed on collision
  20275. */
  20276. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20277. /**
  20278. * Unregisters the physics imposter on contact
  20279. * @param collideAgainst The physics object to collide against
  20280. * @param func Callback to execute on collision
  20281. */
  20282. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20283. private _tmpQuat;
  20284. private _tmpQuat2;
  20285. /**
  20286. * Get the parent rotation
  20287. * @returns The parent rotation
  20288. */
  20289. getParentsRotation(): Quaternion;
  20290. /**
  20291. * this function is executed by the physics engine.
  20292. */
  20293. beforeStep: () => void;
  20294. /**
  20295. * this function is executed by the physics engine
  20296. */
  20297. afterStep: () => void;
  20298. /**
  20299. * Legacy collision detection event support
  20300. */
  20301. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20302. /**
  20303. * event and body object due to cannon's event-based architecture.
  20304. */
  20305. onCollide: (e: {
  20306. body: any;
  20307. }) => void;
  20308. /**
  20309. * Apply a force
  20310. * @param force The force to apply
  20311. * @param contactPoint The contact point for the force
  20312. * @returns The physics imposter
  20313. */
  20314. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20315. /**
  20316. * Apply an impulse
  20317. * @param force The impulse force
  20318. * @param contactPoint The contact point for the impulse force
  20319. * @returns The physics imposter
  20320. */
  20321. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20322. /**
  20323. * A help function to create a joint
  20324. * @param otherImpostor A physics imposter used to create a joint
  20325. * @param jointType The type of joint
  20326. * @param jointData The data for the joint
  20327. * @returns The physics imposter
  20328. */
  20329. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20330. /**
  20331. * Add a joint to this impostor with a different impostor
  20332. * @param otherImpostor A physics imposter used to add a joint
  20333. * @param joint The joint to add
  20334. * @returns The physics imposter
  20335. */
  20336. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20337. /**
  20338. * Will keep this body still, in a sleep mode.
  20339. * @returns the physics imposter
  20340. */
  20341. sleep(): PhysicsImpostor;
  20342. /**
  20343. * Wake the body up.
  20344. * @returns The physics imposter
  20345. */
  20346. wakeUp(): PhysicsImpostor;
  20347. /**
  20348. * Clones the physics imposter
  20349. * @param newObject The physics imposter clones to this physics-enabled object
  20350. * @returns A nullable physics imposter
  20351. */
  20352. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20353. /**
  20354. * Disposes the physics imposter
  20355. */
  20356. dispose(): void;
  20357. /**
  20358. * Sets the delta position
  20359. * @param position The delta position amount
  20360. */
  20361. setDeltaPosition(position: Vector3): void;
  20362. /**
  20363. * Sets the delta rotation
  20364. * @param rotation The delta rotation amount
  20365. */
  20366. setDeltaRotation(rotation: Quaternion): void;
  20367. /**
  20368. * Gets the box size of the physics imposter and stores the result in the input parameter
  20369. * @param result Stores the box size
  20370. * @returns The physics imposter
  20371. */
  20372. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20373. /**
  20374. * Gets the radius of the physics imposter
  20375. * @returns Radius of the physics imposter
  20376. */
  20377. getRadius(): number;
  20378. /**
  20379. * Sync a bone with this impostor
  20380. * @param bone The bone to sync to the impostor.
  20381. * @param boneMesh The mesh that the bone is influencing.
  20382. * @param jointPivot The pivot of the joint / bone in local space.
  20383. * @param distToJoint Optional distance from the impostor to the joint.
  20384. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20385. */
  20386. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20387. /**
  20388. * Sync impostor to a bone
  20389. * @param bone The bone that the impostor will be synced to.
  20390. * @param boneMesh The mesh that the bone is influencing.
  20391. * @param jointPivot The pivot of the joint / bone in local space.
  20392. * @param distToJoint Optional distance from the impostor to the joint.
  20393. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20394. * @param boneAxis Optional vector3 axis the bone is aligned with
  20395. */
  20396. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20397. /**
  20398. * No-Imposter type
  20399. */
  20400. static NoImpostor: number;
  20401. /**
  20402. * Sphere-Imposter type
  20403. */
  20404. static SphereImpostor: number;
  20405. /**
  20406. * Box-Imposter type
  20407. */
  20408. static BoxImpostor: number;
  20409. /**
  20410. * Plane-Imposter type
  20411. */
  20412. static PlaneImpostor: number;
  20413. /**
  20414. * Mesh-imposter type
  20415. */
  20416. static MeshImpostor: number;
  20417. /**
  20418. * Cylinder-Imposter type
  20419. */
  20420. static CylinderImpostor: number;
  20421. /**
  20422. * Particle-Imposter type
  20423. */
  20424. static ParticleImpostor: number;
  20425. /**
  20426. * Heightmap-Imposter type
  20427. */
  20428. static HeightmapImpostor: number;
  20429. }
  20430. }
  20431. declare module "babylonjs/Meshes/mesh" {
  20432. import { Observable } from "babylonjs/Misc/observable";
  20433. import { IAnimatable } from "babylonjs/Misc/tools";
  20434. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20435. import { Camera } from "babylonjs/Cameras/camera";
  20436. import { Scene } from "babylonjs/scene";
  20437. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20438. import { Engine } from "babylonjs/Engines/engine";
  20439. import { Node } from "babylonjs/node";
  20440. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20441. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20442. import { Buffer } from "babylonjs/Meshes/buffer";
  20443. import { Geometry } from "babylonjs/Meshes/geometry";
  20444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20446. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20447. import { Effect } from "babylonjs/Materials/effect";
  20448. import { Material } from "babylonjs/Materials/material";
  20449. import { Skeleton } from "babylonjs/Bones/skeleton";
  20450. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20451. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20452. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20453. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20454. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20456. /**
  20457. * Class used to represent a specific level of detail of a mesh
  20458. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20459. */
  20460. export class MeshLODLevel {
  20461. /** Defines the distance where this level should star being displayed */
  20462. distance: number;
  20463. /** Defines the mesh to use to render this level */
  20464. mesh: Nullable<Mesh>;
  20465. /**
  20466. * Creates a new LOD level
  20467. * @param distance defines the distance where this level should star being displayed
  20468. * @param mesh defines the mesh to use to render this level
  20469. */
  20470. constructor(
  20471. /** Defines the distance where this level should star being displayed */
  20472. distance: number,
  20473. /** Defines the mesh to use to render this level */
  20474. mesh: Nullable<Mesh>);
  20475. }
  20476. /**
  20477. * @hidden
  20478. **/
  20479. export class _CreationDataStorage {
  20480. closePath?: boolean;
  20481. closeArray?: boolean;
  20482. idx: number[];
  20483. dashSize: number;
  20484. gapSize: number;
  20485. path3D: Path3D;
  20486. pathArray: Vector3[][];
  20487. arc: number;
  20488. radius: number;
  20489. cap: number;
  20490. tessellation: number;
  20491. }
  20492. /**
  20493. * @hidden
  20494. **/
  20495. class _InstanceDataStorage {
  20496. visibleInstances: any;
  20497. renderIdForInstances: number[];
  20498. batchCache: _InstancesBatch;
  20499. instancesBufferSize: number;
  20500. instancesBuffer: Nullable<Buffer>;
  20501. instancesData: Float32Array;
  20502. overridenInstanceCount: number;
  20503. }
  20504. /**
  20505. * @hidden
  20506. **/
  20507. export class _InstancesBatch {
  20508. mustReturn: boolean;
  20509. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20510. renderSelf: boolean[];
  20511. }
  20512. /**
  20513. * Class used to represent renderable models
  20514. */
  20515. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20516. /**
  20517. * Mesh side orientation : usually the external or front surface
  20518. */
  20519. static readonly FRONTSIDE: number;
  20520. /**
  20521. * Mesh side orientation : usually the internal or back surface
  20522. */
  20523. static readonly BACKSIDE: number;
  20524. /**
  20525. * Mesh side orientation : both internal and external or front and back surfaces
  20526. */
  20527. static readonly DOUBLESIDE: number;
  20528. /**
  20529. * Mesh side orientation : by default, `FRONTSIDE`
  20530. */
  20531. static readonly DEFAULTSIDE: number;
  20532. /**
  20533. * Mesh cap setting : no cap
  20534. */
  20535. static readonly NO_CAP: number;
  20536. /**
  20537. * Mesh cap setting : one cap at the beginning of the mesh
  20538. */
  20539. static readonly CAP_START: number;
  20540. /**
  20541. * Mesh cap setting : one cap at the end of the mesh
  20542. */
  20543. static readonly CAP_END: number;
  20544. /**
  20545. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20546. */
  20547. static readonly CAP_ALL: number;
  20548. /**
  20549. * Gets the default side orientation.
  20550. * @param orientation the orientation to value to attempt to get
  20551. * @returns the default orientation
  20552. * @hidden
  20553. */
  20554. static _GetDefaultSideOrientation(orientation?: number): number;
  20555. private _onBeforeRenderObservable;
  20556. private _onBeforeBindObservable;
  20557. private _onAfterRenderObservable;
  20558. private _onBeforeDrawObservable;
  20559. /**
  20560. * An event triggered before rendering the mesh
  20561. */
  20562. readonly onBeforeRenderObservable: Observable<Mesh>;
  20563. /**
  20564. * An event triggered before binding the mesh
  20565. */
  20566. readonly onBeforeBindObservable: Observable<Mesh>;
  20567. /**
  20568. * An event triggered after rendering the mesh
  20569. */
  20570. readonly onAfterRenderObservable: Observable<Mesh>;
  20571. /**
  20572. * An event triggered before drawing the mesh
  20573. */
  20574. readonly onBeforeDrawObservable: Observable<Mesh>;
  20575. private _onBeforeDrawObserver;
  20576. /**
  20577. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20578. */
  20579. onBeforeDraw: () => void;
  20580. /**
  20581. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20582. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20583. */
  20584. delayLoadState: number;
  20585. /**
  20586. * Gets the list of instances created from this mesh
  20587. * it is not supposed to be modified manually.
  20588. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20590. */
  20591. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20592. /**
  20593. * Gets the file containing delay loading data for this mesh
  20594. */
  20595. delayLoadingFile: string;
  20596. /** @hidden */
  20597. _binaryInfo: any;
  20598. private _LODLevels;
  20599. /**
  20600. * User defined function used to change how LOD level selection is done
  20601. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20602. */
  20603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20604. private _morphTargetManager;
  20605. /**
  20606. * Gets or sets the morph target manager
  20607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20608. */
  20609. morphTargetManager: Nullable<MorphTargetManager>;
  20610. /** @hidden */
  20611. _creationDataStorage: Nullable<_CreationDataStorage>;
  20612. /** @hidden */
  20613. _geometry: Nullable<Geometry>;
  20614. /** @hidden */
  20615. _delayInfo: Array<string>;
  20616. /** @hidden */
  20617. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20618. /** @hidden */
  20619. _instanceDataStorage: _InstanceDataStorage;
  20620. private _effectiveMaterial;
  20621. /** @hidden */
  20622. _shouldGenerateFlatShading: boolean;
  20623. private _preActivateId;
  20624. /** @hidden */
  20625. _originalBuilderSideOrientation: number;
  20626. /**
  20627. * Use this property to change the original side orientation defined at construction time
  20628. */
  20629. overrideMaterialSideOrientation: Nullable<number>;
  20630. private _areNormalsFrozen;
  20631. private _sourcePositions;
  20632. private _sourceNormals;
  20633. private _source;
  20634. private meshMap;
  20635. /**
  20636. * Gets the source mesh (the one used to clone this one from)
  20637. */
  20638. readonly source: Nullable<Mesh>;
  20639. /**
  20640. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20641. */
  20642. isUnIndexed: boolean;
  20643. /**
  20644. * @constructor
  20645. * @param name The value used by scene.getMeshByName() to do a lookup.
  20646. * @param scene The scene to add this mesh to.
  20647. * @param parent The parent of this mesh, if it has one
  20648. * @param source An optional Mesh from which geometry is shared, cloned.
  20649. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20650. * When false, achieved by calling a clone(), also passing False.
  20651. * This will make creation of children, recursive.
  20652. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20653. */
  20654. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20655. /**
  20656. * Gets the class name
  20657. * @returns the string "Mesh".
  20658. */
  20659. getClassName(): string;
  20660. /** @hidden */
  20661. readonly _isMesh: boolean;
  20662. /**
  20663. * Returns a description of this mesh
  20664. * @param fullDetails define if full details about this mesh must be used
  20665. * @returns a descriptive string representing this mesh
  20666. */
  20667. toString(fullDetails?: boolean): string;
  20668. /** @hidden */
  20669. _unBindEffect(): void;
  20670. /**
  20671. * Gets a boolean indicating if this mesh has LOD
  20672. */
  20673. readonly hasLODLevels: boolean;
  20674. /**
  20675. * Gets the list of MeshLODLevel associated with the current mesh
  20676. * @returns an array of MeshLODLevel
  20677. */
  20678. getLODLevels(): MeshLODLevel[];
  20679. private _sortLODLevels;
  20680. /**
  20681. * Add a mesh as LOD level triggered at the given distance.
  20682. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20683. * @param distance The distance from the center of the object to show this level
  20684. * @param mesh The mesh to be added as LOD level (can be null)
  20685. * @return This mesh (for chaining)
  20686. */
  20687. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20688. /**
  20689. * Returns the LOD level mesh at the passed distance or null if not found.
  20690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20691. * @param distance The distance from the center of the object to show this level
  20692. * @returns a Mesh or `null`
  20693. */
  20694. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20695. /**
  20696. * Remove a mesh from the LOD array
  20697. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20698. * @param mesh defines the mesh to be removed
  20699. * @return This mesh (for chaining)
  20700. */
  20701. removeLODLevel(mesh: Mesh): Mesh;
  20702. /**
  20703. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20705. * @param camera defines the camera to use to compute distance
  20706. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20707. * @return This mesh (for chaining)
  20708. */
  20709. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20710. /**
  20711. * Gets the mesh internal Geometry object
  20712. */
  20713. readonly geometry: Nullable<Geometry>;
  20714. /**
  20715. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20716. * @returns the total number of vertices
  20717. */
  20718. getTotalVertices(): number;
  20719. /**
  20720. * Returns the content of an associated vertex buffer
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.UVKind
  20724. * - VertexBuffer.UV2Kind
  20725. * - VertexBuffer.UV3Kind
  20726. * - VertexBuffer.UV4Kind
  20727. * - VertexBuffer.UV5Kind
  20728. * - VertexBuffer.UV6Kind
  20729. * - VertexBuffer.ColorKind
  20730. * - VertexBuffer.MatricesIndicesKind
  20731. * - VertexBuffer.MatricesIndicesExtraKind
  20732. * - VertexBuffer.MatricesWeightsKind
  20733. * - VertexBuffer.MatricesWeightsExtraKind
  20734. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  20735. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20736. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20737. */
  20738. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20739. /**
  20740. * Returns the mesh VertexBuffer object from the requested `kind`
  20741. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20742. * - VertexBuffer.PositionKind
  20743. * - VertexBuffer.UVKind
  20744. * - VertexBuffer.UV2Kind
  20745. * - VertexBuffer.UV3Kind
  20746. * - VertexBuffer.UV4Kind
  20747. * - VertexBuffer.UV5Kind
  20748. * - VertexBuffer.UV6Kind
  20749. * - VertexBuffer.ColorKind
  20750. * - VertexBuffer.MatricesIndicesKind
  20751. * - VertexBuffer.MatricesIndicesExtraKind
  20752. * - VertexBuffer.MatricesWeightsKind
  20753. * - VertexBuffer.MatricesWeightsExtraKind
  20754. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20755. */
  20756. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20757. /**
  20758. * Tests if a specific vertex buffer is associated with this mesh
  20759. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20760. * - VertexBuffer.PositionKind
  20761. * - VertexBuffer.UVKind
  20762. * - VertexBuffer.UV2Kind
  20763. * - VertexBuffer.UV3Kind
  20764. * - VertexBuffer.UV4Kind
  20765. * - VertexBuffer.UV5Kind
  20766. * - VertexBuffer.UV6Kind
  20767. * - VertexBuffer.ColorKind
  20768. * - VertexBuffer.MatricesIndicesKind
  20769. * - VertexBuffer.MatricesIndicesExtraKind
  20770. * - VertexBuffer.MatricesWeightsKind
  20771. * - VertexBuffer.MatricesWeightsExtraKind
  20772. * @returns a boolean
  20773. */
  20774. isVerticesDataPresent(kind: string): boolean;
  20775. /**
  20776. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20778. * - VertexBuffer.PositionKind
  20779. * - VertexBuffer.UVKind
  20780. * - VertexBuffer.UV2Kind
  20781. * - VertexBuffer.UV3Kind
  20782. * - VertexBuffer.UV4Kind
  20783. * - VertexBuffer.UV5Kind
  20784. * - VertexBuffer.UV6Kind
  20785. * - VertexBuffer.ColorKind
  20786. * - VertexBuffer.MatricesIndicesKind
  20787. * - VertexBuffer.MatricesIndicesExtraKind
  20788. * - VertexBuffer.MatricesWeightsKind
  20789. * - VertexBuffer.MatricesWeightsExtraKind
  20790. * @returns a boolean
  20791. */
  20792. isVertexBufferUpdatable(kind: string): boolean;
  20793. /**
  20794. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20796. * - VertexBuffer.PositionKind
  20797. * - VertexBuffer.UVKind
  20798. * - VertexBuffer.UV2Kind
  20799. * - VertexBuffer.UV3Kind
  20800. * - VertexBuffer.UV4Kind
  20801. * - VertexBuffer.UV5Kind
  20802. * - VertexBuffer.UV6Kind
  20803. * - VertexBuffer.ColorKind
  20804. * - VertexBuffer.MatricesIndicesKind
  20805. * - VertexBuffer.MatricesIndicesExtraKind
  20806. * - VertexBuffer.MatricesWeightsKind
  20807. * - VertexBuffer.MatricesWeightsExtraKind
  20808. * @returns an array of strings
  20809. */
  20810. getVerticesDataKinds(): string[];
  20811. /**
  20812. * Returns a positive integer : the total number of indices in this mesh geometry.
  20813. * @returns the numner of indices or zero if the mesh has no geometry.
  20814. */
  20815. getTotalIndices(): number;
  20816. /**
  20817. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20818. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  20819. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20820. * @returns the indices array or an empty array if the mesh has no geometry
  20821. */
  20822. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20823. readonly isBlocked: boolean;
  20824. /**
  20825. * Determine if the current mesh is ready to be rendered
  20826. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20827. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20828. * @returns true if all associated assets are ready (material, textures, shaders)
  20829. */
  20830. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20831. /**
  20832. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  20833. */
  20834. readonly areNormalsFrozen: boolean;
  20835. /**
  20836. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  20837. * @returns the current mesh
  20838. */
  20839. freezeNormals(): Mesh;
  20840. /**
  20841. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  20842. * @returns the current mesh
  20843. */
  20844. unfreezeNormals(): Mesh;
  20845. /**
  20846. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20847. */
  20848. overridenInstanceCount: number;
  20849. /** @hidden */
  20850. _preActivate(): Mesh;
  20851. /** @hidden */
  20852. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20853. /** @hidden */
  20854. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20855. /**
  20856. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20857. * This means the mesh underlying bounding box and sphere are recomputed.
  20858. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20859. * @returns the current mesh
  20860. */
  20861. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20862. /** @hidden */
  20863. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20864. /**
  20865. * This function will subdivide the mesh into multiple submeshes
  20866. * @param count defines the expected number of submeshes
  20867. */
  20868. subdivide(count: number): void;
  20869. /**
  20870. * Copy a FloatArray into a specific associated vertex buffer
  20871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20872. * - VertexBuffer.PositionKind
  20873. * - VertexBuffer.UVKind
  20874. * - VertexBuffer.UV2Kind
  20875. * - VertexBuffer.UV3Kind
  20876. * - VertexBuffer.UV4Kind
  20877. * - VertexBuffer.UV5Kind
  20878. * - VertexBuffer.UV6Kind
  20879. * - VertexBuffer.ColorKind
  20880. * - VertexBuffer.MatricesIndicesKind
  20881. * - VertexBuffer.MatricesIndicesExtraKind
  20882. * - VertexBuffer.MatricesWeightsKind
  20883. * - VertexBuffer.MatricesWeightsExtraKind
  20884. * @param data defines the data source
  20885. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20886. * @param stride defines the data stride size (can be null)
  20887. * @returns the current mesh
  20888. */
  20889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20890. /**
  20891. * Flags an associated vertex buffer as updatable
  20892. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20893. * - VertexBuffer.PositionKind
  20894. * - VertexBuffer.UVKind
  20895. * - VertexBuffer.UV2Kind
  20896. * - VertexBuffer.UV3Kind
  20897. * - VertexBuffer.UV4Kind
  20898. * - VertexBuffer.UV5Kind
  20899. * - VertexBuffer.UV6Kind
  20900. * - VertexBuffer.ColorKind
  20901. * - VertexBuffer.MatricesIndicesKind
  20902. * - VertexBuffer.MatricesIndicesExtraKind
  20903. * - VertexBuffer.MatricesWeightsKind
  20904. * - VertexBuffer.MatricesWeightsExtraKind
  20905. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20906. */
  20907. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20908. /**
  20909. * Sets the mesh global Vertex Buffer
  20910. * @param buffer defines the buffer to use
  20911. * @returns the current mesh
  20912. */
  20913. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20914. /**
  20915. * Update a specific associated vertex buffer
  20916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20917. * - VertexBuffer.PositionKind
  20918. * - VertexBuffer.UVKind
  20919. * - VertexBuffer.UV2Kind
  20920. * - VertexBuffer.UV3Kind
  20921. * - VertexBuffer.UV4Kind
  20922. * - VertexBuffer.UV5Kind
  20923. * - VertexBuffer.UV6Kind
  20924. * - VertexBuffer.ColorKind
  20925. * - VertexBuffer.MatricesIndicesKind
  20926. * - VertexBuffer.MatricesIndicesExtraKind
  20927. * - VertexBuffer.MatricesWeightsKind
  20928. * - VertexBuffer.MatricesWeightsExtraKind
  20929. * @param data defines the data source
  20930. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20931. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  20932. * @returns the current mesh
  20933. */
  20934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20935. /**
  20936. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20937. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20938. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20939. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20940. * @returns the current mesh
  20941. */
  20942. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20943. /**
  20944. * Creates a un-shared specific occurence of the geometry for the mesh.
  20945. * @returns the current mesh
  20946. */
  20947. makeGeometryUnique(): Mesh;
  20948. /**
  20949. * Set the index buffer of this mesh
  20950. * @param indices defines the source data
  20951. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20952. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20953. * @returns the current mesh
  20954. */
  20955. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20956. /**
  20957. * Update the current index buffer
  20958. * @param indices defines the source data
  20959. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20960. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20961. * @returns the current mesh
  20962. */
  20963. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20964. /**
  20965. * Invert the geometry to move from a right handed system to a left handed one.
  20966. * @returns the current mesh
  20967. */
  20968. toLeftHanded(): Mesh;
  20969. /** @hidden */
  20970. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20971. /** @hidden */
  20972. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just before the rendering process
  20975. * @param func defines the function to call before rendering this mesh
  20976. * @returns the current mesh
  20977. */
  20978. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called before the rendering
  20981. * @param func defines the function to remove
  20982. * @returns the current mesh
  20983. */
  20984. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. /**
  20986. * Registers for this mesh a javascript function called just after the rendering is complete
  20987. * @param func defines the function to call after rendering this mesh
  20988. * @returns the current mesh
  20989. */
  20990. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20991. /**
  20992. * Disposes a previously registered javascript function called after the rendering.
  20993. * @param func defines the function to remove
  20994. * @returns the current mesh
  20995. */
  20996. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20997. /** @hidden */
  20998. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20999. /** @hidden */
  21000. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21001. /** @hidden */
  21002. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21003. /**
  21004. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21005. * @param subMesh defines the subMesh to render
  21006. * @param enableAlphaMode defines if alpha mode can be changed
  21007. * @returns the current mesh
  21008. */
  21009. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21010. private _onBeforeDraw;
  21011. /**
  21012. * Renormalize the mesh and patch it up if there are no weights
  21013. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21014. * However in the case of zero weights then we set just a single influence to 1.
  21015. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21016. */
  21017. cleanMatrixWeights(): void;
  21018. private normalizeSkinFourWeights;
  21019. private normalizeSkinWeightsAndExtra;
  21020. /**
  21021. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21022. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21023. * the user know there was an issue with importing the mesh
  21024. * @returns a validation object with skinned, valid and report string
  21025. */
  21026. validateSkinning(): {
  21027. skinned: boolean;
  21028. valid: boolean;
  21029. report: string;
  21030. };
  21031. /** @hidden */
  21032. _checkDelayState(): Mesh;
  21033. private _queueLoad;
  21034. /**
  21035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21036. * A mesh is in the frustum if its bounding box intersects the frustum
  21037. * @param frustumPlanes defines the frustum to test
  21038. * @returns true if the mesh is in the frustum planes
  21039. */
  21040. isInFrustum(frustumPlanes: Plane[]): boolean;
  21041. /**
  21042. * Sets the mesh material by the material or multiMaterial `id` property
  21043. * @param id is a string identifying the material or the multiMaterial
  21044. * @returns the current mesh
  21045. */
  21046. setMaterialByID(id: string): Mesh;
  21047. /**
  21048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21049. * @returns an array of IAnimatable
  21050. */
  21051. getAnimatables(): IAnimatable[];
  21052. /**
  21053. * Modifies the mesh geometry according to the passed transformation matrix.
  21054. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21055. * The mesh normals are modified using the same transformation.
  21056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21057. * @param transform defines the transform matrix to use
  21058. * @see http://doc.babylonjs.com/resources/baking_transformations
  21059. * @returns the current mesh
  21060. */
  21061. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21062. /**
  21063. * Modifies the mesh geometry according to its own current World Matrix.
  21064. * The mesh World Matrix is then reset.
  21065. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21066. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21067. * @see http://doc.babylonjs.com/resources/baking_transformations
  21068. * @returns the current mesh
  21069. */
  21070. bakeCurrentTransformIntoVertices(): Mesh;
  21071. /** @hidden */
  21072. readonly _positions: Nullable<Vector3[]>;
  21073. /** @hidden */
  21074. _resetPointsArrayCache(): Mesh;
  21075. /** @hidden */
  21076. _generatePointsArray(): boolean;
  21077. /**
  21078. * Returns a new Mesh object generated from the current mesh properties.
  21079. * This method must not get confused with createInstance()
  21080. * @param name is a string, the name given to the new mesh
  21081. * @param newParent can be any Node object (default `null`)
  21082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21084. * @returns a new mesh
  21085. */
  21086. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21087. /**
  21088. * Releases resources associated with this mesh.
  21089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21091. */
  21092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21093. /**
  21094. * Modifies the mesh geometry according to a displacement map.
  21095. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  21096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21097. * @param url is a string, the URL from the image file is to be downloaded.
  21098. * @param minHeight is the lower limit of the displacement.
  21099. * @param maxHeight is the upper limit of the displacement.
  21100. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21101. * @param uvOffset is an optional vector2 used to offset UV.
  21102. * @param uvScale is an optional vector2 used to scale UV.
  21103. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  21104. * @returns the Mesh.
  21105. */
  21106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21107. /**
  21108. * Modifies the mesh geometry according to a displacementMap buffer.
  21109. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  21110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21112. * @param heightMapWidth is the width of the buffer image.
  21113. * @param heightMapHeight is the height of the buffer image.
  21114. * @param minHeight is the lower limit of the displacement.
  21115. * @param maxHeight is the upper limit of the displacement.
  21116. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21117. * @param uvOffset is an optional vector2 used to offset UV.
  21118. * @param uvScale is an optional vector2 used to scale UV.
  21119. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  21120. * @returns the Mesh.
  21121. */
  21122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21123. /**
  21124. * Modify the mesh to get a flat shading rendering.
  21125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21127. * @returns current mesh
  21128. */
  21129. convertToFlatShadedMesh(): Mesh;
  21130. /**
  21131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21132. * In other words, more vertices, no more indices and a single bigger VBO.
  21133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21134. * @returns current mesh
  21135. */
  21136. convertToUnIndexedMesh(): Mesh;
  21137. /**
  21138. * Inverses facet orientations.
  21139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21140. * @param flipNormals will also inverts the normals
  21141. * @returns current mesh
  21142. */
  21143. flipFaces(flipNormals?: boolean): Mesh;
  21144. /** @hidden */
  21145. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21146. /** @hidden */
  21147. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21148. /**
  21149. * Creates a new InstancedMesh object from the mesh model.
  21150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21151. * @param name defines the name of the new instance
  21152. * @returns a new InstancedMesh
  21153. */
  21154. createInstance(name: string): InstancedMesh;
  21155. /**
  21156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21158. * @returns the current mesh
  21159. */
  21160. synchronizeInstances(): Mesh;
  21161. /**
  21162. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21163. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21164. * This should be used together with the simplification to avoid disappearing triangles.
  21165. * @param successCallback an optional success callback to be called after the optimization finished.
  21166. * @returns the current mesh
  21167. */
  21168. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21169. /**
  21170. * Serialize current mesh
  21171. * @param serializationObject defines the object which will receive the serialization data
  21172. */
  21173. serialize(serializationObject: any): void;
  21174. /** @hidden */
  21175. _syncGeometryWithMorphTargetManager(): void;
  21176. /** @hidden */
  21177. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21178. /**
  21179. * Returns a new Mesh object parsed from the source provided.
  21180. * @param parsedMesh is the source
  21181. * @param scene defines the hosting scene
  21182. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21183. * @returns a new Mesh
  21184. */
  21185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21186. /**
  21187. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21189. * @param name defines the name of the mesh to create
  21190. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21191. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21192. * @param closePath creates a seam between the first and the last points of each path of the path array
  21193. * @param offset is taken in account only if the `pathArray` is containing a single path
  21194. * @param scene defines the hosting scene
  21195. * @param updatable defines if the mesh must be flagged as updatable
  21196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21197. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  21198. * @returns a new Mesh
  21199. */
  21200. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21201. /**
  21202. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21203. * @param name defines the name of the mesh to create
  21204. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21205. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  21206. * @param scene defines the hosting scene
  21207. * @param updatable defines if the mesh must be flagged as updatable
  21208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21209. * @returns a new Mesh
  21210. */
  21211. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21212. /**
  21213. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21214. * @param name defines the name of the mesh to create
  21215. * @param size sets the size (float) of each box side (default 1)
  21216. * @param scene defines the hosting scene
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @returns a new Mesh
  21220. */
  21221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21222. /**
  21223. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21224. * @param name defines the name of the mesh to create
  21225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21227. * @param scene defines the hosting scene
  21228. * @param updatable defines if the mesh must be flagged as updatable
  21229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21230. * @returns a new Mesh
  21231. */
  21232. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21233. /**
  21234. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21235. * @param name defines the name of the mesh to create
  21236. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21237. * @param diameterTop set the top cap diameter (floats, default 1)
  21238. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21239. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21240. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21241. * @param scene defines the hosting scene
  21242. * @param updatable defines if the mesh must be flagged as updatable
  21243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21244. * @returns a new Mesh
  21245. */
  21246. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21247. /**
  21248. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21249. * @param name defines the name of the mesh to create
  21250. * @param diameter sets the diameter size (float) of the torus (default 1)
  21251. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21252. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21253. * @param scene defines the hosting scene
  21254. * @param updatable defines if the mesh must be flagged as updatable
  21255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21256. * @returns a new Mesh
  21257. */
  21258. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21259. /**
  21260. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21261. * @param name defines the name of the mesh to create
  21262. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21263. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21264. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21265. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21266. * @param p the number of windings on X axis (positive integers, default 2)
  21267. * @param q the number of windings on Y axis (positive integers, default 3)
  21268. * @param scene defines the hosting scene
  21269. * @param updatable defines if the mesh must be flagged as updatable
  21270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21271. * @returns a new Mesh
  21272. */
  21273. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21274. /**
  21275. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21276. * @param name defines the name of the mesh to create
  21277. * @param points is an array successive Vector3
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  21281. * @returns a new Mesh
  21282. */
  21283. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21284. /**
  21285. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param points is an array successive Vector3
  21288. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21289. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21290. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21291. * @param scene defines the hosting scene
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  21294. * @returns a new Mesh
  21295. */
  21296. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21297. /**
  21298. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21299. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21300. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  21301. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21302. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21303. * Remember you can only change the shape positions, not their number when updating a polygon.
  21304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21305. * @param name defines the name of the mesh to create
  21306. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  21307. * @param scene defines the hosting scene
  21308. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21309. * @param updatable defines if the mesh must be flagged as updatable
  21310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21311. * @param earcutInjection can be used to inject your own earcut reference
  21312. * @returns a new Mesh
  21313. */
  21314. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21315. /**
  21316. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21318. * @param name defines the name of the mesh to create
  21319. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  21320. * @param depth defines the height of extrusion
  21321. * @param scene defines the hosting scene
  21322. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21323. * @param updatable defines if the mesh must be flagged as updatable
  21324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21325. * @param earcutInjection can be used to inject your own earcut reference
  21326. * @returns a new Mesh
  21327. */
  21328. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21329. /**
  21330. * Creates an extruded shape mesh.
  21331. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  21332. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21334. * @param name defines the name of the mesh to create
  21335. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  21336. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21337. * @param scale is the value to scale the shape
  21338. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  21339. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21340. * @param scene defines the hosting scene
  21341. * @param updatable defines if the mesh must be flagged as updatable
  21342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21343. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  21344. * @returns a new Mesh
  21345. */
  21346. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21347. /**
  21348. * Creates an custom extruded shape mesh.
  21349. * The custom extrusion is a parametric shape.
  21350. * It has no predefined shape. Its final shape will depend on the input parameters.
  21351. * Please consider using the same method from the MeshBuilder class instead
  21352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21353. * @param name defines the name of the mesh to create
  21354. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  21355. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21356. * @param scaleFunction is a custom Javascript function called on each path point
  21357. * @param rotationFunction is a custom Javascript function called on each path point
  21358. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21359. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21360. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21361. * @param scene defines the hosting scene
  21362. * @param updatable defines if the mesh must be flagged as updatable
  21363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21364. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  21365. * @returns a new Mesh
  21366. */
  21367. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21368. /**
  21369. * Creates lathe mesh.
  21370. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21371. * Please consider using the same method from the MeshBuilder class instead
  21372. * @param name defines the name of the mesh to create
  21373. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  21374. * @param radius is the radius value of the lathe
  21375. * @param tessellation is the side number of the lathe.
  21376. * @param scene defines the hosting scene
  21377. * @param updatable defines if the mesh must be flagged as updatable
  21378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21379. * @returns a new Mesh
  21380. */
  21381. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21382. /**
  21383. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21384. * @param name defines the name of the mesh to create
  21385. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21386. * @param scene defines the hosting scene
  21387. * @param updatable defines if the mesh must be flagged as updatable
  21388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21389. * @returns a new Mesh
  21390. */
  21391. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21392. /**
  21393. * Creates a ground mesh.
  21394. * Please consider using the same method from the MeshBuilder class instead
  21395. * @param name defines the name of the mesh to create
  21396. * @param width set the width of the ground
  21397. * @param height set the height of the ground
  21398. * @param subdivisions sets the number of subdivisions per side
  21399. * @param scene defines the hosting scene
  21400. * @param updatable defines if the mesh must be flagged as updatable
  21401. * @returns a new Mesh
  21402. */
  21403. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21404. /**
  21405. * Creates a tiled ground mesh.
  21406. * Please consider using the same method from the MeshBuilder class instead
  21407. * @param name defines the name of the mesh to create
  21408. * @param xmin set the ground minimum X coordinate
  21409. * @param zmin set the ground minimum Y coordinate
  21410. * @param xmax set the ground maximum X coordinate
  21411. * @param zmax set the ground maximum Z coordinate
  21412. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  21413. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  21414. * @param scene defines the hosting scene
  21415. * @param updatable defines if the mesh must be flagged as updatable
  21416. * @returns a new Mesh
  21417. */
  21418. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21419. w: number;
  21420. h: number;
  21421. }, precision: {
  21422. w: number;
  21423. h: number;
  21424. }, scene: Scene, updatable?: boolean): Mesh;
  21425. /**
  21426. * Creates a ground mesh from a height map.
  21427. * Please consider using the same method from the MeshBuilder class instead
  21428. * @see http://doc.babylonjs.com/babylon101/height_map
  21429. * @param name defines the name of the mesh to create
  21430. * @param url sets the URL of the height map image resource
  21431. * @param width set the ground width size
  21432. * @param height set the ground height size
  21433. * @param subdivisions sets the number of subdivision per side
  21434. * @param minHeight is the minimum altitude on the ground
  21435. * @param maxHeight is the maximum altitude on the ground
  21436. * @param scene defines the hosting scene
  21437. * @param updatable defines if the mesh must be flagged as updatable
  21438. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21439. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21440. * @returns a new Mesh
  21441. */
  21442. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  21443. /**
  21444. * Creates a tube mesh.
  21445. * The tube is a parametric shape.
  21446. * It has no predefined shape. Its final shape will depend on the input parameters.
  21447. * Please consider using the same method from the MeshBuilder class instead
  21448. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21449. * @param name defines the name of the mesh to create
  21450. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21451. * @param radius sets the tube radius size
  21452. * @param tessellation is the number of sides on the tubular surface
  21453. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  21454. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21455. * @param scene defines the hosting scene
  21456. * @param updatable defines if the mesh must be flagged as updatable
  21457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21458. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  21459. * @returns a new Mesh
  21460. */
  21461. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21462. (i: number, distance: number): number;
  21463. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21464. /**
  21465. * Creates a polyhedron mesh.
  21466. * Please consider using the same method from the MeshBuilder class instead.
  21467. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  21468. * * The parameter `size` (positive float, default 1) sets the polygon size
  21469. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21470. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  21471. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  21472. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  21473. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  21474. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  21475. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21478. * @param name defines the name of the mesh to create
  21479. * @param options defines the options used to create the mesh
  21480. * @param scene defines the hosting scene
  21481. * @returns a new Mesh
  21482. */
  21483. static CreatePolyhedron(name: string, options: {
  21484. type?: number;
  21485. size?: number;
  21486. sizeX?: number;
  21487. sizeY?: number;
  21488. sizeZ?: number;
  21489. custom?: any;
  21490. faceUV?: Vector4[];
  21491. faceColors?: Color4[];
  21492. updatable?: boolean;
  21493. sideOrientation?: number;
  21494. }, scene: Scene): Mesh;
  21495. /**
  21496. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21497. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21498. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  21499. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21500. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  21501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21504. * @param name defines the name of the mesh
  21505. * @param options defines the options used to create the mesh
  21506. * @param scene defines the hosting scene
  21507. * @returns a new Mesh
  21508. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21509. */
  21510. static CreateIcoSphere(name: string, options: {
  21511. radius?: number;
  21512. flat?: boolean;
  21513. subdivisions?: number;
  21514. sideOrientation?: number;
  21515. updatable?: boolean;
  21516. }, scene: Scene): Mesh;
  21517. /**
  21518. * Creates a decal mesh.
  21519. * Please consider using the same method from the MeshBuilder class instead.
  21520. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21521. * @param name defines the name of the mesh
  21522. * @param sourceMesh defines the mesh receiving the decal
  21523. * @param position sets the position of the decal in world coordinates
  21524. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21525. * @param size sets the decal scaling
  21526. * @param angle sets the angle to rotate the decal
  21527. * @returns a new Mesh
  21528. */
  21529. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21530. /**
  21531. * Prepare internal position array for software CPU skinning
  21532. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21533. */
  21534. setPositionsForCPUSkinning(): Float32Array;
  21535. /**
  21536. * Prepare internal normal array for software CPU skinning
  21537. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21538. */
  21539. setNormalsForCPUSkinning(): Float32Array;
  21540. /**
  21541. * Updates the vertex buffer by applying transformation from the bones
  21542. * @param skeleton defines the skeleton to apply to current mesh
  21543. * @returns the current mesh
  21544. */
  21545. applySkeleton(skeleton: Skeleton): Mesh;
  21546. /**
  21547. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  21548. * @param meshes defines the list of meshes to scan
  21549. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21550. */
  21551. static MinMax(meshes: AbstractMesh[]): {
  21552. min: Vector3;
  21553. max: Vector3;
  21554. };
  21555. /**
  21556. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21557. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21558. * @returns a vector3
  21559. */
  21560. static Center(meshesOrMinMaxVector: {
  21561. min: Vector3;
  21562. max: Vector3;
  21563. } | AbstractMesh[]): Vector3;
  21564. /**
  21565. * Merge the array of meshes into a single mesh for performance reasons.
  21566. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21567. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21568. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21569. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21570. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21571. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21572. * @returns a new mesh
  21573. */
  21574. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21575. /** @hidden */
  21576. addInstance(instance: InstancedMesh): void;
  21577. /** @hidden */
  21578. removeInstance(instance: InstancedMesh): void;
  21579. }
  21580. }
  21581. declare module "babylonjs/Materials/material" {
  21582. import { IAnimatable } from "babylonjs/Misc/tools";
  21583. import { SmartArray } from "babylonjs/Misc/smartArray";
  21584. import { Observable } from "babylonjs/Misc/observable";
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { Matrix } from "babylonjs/Maths/math";
  21588. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21590. import { Mesh } from "babylonjs/Meshes/mesh";
  21591. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21595. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21596. import { Animation } from "babylonjs/Animations/animation";
  21597. /**
  21598. * Base class for the main features of a material in Babylon.js
  21599. */
  21600. export class Material implements IAnimatable {
  21601. /**
  21602. * Returns the triangle fill mode
  21603. */
  21604. static readonly TriangleFillMode: number;
  21605. /**
  21606. * Returns the wireframe mode
  21607. */
  21608. static readonly WireFrameFillMode: number;
  21609. /**
  21610. * Returns the point fill mode
  21611. */
  21612. static readonly PointFillMode: number;
  21613. /**
  21614. * Returns the point list draw mode
  21615. */
  21616. static readonly PointListDrawMode: number;
  21617. /**
  21618. * Returns the line list draw mode
  21619. */
  21620. static readonly LineListDrawMode: number;
  21621. /**
  21622. * Returns the line loop draw mode
  21623. */
  21624. static readonly LineLoopDrawMode: number;
  21625. /**
  21626. * Returns the line strip draw mode
  21627. */
  21628. static readonly LineStripDrawMode: number;
  21629. /**
  21630. * Returns the triangle strip draw mode
  21631. */
  21632. static readonly TriangleStripDrawMode: number;
  21633. /**
  21634. * Returns the triangle fan draw mode
  21635. */
  21636. static readonly TriangleFanDrawMode: number;
  21637. /**
  21638. * Stores the clock-wise side orientation
  21639. */
  21640. static readonly ClockWiseSideOrientation: number;
  21641. /**
  21642. * Stores the counter clock-wise side orientation
  21643. */
  21644. static readonly CounterClockWiseSideOrientation: number;
  21645. /**
  21646. * The dirty texture flag value
  21647. */
  21648. static readonly TextureDirtyFlag: number;
  21649. /**
  21650. * The dirty light flag value
  21651. */
  21652. static readonly LightDirtyFlag: number;
  21653. /**
  21654. * The dirty fresnel flag value
  21655. */
  21656. static readonly FresnelDirtyFlag: number;
  21657. /**
  21658. * The dirty attribute flag value
  21659. */
  21660. static readonly AttributesDirtyFlag: number;
  21661. /**
  21662. * The dirty misc flag value
  21663. */
  21664. static readonly MiscDirtyFlag: number;
  21665. /**
  21666. * The all dirty flag value
  21667. */
  21668. static readonly AllDirtyFlag: number;
  21669. /**
  21670. * The ID of the material
  21671. */
  21672. id: string;
  21673. /**
  21674. * Gets or sets the unique id of the material
  21675. */
  21676. uniqueId: number;
  21677. /**
  21678. * The name of the material
  21679. */
  21680. name: string;
  21681. /**
  21682. * Gets or sets user defined metadata
  21683. */
  21684. metadata: any;
  21685. /**
  21686. * For internal use only. Please do not use.
  21687. */
  21688. reservedDataStore: any;
  21689. /**
  21690. * Specifies if the ready state should be checked on each call
  21691. */
  21692. checkReadyOnEveryCall: boolean;
  21693. /**
  21694. * Specifies if the ready state should be checked once
  21695. */
  21696. checkReadyOnlyOnce: boolean;
  21697. /**
  21698. * The state of the material
  21699. */
  21700. state: string;
  21701. /**
  21702. * The alpha value of the material
  21703. */
  21704. protected _alpha: number;
  21705. /**
  21706. * Sets the alpha value of the material
  21707. */
  21708. /**
  21709. * Gets the alpha value of the material
  21710. */
  21711. alpha: number;
  21712. /**
  21713. * Specifies if back face culling is enabled
  21714. */
  21715. protected _backFaceCulling: boolean;
  21716. /**
  21717. * Sets the back-face culling state
  21718. */
  21719. /**
  21720. * Gets the back-face culling state
  21721. */
  21722. backFaceCulling: boolean;
  21723. /**
  21724. * Stores the value for side orientation
  21725. */
  21726. sideOrientation: number;
  21727. /**
  21728. * Callback triggered when the material is compiled
  21729. */
  21730. onCompiled: (effect: Effect) => void;
  21731. /**
  21732. * Callback triggered when an error occurs
  21733. */
  21734. onError: (effect: Effect, errors: string) => void;
  21735. /**
  21736. * Callback triggered to get the render target textures
  21737. */
  21738. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21739. /**
  21740. * Gets a boolean indicating that current material needs to register RTT
  21741. */
  21742. readonly hasRenderTargetTextures: boolean;
  21743. /**
  21744. * Specifies if the material should be serialized
  21745. */
  21746. doNotSerialize: boolean;
  21747. /**
  21748. * @hidden
  21749. */
  21750. _storeEffectOnSubMeshes: boolean;
  21751. /**
  21752. * Stores the animations for the material
  21753. */
  21754. animations: Array<Animation>;
  21755. /**
  21756. * An event triggered when the material is disposed
  21757. */
  21758. onDisposeObservable: Observable<Material>;
  21759. /**
  21760. * An observer which watches for dispose events
  21761. */
  21762. private _onDisposeObserver;
  21763. private _onUnBindObservable;
  21764. /**
  21765. * Called during a dispose event
  21766. */
  21767. onDispose: () => void;
  21768. private _onBindObservable;
  21769. /**
  21770. * An event triggered when the material is bound
  21771. */
  21772. readonly onBindObservable: Observable<AbstractMesh>;
  21773. /**
  21774. * An observer which watches for bind events
  21775. */
  21776. private _onBindObserver;
  21777. /**
  21778. * Called during a bind event
  21779. */
  21780. onBind: (Mesh: AbstractMesh) => void;
  21781. /**
  21782. * An event triggered when the material is unbound
  21783. */
  21784. readonly onUnBindObservable: Observable<Material>;
  21785. /**
  21786. * Stores the value of the alpha mode
  21787. */
  21788. private _alphaMode;
  21789. /**
  21790. * Sets the value of the alpha mode.
  21791. *
  21792. * | Value | Type | Description |
  21793. * | --- | --- | --- |
  21794. * | 0 | ALPHA_DISABLE | |
  21795. * | 1 | ALPHA_ADD | |
  21796. * | 2 | ALPHA_COMBINE | |
  21797. * | 3 | ALPHA_SUBTRACT | |
  21798. * | 4 | ALPHA_MULTIPLY | |
  21799. * | 5 | ALPHA_MAXIMIZED | |
  21800. * | 6 | ALPHA_ONEONE | |
  21801. * | 7 | ALPHA_PREMULTIPLIED | |
  21802. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21803. * | 9 | ALPHA_INTERPOLATE | |
  21804. * | 10 | ALPHA_SCREENMODE | |
  21805. *
  21806. */
  21807. /**
  21808. * Gets the value of the alpha mode
  21809. */
  21810. alphaMode: number;
  21811. /**
  21812. * Stores the state of the need depth pre-pass value
  21813. */
  21814. private _needDepthPrePass;
  21815. /**
  21816. * Sets the need depth pre-pass value
  21817. */
  21818. /**
  21819. * Gets the depth pre-pass value
  21820. */
  21821. needDepthPrePass: boolean;
  21822. /**
  21823. * Specifies if depth writing should be disabled
  21824. */
  21825. disableDepthWrite: boolean;
  21826. /**
  21827. * Specifies if depth writing should be forced
  21828. */
  21829. forceDepthWrite: boolean;
  21830. /**
  21831. * Specifies if there should be a separate pass for culling
  21832. */
  21833. separateCullingPass: boolean;
  21834. /**
  21835. * Stores the state specifing if fog should be enabled
  21836. */
  21837. private _fogEnabled;
  21838. /**
  21839. * Sets the state for enabling fog
  21840. */
  21841. /**
  21842. * Gets the value of the fog enabled state
  21843. */
  21844. fogEnabled: boolean;
  21845. /**
  21846. * Stores the size of points
  21847. */
  21848. pointSize: number;
  21849. /**
  21850. * Stores the z offset value
  21851. */
  21852. zOffset: number;
  21853. /**
  21854. * Gets a value specifying if wireframe mode is enabled
  21855. */
  21856. /**
  21857. * Sets the state of wireframe mode
  21858. */
  21859. wireframe: boolean;
  21860. /**
  21861. * Gets the value specifying if point clouds are enabled
  21862. */
  21863. /**
  21864. * Sets the state of point cloud mode
  21865. */
  21866. pointsCloud: boolean;
  21867. /**
  21868. * Gets the material fill mode
  21869. */
  21870. /**
  21871. * Sets the material fill mode
  21872. */
  21873. fillMode: number;
  21874. /**
  21875. * @hidden
  21876. * Stores the effects for the material
  21877. */
  21878. _effect: Nullable<Effect>;
  21879. /**
  21880. * @hidden
  21881. * Specifies if the material was previously ready
  21882. */
  21883. _wasPreviouslyReady: boolean;
  21884. /**
  21885. * Specifies if uniform buffers should be used
  21886. */
  21887. private _useUBO;
  21888. /**
  21889. * Stores a reference to the scene
  21890. */
  21891. private _scene;
  21892. /**
  21893. * Stores the fill mode state
  21894. */
  21895. private _fillMode;
  21896. /**
  21897. * Specifies if the depth write state should be cached
  21898. */
  21899. private _cachedDepthWriteState;
  21900. /**
  21901. * Stores the uniform buffer
  21902. */
  21903. protected _uniformBuffer: UniformBuffer;
  21904. /** @hidden */
  21905. _indexInSceneMaterialArray: number;
  21906. /** @hidden */
  21907. meshMap: Nullable<{
  21908. [id: string]: AbstractMesh | undefined;
  21909. }>;
  21910. /**
  21911. * Creates a material instance
  21912. * @param name defines the name of the material
  21913. * @param scene defines the scene to reference
  21914. * @param doNotAdd specifies if the material should be added to the scene
  21915. */
  21916. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21917. /**
  21918. * Returns a string representation of the current material
  21919. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21920. * @returns a string with material information
  21921. */
  21922. toString(fullDetails?: boolean): string;
  21923. /**
  21924. * Gets the class name of the material
  21925. * @returns a string with the class name of the material
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Specifies if updates for the material been locked
  21930. */
  21931. readonly isFrozen: boolean;
  21932. /**
  21933. * Locks updates for the material
  21934. */
  21935. freeze(): void;
  21936. /**
  21937. * Unlocks updates for the material
  21938. */
  21939. unfreeze(): void;
  21940. /**
  21941. * Specifies if the material is ready to be used
  21942. * @param mesh defines the mesh to check
  21943. * @param useInstances specifies if instances should be used
  21944. * @returns a boolean indicating if the material is ready to be used
  21945. */
  21946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21947. /**
  21948. * Specifies that the submesh is ready to be used
  21949. * @param mesh defines the mesh to check
  21950. * @param subMesh defines which submesh to check
  21951. * @param useInstances specifies that instances should be used
  21952. * @returns a boolean indicating that the submesh is ready or not
  21953. */
  21954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21955. /**
  21956. * Returns the material effect
  21957. * @returns the effect associated with the material
  21958. */
  21959. getEffect(): Nullable<Effect>;
  21960. /**
  21961. * Returns the current scene
  21962. * @returns a Scene
  21963. */
  21964. getScene(): Scene;
  21965. /**
  21966. * Specifies if the material will require alpha blending
  21967. * @returns a boolean specifying if alpha blending is needed
  21968. */
  21969. needAlphaBlending(): boolean;
  21970. /**
  21971. * Specifies if the mesh will require alpha blending
  21972. * @param mesh defines the mesh to check
  21973. * @returns a boolean specifying if alpha blending is needed for the mesh
  21974. */
  21975. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21976. /**
  21977. * Specifies if this material should be rendered in alpha test mode
  21978. * @returns a boolean specifying if an alpha test is needed.
  21979. */
  21980. needAlphaTesting(): boolean;
  21981. /**
  21982. * Gets the texture used for the alpha test
  21983. * @returns the texture to use for alpha testing
  21984. */
  21985. getAlphaTestTexture(): Nullable<BaseTexture>;
  21986. /**
  21987. * Marks the material to indicate that it needs to be re-calculated
  21988. */
  21989. markDirty(): void;
  21990. /** @hidden */
  21991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21992. /**
  21993. * Binds the material to the mesh
  21994. * @param world defines the world transformation matrix
  21995. * @param mesh defines the mesh to bind the material to
  21996. */
  21997. bind(world: Matrix, mesh?: Mesh): void;
  21998. /**
  21999. * Binds the submesh to the material
  22000. * @param world defines the world transformation matrix
  22001. * @param mesh defines the mesh containing the submesh
  22002. * @param subMesh defines the submesh to bind the material to
  22003. */
  22004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22005. /**
  22006. * Binds the world matrix to the material
  22007. * @param world defines the world transformation matrix
  22008. */
  22009. bindOnlyWorldMatrix(world: Matrix): void;
  22010. /**
  22011. * Binds the scene's uniform buffer to the effect.
  22012. * @param effect defines the effect to bind to the scene uniform buffer
  22013. * @param sceneUbo defines the uniform buffer storing scene data
  22014. */
  22015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22016. /**
  22017. * Binds the view matrix to the effect
  22018. * @param effect defines the effect to bind the view matrix to
  22019. */
  22020. bindView(effect: Effect): void;
  22021. /**
  22022. * Binds the view projection matrix to the effect
  22023. * @param effect defines the effect to bind the view projection matrix to
  22024. */
  22025. bindViewProjection(effect: Effect): void;
  22026. /**
  22027. * Specifies if material alpha testing should be turned on for the mesh
  22028. * @param mesh defines the mesh to check
  22029. */
  22030. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22031. /**
  22032. * Processes to execute after binding the material to a mesh
  22033. * @param mesh defines the rendered mesh
  22034. */
  22035. protected _afterBind(mesh?: Mesh): void;
  22036. /**
  22037. * Unbinds the material from the mesh
  22038. */
  22039. unbind(): void;
  22040. /**
  22041. * Gets the active textures from the material
  22042. * @returns an array of textures
  22043. */
  22044. getActiveTextures(): BaseTexture[];
  22045. /**
  22046. * Specifies if the material uses a texture
  22047. * @param texture defines the texture to check against the material
  22048. * @returns a boolean specifying if the material uses the texture
  22049. */
  22050. hasTexture(texture: BaseTexture): boolean;
  22051. /**
  22052. * Makes a duplicate of the material, and gives it a new name
  22053. * @param name defines the new name for the duplicated material
  22054. * @returns the cloned material
  22055. */
  22056. clone(name: string): Nullable<Material>;
  22057. /**
  22058. * Gets the meshes bound to the material
  22059. * @returns an array of meshes bound to the material
  22060. */
  22061. getBindedMeshes(): AbstractMesh[];
  22062. /**
  22063. * Force shader compilation
  22064. * @param mesh defines the mesh associated with this material
  22065. * @param onCompiled defines a function to execute once the material is compiled
  22066. * @param options defines the options to configure the compilation
  22067. */
  22068. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22069. clipPlane: boolean;
  22070. }>): void;
  22071. /**
  22072. * Force shader compilation
  22073. * @param mesh defines the mesh that will use this material
  22074. * @param options defines additional options for compiling the shaders
  22075. * @returns a promise that resolves when the compilation completes
  22076. */
  22077. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22078. clipPlane: boolean;
  22079. }>): Promise<void>;
  22080. private static readonly _ImageProcessingDirtyCallBack;
  22081. private static readonly _TextureDirtyCallBack;
  22082. private static readonly _FresnelDirtyCallBack;
  22083. private static readonly _MiscDirtyCallBack;
  22084. private static readonly _LightsDirtyCallBack;
  22085. private static readonly _AttributeDirtyCallBack;
  22086. private static _FresnelAndMiscDirtyCallBack;
  22087. private static _TextureAndMiscDirtyCallBack;
  22088. private static readonly _DirtyCallbackArray;
  22089. private static readonly _RunDirtyCallBacks;
  22090. /**
  22091. * Marks a define in the material to indicate that it needs to be re-computed
  22092. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22093. */
  22094. markAsDirty(flag: number): void;
  22095. /**
  22096. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22097. * @param func defines a function which checks material defines against the submeshes
  22098. */
  22099. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22100. /**
  22101. * Indicates that image processing needs to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22104. /**
  22105. * Indicates that textures need to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsTexturesDirty(): void;
  22108. /**
  22109. * Indicates that fresnel needs to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsFresnelDirty(): void;
  22112. /**
  22113. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22116. /**
  22117. * Indicates that lights need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsLightsDirty(): void;
  22120. /**
  22121. * Indicates that attributes need to be re-calculated for all submeshes
  22122. */
  22123. protected _markAllSubMeshesAsAttributesDirty(): void;
  22124. /**
  22125. * Indicates that misc needs to be re-calculated for all submeshes
  22126. */
  22127. protected _markAllSubMeshesAsMiscDirty(): void;
  22128. /**
  22129. * Indicates that textures and misc need to be re-calculated for all submeshes
  22130. */
  22131. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22132. /**
  22133. * Disposes the material
  22134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22137. */
  22138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22139. /** @hidden */
  22140. private releaseVertexArrayObject;
  22141. /**
  22142. * Serializes this material
  22143. * @returns the serialized material object
  22144. */
  22145. serialize(): any;
  22146. /**
  22147. * Creates a material from parsed material data
  22148. * @param parsedMaterial defines parsed material data
  22149. * @param scene defines the hosting scene
  22150. * @param rootUrl defines the root URL to use to load textures
  22151. * @returns a new material
  22152. */
  22153. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22154. }
  22155. }
  22156. declare module "babylonjs/Meshes/subMesh" {
  22157. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22158. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22159. import { Engine } from "babylonjs/Engines/engine";
  22160. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22161. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22162. import { Effect } from "babylonjs/Materials/effect";
  22163. import { Collider } from "babylonjs/Collisions/collider";
  22164. import { Material } from "babylonjs/Materials/material";
  22165. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22167. import { Mesh } from "babylonjs/Meshes/mesh";
  22168. import { Ray } from "babylonjs/Culling/ray";
  22169. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22170. /**
  22171. * Base class for submeshes
  22172. */
  22173. export class BaseSubMesh {
  22174. /** @hidden */
  22175. _materialDefines: Nullable<MaterialDefines>;
  22176. /** @hidden */
  22177. _materialEffect: Nullable<Effect>;
  22178. /**
  22179. * Gets associated effect
  22180. */
  22181. readonly effect: Nullable<Effect>;
  22182. /**
  22183. * Sets associated effect (effect used to render this submesh)
  22184. * @param effect defines the effect to associate with
  22185. * @param defines defines the set of defines used to compile this effect
  22186. */
  22187. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22188. }
  22189. /**
  22190. * Defines a subdivision inside a mesh
  22191. */
  22192. export class SubMesh extends BaseSubMesh implements ICullable {
  22193. /** the material index to use */
  22194. materialIndex: number;
  22195. /** vertex index start */
  22196. verticesStart: number;
  22197. /** vertices count */
  22198. verticesCount: number;
  22199. /** index start */
  22200. indexStart: number;
  22201. /** indices count */
  22202. indexCount: number;
  22203. /** @hidden */
  22204. _linesIndexCount: number;
  22205. private _mesh;
  22206. private _renderingMesh;
  22207. private _boundingInfo;
  22208. private _linesIndexBuffer;
  22209. /** @hidden */
  22210. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22211. /** @hidden */
  22212. _trianglePlanes: Plane[];
  22213. /** @hidden */
  22214. _lastColliderTransformMatrix: Matrix;
  22215. /** @hidden */
  22216. _renderId: number;
  22217. /** @hidden */
  22218. _alphaIndex: number;
  22219. /** @hidden */
  22220. _distanceToCamera: number;
  22221. /** @hidden */
  22222. _id: number;
  22223. private _currentMaterial;
  22224. /**
  22225. * Add a new submesh to a mesh
  22226. * @param materialIndex defines the material index to use
  22227. * @param verticesStart defines vertex index start
  22228. * @param verticesCount defines vertices count
  22229. * @param indexStart defines index start
  22230. * @param indexCount defines indices count
  22231. * @param mesh defines the parent mesh
  22232. * @param renderingMesh defines an optional rendering mesh
  22233. * @param createBoundingBox defines if bounding box should be created for this submesh
  22234. * @returns the new submesh
  22235. */
  22236. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22237. /**
  22238. * Creates a new submesh
  22239. * @param materialIndex defines the material index to use
  22240. * @param verticesStart defines vertex index start
  22241. * @param verticesCount defines vertices count
  22242. * @param indexStart defines index start
  22243. * @param indexCount defines indices count
  22244. * @param mesh defines the parent mesh
  22245. * @param renderingMesh defines an optional rendering mesh
  22246. * @param createBoundingBox defines if bounding box should be created for this submesh
  22247. */
  22248. constructor(
  22249. /** the material index to use */
  22250. materialIndex: number,
  22251. /** vertex index start */
  22252. verticesStart: number,
  22253. /** vertices count */
  22254. verticesCount: number,
  22255. /** index start */
  22256. indexStart: number,
  22257. /** indices count */
  22258. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22259. /**
  22260. * Returns true if this submesh covers the entire parent mesh
  22261. * @ignorenaming
  22262. */
  22263. readonly IsGlobal: boolean;
  22264. /**
  22265. * Returns the submesh BoudingInfo object
  22266. * @returns current bounding info (or mesh's one if the submesh is global)
  22267. */
  22268. getBoundingInfo(): BoundingInfo;
  22269. /**
  22270. * Sets the submesh BoundingInfo
  22271. * @param boundingInfo defines the new bounding info to use
  22272. * @returns the SubMesh
  22273. */
  22274. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22275. /**
  22276. * Returns the mesh of the current submesh
  22277. * @return the parent mesh
  22278. */
  22279. getMesh(): AbstractMesh;
  22280. /**
  22281. * Returns the rendering mesh of the submesh
  22282. * @returns the rendering mesh (could be different from parent mesh)
  22283. */
  22284. getRenderingMesh(): Mesh;
  22285. /**
  22286. * Returns the submesh material
  22287. * @returns null or the current material
  22288. */
  22289. getMaterial(): Nullable<Material>;
  22290. /**
  22291. * Sets a new updated BoundingInfo object to the submesh
  22292. * @returns the SubMesh
  22293. */
  22294. refreshBoundingInfo(): SubMesh;
  22295. /** @hidden */
  22296. _checkCollision(collider: Collider): boolean;
  22297. /**
  22298. * Updates the submesh BoundingInfo
  22299. * @param world defines the world matrix to use to update the bounding info
  22300. * @returns the submesh
  22301. */
  22302. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22303. /**
  22304. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22305. * @param frustumPlanes defines the frustum planes
  22306. * @returns true if the submesh is intersecting with the frustum
  22307. */
  22308. isInFrustum(frustumPlanes: Plane[]): boolean;
  22309. /**
  22310. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22311. * @param frustumPlanes defines the frustum planes
  22312. * @returns true if the submesh is inside the frustum
  22313. */
  22314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22315. /**
  22316. * Renders the submesh
  22317. * @param enableAlphaMode defines if alpha needs to be used
  22318. * @returns the submesh
  22319. */
  22320. render(enableAlphaMode: boolean): SubMesh;
  22321. /**
  22322. * @hidden
  22323. */
  22324. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22325. /**
  22326. * Checks if the submesh intersects with a ray
  22327. * @param ray defines the ray to test
  22328. * @returns true is the passed ray intersects the submesh bounding box
  22329. */
  22330. canIntersects(ray: Ray): boolean;
  22331. /**
  22332. * Intersects current submesh with a ray
  22333. * @param ray defines the ray to test
  22334. * @param positions defines mesh's positions array
  22335. * @param indices defines mesh's indices array
  22336. * @param fastCheck defines if only bounding info should be used
  22337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22338. * @returns intersection info or null if no intersection
  22339. */
  22340. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22341. /** @hidden */
  22342. private _intersectLines;
  22343. /** @hidden */
  22344. private _intersectTriangles;
  22345. /** @hidden */
  22346. _rebuild(): void;
  22347. /**
  22348. * Creates a new submesh from the passed mesh
  22349. * @param newMesh defines the new hosting mesh
  22350. * @param newRenderingMesh defines an optional rendering mesh
  22351. * @returns the new submesh
  22352. */
  22353. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22354. /**
  22355. * Release associated resources
  22356. */
  22357. dispose(): void;
  22358. /**
  22359. * Gets the class name
  22360. * @returns the string "SubMesh".
  22361. */
  22362. getClassName(): string;
  22363. /**
  22364. * Creates a new submesh from indices data
  22365. * @param materialIndex the index of the main mesh material
  22366. * @param startIndex the index where to start the copy in the mesh indices array
  22367. * @param indexCount the number of indices to copy then from the startIndex
  22368. * @param mesh the main mesh to create the submesh from
  22369. * @param renderingMesh the optional rendering mesh
  22370. * @returns a new submesh
  22371. */
  22372. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22373. }
  22374. }
  22375. declare module "babylonjs/Meshes/geometry" {
  22376. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22377. import { Scene } from "babylonjs/scene";
  22378. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22379. import { Engine } from "babylonjs/Engines/engine";
  22380. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22382. import { Effect } from "babylonjs/Materials/effect";
  22383. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22384. import { Mesh } from "babylonjs/Meshes/mesh";
  22385. /**
  22386. * Class used to store geometry data (vertex buffers + index buffer)
  22387. */
  22388. export class Geometry implements IGetSetVerticesData {
  22389. /**
  22390. * Gets or sets the ID of the geometry
  22391. */
  22392. id: string;
  22393. /**
  22394. * Gets or sets the unique ID of the geometry
  22395. */
  22396. uniqueId: number;
  22397. /**
  22398. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22399. */
  22400. delayLoadState: number;
  22401. /**
  22402. * Gets the file containing the data to load when running in delay load state
  22403. */
  22404. delayLoadingFile: Nullable<string>;
  22405. /**
  22406. * Callback called when the geometry is updated
  22407. */
  22408. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22409. private _scene;
  22410. private _engine;
  22411. private _meshes;
  22412. private _totalVertices;
  22413. /** @hidden */
  22414. _indices: IndicesArray;
  22415. /** @hidden */
  22416. _vertexBuffers: {
  22417. [key: string]: VertexBuffer;
  22418. };
  22419. private _isDisposed;
  22420. private _extend;
  22421. private _boundingBias;
  22422. /** @hidden */
  22423. _delayInfo: Array<string>;
  22424. private _indexBuffer;
  22425. private _indexBufferIsUpdatable;
  22426. /** @hidden */
  22427. _boundingInfo: Nullable<BoundingInfo>;
  22428. /** @hidden */
  22429. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22430. /** @hidden */
  22431. _softwareSkinningFrameId: number;
  22432. private _vertexArrayObjects;
  22433. private _updatable;
  22434. /** @hidden */
  22435. _positions: Nullable<Vector3[]>;
  22436. /**
  22437. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22438. */
  22439. /**
  22440. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22441. */
  22442. boundingBias: Vector2;
  22443. /**
  22444. * Static function used to attach a new empty geometry to a mesh
  22445. * @param mesh defines the mesh to attach the geometry to
  22446. * @returns the new Geometry
  22447. */
  22448. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22449. /**
  22450. * Creates a new geometry
  22451. * @param id defines the unique ID
  22452. * @param scene defines the hosting scene
  22453. * @param vertexData defines the VertexData used to get geometry data
  22454. * @param updatable defines if geometry must be updatable (false by default)
  22455. * @param mesh defines the mesh that will be associated with the geometry
  22456. */
  22457. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22458. /**
  22459. * Gets the current extend of the geometry
  22460. */
  22461. readonly extend: {
  22462. minimum: Vector3;
  22463. maximum: Vector3;
  22464. };
  22465. /**
  22466. * Gets the hosting scene
  22467. * @returns the hosting Scene
  22468. */
  22469. getScene(): Scene;
  22470. /**
  22471. * Gets the hosting engine
  22472. * @returns the hosting Engine
  22473. */
  22474. getEngine(): Engine;
  22475. /**
  22476. * Defines if the geometry is ready to use
  22477. * @returns true if the geometry is ready to be used
  22478. */
  22479. isReady(): boolean;
  22480. /**
  22481. * Gets a value indicating that the geometry should not be serialized
  22482. */
  22483. readonly doNotSerialize: boolean;
  22484. /** @hidden */
  22485. _rebuild(): void;
  22486. /**
  22487. * Affects all geometry data in one call
  22488. * @param vertexData defines the geometry data
  22489. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22490. */
  22491. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22492. /**
  22493. * Set specific vertex data
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @param data defines the vertex data to use
  22496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22498. */
  22499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22500. /**
  22501. * Removes a specific vertex data
  22502. * @param kind defines the data kind (Position, normal, etc...)
  22503. */
  22504. removeVerticesData(kind: string): void;
  22505. /**
  22506. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22507. * @param buffer defines the vertex buffer to use
  22508. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22509. */
  22510. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22511. /**
  22512. * Update a specific vertex buffer
  22513. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22514. * It will do nothing if the buffer is not updatable
  22515. * @param kind defines the data kind (Position, normal, etc...)
  22516. * @param data defines the data to use
  22517. * @param offset defines the offset in the target buffer where to store the data
  22518. * @param useBytes set to true if the offset is in bytes
  22519. */
  22520. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22521. /**
  22522. * Update a specific vertex buffer
  22523. * This function will create a new buffer if the current one is not updatable
  22524. * @param kind defines the data kind (Position, normal, etc...)
  22525. * @param data defines the data to use
  22526. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22527. */
  22528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22529. private _updateBoundingInfo;
  22530. /** @hidden */
  22531. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22532. /**
  22533. * Gets total number of vertices
  22534. * @returns the total number of vertices
  22535. */
  22536. getTotalVertices(): number;
  22537. /**
  22538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22539. * @param kind defines the data kind (Position, normal, etc...)
  22540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22542. * @returns a float array containing vertex data
  22543. */
  22544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22545. /**
  22546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22547. * @param kind defines the data kind (Position, normal, etc...)
  22548. * @returns true if the vertex buffer with the specified kind is updatable
  22549. */
  22550. isVertexBufferUpdatable(kind: string): boolean;
  22551. /**
  22552. * Gets a specific vertex buffer
  22553. * @param kind defines the data kind (Position, normal, etc...)
  22554. * @returns a VertexBuffer
  22555. */
  22556. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22557. /**
  22558. * Returns all vertex buffers
  22559. * @return an object holding all vertex buffers indexed by kind
  22560. */
  22561. getVertexBuffers(): Nullable<{
  22562. [key: string]: VertexBuffer;
  22563. }>;
  22564. /**
  22565. * Gets a boolean indicating if specific vertex buffer is present
  22566. * @param kind defines the data kind (Position, normal, etc...)
  22567. * @returns true if data is present
  22568. */
  22569. isVerticesDataPresent(kind: string): boolean;
  22570. /**
  22571. * Gets a list of all attached data kinds (Position, normal, etc...)
  22572. * @returns a list of string containing all kinds
  22573. */
  22574. getVerticesDataKinds(): string[];
  22575. /**
  22576. * Update index buffer
  22577. * @param indices defines the indices to store in the index buffer
  22578. * @param offset defines the offset in the target buffer where to store the data
  22579. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22580. */
  22581. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22582. /**
  22583. * Creates a new index buffer
  22584. * @param indices defines the indices to store in the index buffer
  22585. * @param totalVertices defines the total number of vertices (could be null)
  22586. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22587. */
  22588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22589. /**
  22590. * Return the total number of indices
  22591. * @returns the total number of indices
  22592. */
  22593. getTotalIndices(): number;
  22594. /**
  22595. * Gets the index buffer array
  22596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22598. * @returns the index buffer array
  22599. */
  22600. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22601. /**
  22602. * Gets the index buffer
  22603. * @return the index buffer
  22604. */
  22605. getIndexBuffer(): Nullable<WebGLBuffer>;
  22606. /** @hidden */
  22607. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22608. /**
  22609. * Release the associated resources for a specific mesh
  22610. * @param mesh defines the source mesh
  22611. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22612. */
  22613. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22614. /**
  22615. * Apply current geometry to a given mesh
  22616. * @param mesh defines the mesh to apply geometry to
  22617. */
  22618. applyToMesh(mesh: Mesh): void;
  22619. private _updateExtend;
  22620. private _applyToMesh;
  22621. private notifyUpdate;
  22622. /**
  22623. * Load the geometry if it was flagged as delay loaded
  22624. * @param scene defines the hosting scene
  22625. * @param onLoaded defines a callback called when the geometry is loaded
  22626. */
  22627. load(scene: Scene, onLoaded?: () => void): void;
  22628. private _queueLoad;
  22629. /**
  22630. * Invert the geometry to move from a right handed system to a left handed one.
  22631. */
  22632. toLeftHanded(): void;
  22633. /** @hidden */
  22634. _resetPointsArrayCache(): void;
  22635. /** @hidden */
  22636. _generatePointsArray(): boolean;
  22637. /**
  22638. * Gets a value indicating if the geometry is disposed
  22639. * @returns true if the geometry was disposed
  22640. */
  22641. isDisposed(): boolean;
  22642. private _disposeVertexArrayObjects;
  22643. /**
  22644. * Free all associated resources
  22645. */
  22646. dispose(): void;
  22647. /**
  22648. * Clone the current geometry into a new geometry
  22649. * @param id defines the unique ID of the new geometry
  22650. * @returns a new geometry object
  22651. */
  22652. copy(id: string): Geometry;
  22653. /**
  22654. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22655. * @return a JSON representation of the current geometry data (without the vertices data)
  22656. */
  22657. serialize(): any;
  22658. private toNumberArray;
  22659. /**
  22660. * Serialize all vertices data into a JSON oject
  22661. * @returns a JSON representation of the current geometry data
  22662. */
  22663. serializeVerticeData(): any;
  22664. /**
  22665. * Extracts a clone of a mesh geometry
  22666. * @param mesh defines the source mesh
  22667. * @param id defines the unique ID of the new geometry object
  22668. * @returns the new geometry object
  22669. */
  22670. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22671. /**
  22672. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22673. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22674. * Be aware Math.random() could cause collisions, but:
  22675. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22676. * @returns a string containing a new GUID
  22677. */
  22678. static RandomId(): string;
  22679. /** @hidden */
  22680. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22681. private static _CleanMatricesWeights;
  22682. /**
  22683. * Create a new geometry from persisted data (Using .babylon file format)
  22684. * @param parsedVertexData defines the persisted data
  22685. * @param scene defines the hosting scene
  22686. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22687. * @returns the new geometry object
  22688. */
  22689. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22690. }
  22691. }
  22692. declare module "babylonjs/Meshes/mesh.vertexData" {
  22693. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22694. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22695. import { Geometry } from "babylonjs/Meshes/geometry";
  22696. import { Mesh } from "babylonjs/Meshes/mesh";
  22697. /**
  22698. * Define an interface for all classes that will get and set the data on vertices
  22699. */
  22700. export interface IGetSetVerticesData {
  22701. /**
  22702. * Gets a boolean indicating if specific vertex data is present
  22703. * @param kind defines the vertex data kind to use
  22704. * @returns true is data kind is present
  22705. */
  22706. isVerticesDataPresent(kind: string): boolean;
  22707. /**
  22708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22709. * @param kind defines the data kind (Position, normal, etc...)
  22710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22712. * @returns a float array containing vertex data
  22713. */
  22714. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22715. /**
  22716. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22717. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22718. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22719. * @returns the indices array or an empty array if the mesh has no geometry
  22720. */
  22721. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22722. /**
  22723. * Set specific vertex data
  22724. * @param kind defines the data kind (Position, normal, etc...)
  22725. * @param data defines the vertex data to use
  22726. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22727. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22728. */
  22729. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22730. /**
  22731. * Update a specific associated vertex buffer
  22732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22733. * - VertexBuffer.PositionKind
  22734. * - VertexBuffer.UVKind
  22735. * - VertexBuffer.UV2Kind
  22736. * - VertexBuffer.UV3Kind
  22737. * - VertexBuffer.UV4Kind
  22738. * - VertexBuffer.UV5Kind
  22739. * - VertexBuffer.UV6Kind
  22740. * - VertexBuffer.ColorKind
  22741. * - VertexBuffer.MatricesIndicesKind
  22742. * - VertexBuffer.MatricesIndicesExtraKind
  22743. * - VertexBuffer.MatricesWeightsKind
  22744. * - VertexBuffer.MatricesWeightsExtraKind
  22745. * @param data defines the data source
  22746. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22747. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22748. */
  22749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22750. /**
  22751. * Creates a new index buffer
  22752. * @param indices defines the indices to store in the index buffer
  22753. * @param totalVertices defines the total number of vertices (could be null)
  22754. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22755. */
  22756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22757. }
  22758. /**
  22759. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22760. */
  22761. export class VertexData {
  22762. /**
  22763. * Mesh side orientation : usually the external or front surface
  22764. */
  22765. static readonly FRONTSIDE: number;
  22766. /**
  22767. * Mesh side orientation : usually the internal or back surface
  22768. */
  22769. static readonly BACKSIDE: number;
  22770. /**
  22771. * Mesh side orientation : both internal and external or front and back surfaces
  22772. */
  22773. static readonly DOUBLESIDE: number;
  22774. /**
  22775. * Mesh side orientation : by default, `FRONTSIDE`
  22776. */
  22777. static readonly DEFAULTSIDE: number;
  22778. /**
  22779. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22780. */
  22781. positions: Nullable<FloatArray>;
  22782. /**
  22783. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22784. */
  22785. normals: Nullable<FloatArray>;
  22786. /**
  22787. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22788. */
  22789. tangents: Nullable<FloatArray>;
  22790. /**
  22791. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22792. */
  22793. uvs: Nullable<FloatArray>;
  22794. /**
  22795. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22796. */
  22797. uvs2: Nullable<FloatArray>;
  22798. /**
  22799. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22800. */
  22801. uvs3: Nullable<FloatArray>;
  22802. /**
  22803. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22804. */
  22805. uvs4: Nullable<FloatArray>;
  22806. /**
  22807. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22808. */
  22809. uvs5: Nullable<FloatArray>;
  22810. /**
  22811. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22812. */
  22813. uvs6: Nullable<FloatArray>;
  22814. /**
  22815. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22816. */
  22817. colors: Nullable<FloatArray>;
  22818. /**
  22819. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22820. */
  22821. matricesIndices: Nullable<FloatArray>;
  22822. /**
  22823. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22824. */
  22825. matricesWeights: Nullable<FloatArray>;
  22826. /**
  22827. * An array extending the number of possible indices
  22828. */
  22829. matricesIndicesExtra: Nullable<FloatArray>;
  22830. /**
  22831. * An array extending the number of possible weights when the number of indices is extended
  22832. */
  22833. matricesWeightsExtra: Nullable<FloatArray>;
  22834. /**
  22835. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22836. */
  22837. indices: Nullable<IndicesArray>;
  22838. /**
  22839. * Uses the passed data array to set the set the values for the specified kind of data
  22840. * @param data a linear array of floating numbers
  22841. * @param kind the type of data that is being set, eg positions, colors etc
  22842. */
  22843. set(data: FloatArray, kind: string): void;
  22844. /**
  22845. * Associates the vertexData to the passed Mesh.
  22846. * Sets it as updatable or not (default `false`)
  22847. * @param mesh the mesh the vertexData is applied to
  22848. * @param updatable when used and having the value true allows new data to update the vertexData
  22849. * @returns the VertexData
  22850. */
  22851. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22852. /**
  22853. * Associates the vertexData to the passed Geometry.
  22854. * Sets it as updatable or not (default `false`)
  22855. * @param geometry the geometry the vertexData is applied to
  22856. * @param updatable when used and having the value true allows new data to update the vertexData
  22857. * @returns VertexData
  22858. */
  22859. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22860. /**
  22861. * Updates the associated mesh
  22862. * @param mesh the mesh to be updated
  22863. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22864. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22865. * @returns VertexData
  22866. */
  22867. updateMesh(mesh: Mesh): VertexData;
  22868. /**
  22869. * Updates the associated geometry
  22870. * @param geometry the geometry to be updated
  22871. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22872. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22873. * @returns VertexData.
  22874. */
  22875. updateGeometry(geometry: Geometry): VertexData;
  22876. private _applyTo;
  22877. private _update;
  22878. /**
  22879. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22880. * @param matrix the transforming matrix
  22881. * @returns the VertexData
  22882. */
  22883. transform(matrix: Matrix): VertexData;
  22884. /**
  22885. * Merges the passed VertexData into the current one
  22886. * @param other the VertexData to be merged into the current one
  22887. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22888. * @returns the modified VertexData
  22889. */
  22890. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22891. private _mergeElement;
  22892. private _validate;
  22893. /**
  22894. * Serializes the VertexData
  22895. * @returns a serialized object
  22896. */
  22897. serialize(): any;
  22898. /**
  22899. * Extracts the vertexData from a mesh
  22900. * @param mesh the mesh from which to extract the VertexData
  22901. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22902. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22903. * @returns the object VertexData associated to the passed mesh
  22904. */
  22905. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22906. /**
  22907. * Extracts the vertexData from the geometry
  22908. * @param geometry the geometry from which to extract the VertexData
  22909. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22910. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22911. * @returns the object VertexData associated to the passed mesh
  22912. */
  22913. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22914. private static _ExtractFrom;
  22915. /**
  22916. * Creates the VertexData for a Ribbon
  22917. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22918. * * pathArray array of paths, each of which an array of successive Vector3
  22919. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22920. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22921. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22923. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22924. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22925. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22926. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22927. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22928. * @returns the VertexData of the ribbon
  22929. */
  22930. static CreateRibbon(options: {
  22931. pathArray: Vector3[][];
  22932. closeArray?: boolean;
  22933. closePath?: boolean;
  22934. offset?: number;
  22935. sideOrientation?: number;
  22936. frontUVs?: Vector4;
  22937. backUVs?: Vector4;
  22938. invertUV?: boolean;
  22939. uvs?: Vector2[];
  22940. colors?: Color4[];
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a box
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22946. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22947. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22948. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22949. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22950. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22953. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22954. * @returns the VertexData of the box
  22955. */
  22956. static CreateBox(options: {
  22957. size?: number;
  22958. width?: number;
  22959. height?: number;
  22960. depth?: number;
  22961. faceUV?: Vector4[];
  22962. faceColors?: Color4[];
  22963. sideOrientation?: number;
  22964. frontUVs?: Vector4;
  22965. backUVs?: Vector4;
  22966. }): VertexData;
  22967. /**
  22968. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22970. * * segments sets the number of horizontal strips optional, default 32
  22971. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22972. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22973. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22974. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22975. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22976. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22978. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22979. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22980. * @returns the VertexData of the ellipsoid
  22981. */
  22982. static CreateSphere(options: {
  22983. segments?: number;
  22984. diameter?: number;
  22985. diameterX?: number;
  22986. diameterY?: number;
  22987. diameterZ?: number;
  22988. arc?: number;
  22989. slice?: number;
  22990. sideOrientation?: number;
  22991. frontUVs?: Vector4;
  22992. backUVs?: Vector4;
  22993. }): VertexData;
  22994. /**
  22995. * Creates the VertexData for a cylinder, cone or prism
  22996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22997. * * height sets the height (y direction) of the cylinder, optional, default 2
  22998. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22999. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23000. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23002. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23003. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  23004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23006. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23007. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23009. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23010. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23011. * @returns the VertexData of the cylinder, cone or prism
  23012. */
  23013. static CreateCylinder(options: {
  23014. height?: number;
  23015. diameterTop?: number;
  23016. diameterBottom?: number;
  23017. diameter?: number;
  23018. tessellation?: number;
  23019. subdivisions?: number;
  23020. arc?: number;
  23021. faceColors?: Color4[];
  23022. faceUV?: Vector4[];
  23023. hasRings?: boolean;
  23024. enclose?: boolean;
  23025. sideOrientation?: number;
  23026. frontUVs?: Vector4;
  23027. backUVs?: Vector4;
  23028. }): VertexData;
  23029. /**
  23030. * Creates the VertexData for a torus
  23031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23032. * * diameter the diameter of the torus, optional default 1
  23033. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23036. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23037. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23038. * @returns the VertexData of the torus
  23039. */
  23040. static CreateTorus(options: {
  23041. diameter?: number;
  23042. thickness?: number;
  23043. tessellation?: number;
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData of the LineSystem
  23050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23051. * - lines an array of lines, each line being an array of successive Vector3
  23052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23053. * @returns the VertexData of the LineSystem
  23054. */
  23055. static CreateLineSystem(options: {
  23056. lines: Vector3[][];
  23057. colors?: Nullable<Color4[][]>;
  23058. }): VertexData;
  23059. /**
  23060. * Create the VertexData for a DashedLines
  23061. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23062. * - points an array successive Vector3
  23063. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23064. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23065. * - dashNb the intended total number of dashes, optional, default 200
  23066. * @returns the VertexData for the DashedLines
  23067. */
  23068. static CreateDashedLines(options: {
  23069. points: Vector3[];
  23070. dashSize?: number;
  23071. gapSize?: number;
  23072. dashNb?: number;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for a Ground
  23076. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23077. * - width the width (x direction) of the ground, optional, default 1
  23078. * - height the height (z direction) of the ground, optional, default 1
  23079. * - subdivisions the number of subdivisions per side, optional, default 1
  23080. * @returns the VertexData of the Ground
  23081. */
  23082. static CreateGround(options: {
  23083. width?: number;
  23084. height?: number;
  23085. subdivisions?: number;
  23086. subdivisionsX?: number;
  23087. subdivisionsY?: number;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23092. * * xmin the ground minimum X coordinate, optional, default -1
  23093. * * zmin the ground minimum Z coordinate, optional, default -1
  23094. * * xmax the ground maximum X coordinate, optional, default 1
  23095. * * zmax the ground maximum Z coordinate, optional, default 1
  23096. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  23097. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  23098. * @returns the VertexData of the TiledGround
  23099. */
  23100. static CreateTiledGround(options: {
  23101. xmin: number;
  23102. zmin: number;
  23103. xmax: number;
  23104. zmax: number;
  23105. subdivisions?: {
  23106. w: number;
  23107. h: number;
  23108. };
  23109. precision?: {
  23110. w: number;
  23111. h: number;
  23112. };
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData of the Ground designed from a heightmap
  23116. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23117. * * width the width (x direction) of the ground
  23118. * * height the height (z direction) of the ground
  23119. * * subdivisions the number of subdivisions per side
  23120. * * minHeight the minimum altitude on the ground, optional, default 0
  23121. * * maxHeight the maximum altitude on the ground, optional default 1
  23122. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23123. * * buffer the array holding the image color data
  23124. * * bufferWidth the width of image
  23125. * * bufferHeight the height of image
  23126. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23127. * @returns the VertexData of the Ground designed from a heightmap
  23128. */
  23129. static CreateGroundFromHeightMap(options: {
  23130. width: number;
  23131. height: number;
  23132. subdivisions: number;
  23133. minHeight: number;
  23134. maxHeight: number;
  23135. colorFilter: Color3;
  23136. buffer: Uint8Array;
  23137. bufferWidth: number;
  23138. bufferHeight: number;
  23139. alphaFilter: number;
  23140. }): VertexData;
  23141. /**
  23142. * Creates the VertexData for a Plane
  23143. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23144. * * size sets the width and height of the plane to the value of size, optional default 1
  23145. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23146. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23149. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23150. * @returns the VertexData of the box
  23151. */
  23152. static CreatePlane(options: {
  23153. size?: number;
  23154. width?: number;
  23155. height?: number;
  23156. sideOrientation?: number;
  23157. frontUVs?: Vector4;
  23158. backUVs?: Vector4;
  23159. }): VertexData;
  23160. /**
  23161. * Creates the VertexData of the Disc or regular Polygon
  23162. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23163. * * radius the radius of the disc, optional default 0.5
  23164. * * tessellation the number of polygon sides, optional, default 64
  23165. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  23166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23167. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23168. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23169. * @returns the VertexData of the box
  23170. */
  23171. static CreateDisc(options: {
  23172. radius?: number;
  23173. tessellation?: number;
  23174. arc?: number;
  23175. sideOrientation?: number;
  23176. frontUVs?: Vector4;
  23177. backUVs?: Vector4;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23181. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23182. * @param polygon a mesh built from polygonTriangulation.build()
  23183. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23184. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23185. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23186. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23187. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23188. * @returns the VertexData of the Polygon
  23189. */
  23190. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23191. /**
  23192. * Creates the VertexData of the IcoSphere
  23193. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23194. * * radius the radius of the IcoSphere, optional default 1
  23195. * * radiusX allows stretching in the x direction, optional, default radius
  23196. * * radiusY allows stretching in the y direction, optional, default radius
  23197. * * radiusZ allows stretching in the z direction, optional, default radius
  23198. * * flat when true creates a flat shaded mesh, optional, default true
  23199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23201. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23202. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23203. * @returns the VertexData of the IcoSphere
  23204. */
  23205. static CreateIcoSphere(options: {
  23206. radius?: number;
  23207. radiusX?: number;
  23208. radiusY?: number;
  23209. radiusZ?: number;
  23210. flat?: boolean;
  23211. subdivisions?: number;
  23212. sideOrientation?: number;
  23213. frontUVs?: Vector4;
  23214. backUVs?: Vector4;
  23215. }): VertexData;
  23216. /**
  23217. * Creates the VertexData for a Polyhedron
  23218. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23219. * * type provided types are:
  23220. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23221. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  23222. * * size the size of the IcoSphere, optional default 1
  23223. * * sizeX allows stretching in the x direction, optional, default size
  23224. * * sizeY allows stretching in the y direction, optional, default size
  23225. * * sizeZ allows stretching in the z direction, optional, default size
  23226. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  23227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23229. * * flat when true creates a flat shaded mesh, optional, default true
  23230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23232. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23233. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23234. * @returns the VertexData of the Polyhedron
  23235. */
  23236. static CreatePolyhedron(options: {
  23237. type?: number;
  23238. size?: number;
  23239. sizeX?: number;
  23240. sizeY?: number;
  23241. sizeZ?: number;
  23242. custom?: any;
  23243. faceUV?: Vector4[];
  23244. faceColors?: Color4[];
  23245. flat?: boolean;
  23246. sideOrientation?: number;
  23247. frontUVs?: Vector4;
  23248. backUVs?: Vector4;
  23249. }): VertexData;
  23250. /**
  23251. * Creates the VertexData for a TorusKnot
  23252. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23253. * * radius the radius of the torus knot, optional, default 2
  23254. * * tube the thickness of the tube, optional, default 0.5
  23255. * * radialSegments the number of sides on each tube segments, optional, default 32
  23256. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23257. * * p the number of windings around the z axis, optional, default 2
  23258. * * q the number of windings around the x axis, optional, default 3
  23259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23260. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23261. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23262. * @returns the VertexData of the Torus Knot
  23263. */
  23264. static CreateTorusKnot(options: {
  23265. radius?: number;
  23266. tube?: number;
  23267. radialSegments?: number;
  23268. tubularSegments?: number;
  23269. p?: number;
  23270. q?: number;
  23271. sideOrientation?: number;
  23272. frontUVs?: Vector4;
  23273. backUVs?: Vector4;
  23274. }): VertexData;
  23275. /**
  23276. * Compute normals for given positions and indices
  23277. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23278. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23279. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23280. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23281. * * facetNormals : optional array of facet normals (vector3)
  23282. * * facetPositions : optional array of facet positions (vector3)
  23283. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23284. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23285. * * bInfo : optional bounding info, required for facetPartitioning computation
  23286. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23287. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23288. * * useRightHandedSystem: optional boolean to for right handed system computation
  23289. * * depthSort : optional boolean to enable the facet depth sort computation
  23290. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23291. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23292. */
  23293. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23294. facetNormals?: any;
  23295. facetPositions?: any;
  23296. facetPartitioning?: any;
  23297. ratio?: number;
  23298. bInfo?: any;
  23299. bbSize?: Vector3;
  23300. subDiv?: any;
  23301. useRightHandedSystem?: boolean;
  23302. depthSort?: boolean;
  23303. distanceTo?: Vector3;
  23304. depthSortedFacets?: any;
  23305. }): void;
  23306. /** @hidden */
  23307. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23308. /**
  23309. * Applies VertexData created from the imported parameters to the geometry
  23310. * @param parsedVertexData the parsed data from an imported file
  23311. * @param geometry the geometry to apply the VertexData to
  23312. */
  23313. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23314. }
  23315. }
  23316. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23317. import { Nullable } from "babylonjs/types";
  23318. import { Scene } from "babylonjs/scene";
  23319. import { Vector4 } from "babylonjs/Maths/math";
  23320. import { Mesh } from "babylonjs/Meshes/mesh";
  23321. /**
  23322. * Class containing static functions to help procedurally build meshes
  23323. */
  23324. export class DiscBuilder {
  23325. /**
  23326. * Creates a plane polygonal mesh. By default, this is a disc
  23327. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23328. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  23329. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  23330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23333. * @param name defines the name of the mesh
  23334. * @param options defines the options used to create the mesh
  23335. * @param scene defines the hosting scene
  23336. * @returns the plane polygonal mesh
  23337. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23338. */
  23339. static CreateDisc(name: string, options: {
  23340. radius?: number;
  23341. tessellation?: number;
  23342. arc?: number;
  23343. updatable?: boolean;
  23344. sideOrientation?: number;
  23345. frontUVs?: Vector4;
  23346. backUVs?: Vector4;
  23347. }, scene?: Nullable<Scene>): Mesh;
  23348. }
  23349. }
  23350. declare module "babylonjs/Particles/solidParticleSystem" {
  23351. import { Vector3 } from "babylonjs/Maths/math";
  23352. import { Mesh } from "babylonjs/Meshes/mesh";
  23353. import { Scene, IDisposable } from "babylonjs/scene";
  23354. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23355. /**
  23356. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23357. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  23358. * The SPS is also a particle system. It provides some methods to manage the particles.
  23359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23360. *
  23361. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23362. */
  23363. export class SolidParticleSystem implements IDisposable {
  23364. /**
  23365. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23366. * Example : var p = SPS.particles[i];
  23367. */
  23368. particles: SolidParticle[];
  23369. /**
  23370. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23371. */
  23372. nbParticles: number;
  23373. /**
  23374. * If the particles must ever face the camera (default false). Useful for planar particles.
  23375. */
  23376. billboard: boolean;
  23377. /**
  23378. * Recompute normals when adding a shape
  23379. */
  23380. recomputeNormals: boolean;
  23381. /**
  23382. * This a counter ofr your own usage. It's not set by any SPS functions.
  23383. */
  23384. counter: number;
  23385. /**
  23386. * The SPS name. This name is also given to the underlying mesh.
  23387. */
  23388. name: string;
  23389. /**
  23390. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23391. */
  23392. mesh: Mesh;
  23393. /**
  23394. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23395. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23396. */
  23397. vars: any;
  23398. /**
  23399. * This array is populated when the SPS is set as 'pickable'.
  23400. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23401. * Each element of this array is an object `{idx: int, faceId: int}`.
  23402. * `idx` is the picked particle index in the `SPS.particles` array
  23403. * `faceId` is the picked face index counted within this particle.
  23404. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23405. */
  23406. pickedParticles: {
  23407. idx: number;
  23408. faceId: number;
  23409. }[];
  23410. /**
  23411. * This array is populated when `enableDepthSort` is set to true.
  23412. * Each element of this array is an instance of the class DepthSortedParticle.
  23413. */
  23414. depthSortedParticles: DepthSortedParticle[];
  23415. /**
  23416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23417. * @hidden
  23418. */
  23419. _bSphereOnly: boolean;
  23420. /**
  23421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23422. * @hidden
  23423. */
  23424. _bSphereRadiusFactor: number;
  23425. private _scene;
  23426. private _positions;
  23427. private _indices;
  23428. private _normals;
  23429. private _colors;
  23430. private _uvs;
  23431. private _indices32;
  23432. private _positions32;
  23433. private _normals32;
  23434. private _fixedNormal32;
  23435. private _colors32;
  23436. private _uvs32;
  23437. private _index;
  23438. private _updatable;
  23439. private _pickable;
  23440. private _isVisibilityBoxLocked;
  23441. private _alwaysVisible;
  23442. private _depthSort;
  23443. private _shapeCounter;
  23444. private _copy;
  23445. private _color;
  23446. private _computeParticleColor;
  23447. private _computeParticleTexture;
  23448. private _computeParticleRotation;
  23449. private _computeParticleVertex;
  23450. private _computeBoundingBox;
  23451. private _depthSortParticles;
  23452. private _camera;
  23453. private _mustUnrotateFixedNormals;
  23454. private _particlesIntersect;
  23455. private _needs32Bits;
  23456. /**
  23457. * Creates a SPS (Solid Particle System) object.
  23458. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23459. * @param scene (Scene) is the scene in which the SPS is added.
  23460. * @param options defines the options of the sps e.g.
  23461. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23462. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23463. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23464. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23465. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23466. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23467. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23468. */
  23469. constructor(name: string, scene: Scene, options?: {
  23470. updatable?: boolean;
  23471. isPickable?: boolean;
  23472. enableDepthSort?: boolean;
  23473. particleIntersection?: boolean;
  23474. boundingSphereOnly?: boolean;
  23475. bSphereRadiusFactor?: number;
  23476. });
  23477. /**
  23478. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23479. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23480. * @returns the created mesh
  23481. */
  23482. buildMesh(): Mesh;
  23483. /**
  23484. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23485. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23486. * Thus the particles generated from `digest()` have their property `position` set yet.
  23487. * @param mesh ( Mesh ) is the mesh to be digested
  23488. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  23489. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23490. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23491. * @returns the current SPS
  23492. */
  23493. digest(mesh: Mesh, options?: {
  23494. facetNb?: number;
  23495. number?: number;
  23496. delta?: number;
  23497. }): SolidParticleSystem;
  23498. private _unrotateFixedNormals;
  23499. private _resetCopy;
  23500. private _meshBuilder;
  23501. private _posToShape;
  23502. private _uvsToShapeUV;
  23503. private _addParticle;
  23504. /**
  23505. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23506. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23507. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23508. * @param nb (positive integer) the number of particles to be created from this model
  23509. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23510. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23511. * @returns the number of shapes in the system
  23512. */
  23513. addShape(mesh: Mesh, nb: number, options?: {
  23514. positionFunction?: any;
  23515. vertexFunction?: any;
  23516. }): number;
  23517. private _rebuildParticle;
  23518. /**
  23519. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23520. * @returns the SPS.
  23521. */
  23522. rebuildMesh(): SolidParticleSystem;
  23523. /**
  23524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23525. * This method calls `updateParticle()` for each particle of the SPS.
  23526. * For an animated SPS, it is usually called within the render loop.
  23527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23530. * @returns the SPS.
  23531. */
  23532. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23533. /**
  23534. * Disposes the SPS.
  23535. */
  23536. dispose(): void;
  23537. /**
  23538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23539. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23540. * @returns the SPS.
  23541. */
  23542. refreshVisibleSize(): SolidParticleSystem;
  23543. /**
  23544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23545. * @param size the size (float) of the visibility box
  23546. * note : this doesn't lock the SPS mesh bounding box.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23548. */
  23549. setVisibilityBox(size: number): void;
  23550. /**
  23551. * Gets whether the SPS as always visible or not
  23552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23553. */
  23554. /**
  23555. * Sets the SPS as always visible or not
  23556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23557. */
  23558. isAlwaysVisible: boolean;
  23559. /**
  23560. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23562. */
  23563. /**
  23564. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23566. */
  23567. isVisibilityBoxLocked: boolean;
  23568. /**
  23569. * Tells to `setParticles()` to compute the particle rotations or not.
  23570. * Default value : true. The SPS is faster when it's set to false.
  23571. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23572. */
  23573. /**
  23574. * Gets if `setParticles()` computes the particle rotations or not.
  23575. * Default value : true. The SPS is faster when it's set to false.
  23576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23577. */
  23578. computeParticleRotation: boolean;
  23579. /**
  23580. * Tells to `setParticles()` to compute the particle colors or not.
  23581. * Default value : true. The SPS is faster when it's set to false.
  23582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23583. */
  23584. /**
  23585. * Gets if `setParticles()` computes the particle colors or not.
  23586. * Default value : true. The SPS is faster when it's set to false.
  23587. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23588. */
  23589. computeParticleColor: boolean;
  23590. /**
  23591. * Gets if `setParticles()` computes the particle textures or not.
  23592. * Default value : true. The SPS is faster when it's set to false.
  23593. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23594. */
  23595. computeParticleTexture: boolean;
  23596. /**
  23597. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23598. * Default value : false. The SPS is faster when it's set to false.
  23599. * Note : the particle custom vertex positions aren't stored values.
  23600. */
  23601. /**
  23602. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23603. * Default value : false. The SPS is faster when it's set to false.
  23604. * Note : the particle custom vertex positions aren't stored values.
  23605. */
  23606. computeParticleVertex: boolean;
  23607. /**
  23608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23609. */
  23610. /**
  23611. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23612. */
  23613. computeBoundingBox: boolean;
  23614. /**
  23615. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23616. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23617. * Default : `true`
  23618. */
  23619. /**
  23620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23622. * Default : `true`
  23623. */
  23624. depthSortParticles: boolean;
  23625. /**
  23626. * This function does nothing. It may be overwritten to set all the particle first values.
  23627. * The SPS doesn't call this function, you may have to call it by your own.
  23628. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23629. */
  23630. initParticles(): void;
  23631. /**
  23632. * This function does nothing. It may be overwritten to recycle a particle.
  23633. * The SPS doesn't call this function, you may have to call it by your own.
  23634. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23635. * @param particle The particle to recycle
  23636. * @returns the recycled particle
  23637. */
  23638. recycleParticle(particle: SolidParticle): SolidParticle;
  23639. /**
  23640. * Updates a particle : this function should be overwritten by the user.
  23641. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23643. * @example : just set a particle position or velocity and recycle conditions
  23644. * @param particle The particle to update
  23645. * @returns the updated particle
  23646. */
  23647. updateParticle(particle: SolidParticle): SolidParticle;
  23648. /**
  23649. * Updates a vertex of a particle : it can be overwritten by the user.
  23650. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23651. * @param particle the current particle
  23652. * @param vertex the current index of the current particle
  23653. * @param pt the index of the current vertex in the particle shape
  23654. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23655. * @example : just set a vertex particle position
  23656. * @returns the updated vertex
  23657. */
  23658. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23659. /**
  23660. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23661. * This does nothing and may be overwritten by the user.
  23662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23664. * @param update the boolean update value actually passed to setParticles()
  23665. */
  23666. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23667. /**
  23668. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23669. * This will be passed three parameters.
  23670. * This does nothing and may be overwritten by the user.
  23671. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23673. * @param update the boolean update value actually passed to setParticles()
  23674. */
  23675. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23676. }
  23677. }
  23678. declare module "babylonjs/Particles/solidParticle" {
  23679. import { Nullable } from "babylonjs/types";
  23680. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23681. import { Mesh } from "babylonjs/Meshes/mesh";
  23682. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23683. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23684. /**
  23685. * Represents one particle of a solid particle system.
  23686. */
  23687. export class SolidParticle {
  23688. /**
  23689. * particle global index
  23690. */
  23691. idx: number;
  23692. /**
  23693. * The color of the particle
  23694. */
  23695. color: Nullable<Color4>;
  23696. /**
  23697. * The world space position of the particle.
  23698. */
  23699. position: Vector3;
  23700. /**
  23701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23702. */
  23703. rotation: Vector3;
  23704. /**
  23705. * The world space rotation quaternion of the particle.
  23706. */
  23707. rotationQuaternion: Nullable<Quaternion>;
  23708. /**
  23709. * The scaling of the particle.
  23710. */
  23711. scaling: Vector3;
  23712. /**
  23713. * The uvs of the particle.
  23714. */
  23715. uvs: Vector4;
  23716. /**
  23717. * The current speed of the particle.
  23718. */
  23719. velocity: Vector3;
  23720. /**
  23721. * The pivot point in the particle local space.
  23722. */
  23723. pivot: Vector3;
  23724. /**
  23725. * Must the particle be translated from its pivot point in its local space ?
  23726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23727. * Default : false
  23728. */
  23729. translateFromPivot: boolean;
  23730. /**
  23731. * Is the particle active or not ?
  23732. */
  23733. alive: boolean;
  23734. /**
  23735. * Is the particle visible or not ?
  23736. */
  23737. isVisible: boolean;
  23738. /**
  23739. * Index of this particle in the global "positions" array (Internal use)
  23740. * @hidden
  23741. */
  23742. _pos: number;
  23743. /**
  23744. * @hidden Index of this particle in the global "indices" array (Internal use)
  23745. */
  23746. _ind: number;
  23747. /**
  23748. * @hidden ModelShape of this particle (Internal use)
  23749. */
  23750. _model: ModelShape;
  23751. /**
  23752. * ModelShape id of this particle
  23753. */
  23754. shapeId: number;
  23755. /**
  23756. * Index of the particle in its shape id (Internal use)
  23757. */
  23758. idxInShape: number;
  23759. /**
  23760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23761. */
  23762. _modelBoundingInfo: BoundingInfo;
  23763. /**
  23764. * @hidden Particle BoundingInfo object (Internal use)
  23765. */
  23766. _boundingInfo: BoundingInfo;
  23767. /**
  23768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23769. */
  23770. _sps: SolidParticleSystem;
  23771. /**
  23772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23773. */
  23774. _stillInvisible: boolean;
  23775. /**
  23776. * @hidden Last computed particle rotation matrix
  23777. */
  23778. _rotationMatrix: number[];
  23779. /**
  23780. * Parent particle Id, if any.
  23781. * Default null.
  23782. */
  23783. parentId: Nullable<number>;
  23784. /**
  23785. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23786. * The possible values are :
  23787. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23788. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23790. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23791. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23792. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23793. * */
  23794. cullingStrategy: number;
  23795. /**
  23796. * @hidden Internal global position in the SPS.
  23797. */
  23798. _globalPosition: Vector3;
  23799. /**
  23800. * Creates a Solid Particle object.
  23801. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23802. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23803. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23804. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23805. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23806. * @param shapeId (integer) is the model shape identifier in the SPS.
  23807. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23808. * @param sps defines the sps it is associated to
  23809. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23810. */
  23811. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23812. /**
  23813. * Legacy support, changed scale to scaling
  23814. */
  23815. /**
  23816. * Legacy support, changed scale to scaling
  23817. */
  23818. scale: Vector3;
  23819. /**
  23820. * Legacy support, changed quaternion to rotationQuaternion
  23821. */
  23822. /**
  23823. * Legacy support, changed quaternion to rotationQuaternion
  23824. */
  23825. quaternion: Nullable<Quaternion>;
  23826. /**
  23827. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23828. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23829. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23830. * @returns true if it intersects
  23831. */
  23832. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23833. /**
  23834. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23835. * A particle is in the frustum if its bounding box intersects the frustum
  23836. * @param frustumPlanes defines the frustum to test
  23837. * @returns true if the particle is in the frustum planes
  23838. */
  23839. isInFrustum(frustumPlanes: Plane[]): boolean;
  23840. /**
  23841. * get the rotation matrix of the particle
  23842. * @hidden
  23843. */
  23844. getRotationMatrix(m: Matrix): void;
  23845. }
  23846. /**
  23847. * Represents the shape of the model used by one particle of a solid particle system.
  23848. * SPS internal tool, don't use it manually.
  23849. */
  23850. export class ModelShape {
  23851. /**
  23852. * The shape id
  23853. * @hidden
  23854. */
  23855. shapeID: number;
  23856. /**
  23857. * flat array of model positions (internal use)
  23858. * @hidden
  23859. */
  23860. _shape: Vector3[];
  23861. /**
  23862. * flat array of model UVs (internal use)
  23863. * @hidden
  23864. */
  23865. _shapeUV: number[];
  23866. /**
  23867. * length of the shape in the model indices array (internal use)
  23868. * @hidden
  23869. */
  23870. _indicesLength: number;
  23871. /**
  23872. * Custom position function (internal use)
  23873. * @hidden
  23874. */
  23875. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23876. /**
  23877. * Custom vertex function (internal use)
  23878. * @hidden
  23879. */
  23880. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23881. /**
  23882. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  23883. * SPS internal tool, don't use it manually.
  23884. * @hidden
  23885. */
  23886. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  23887. }
  23888. /**
  23889. * Represents a Depth Sorted Particle in the solid particle system.
  23890. */
  23891. export class DepthSortedParticle {
  23892. /**
  23893. * Index of the particle in the "indices" array
  23894. */
  23895. ind: number;
  23896. /**
  23897. * Length of the particle shape in the "indices" array
  23898. */
  23899. indicesLength: number;
  23900. /**
  23901. * Squared distance from the particle to the camera
  23902. */
  23903. sqDistance: number;
  23904. }
  23905. }
  23906. declare module "babylonjs/Meshes/abstractMesh" {
  23907. import { Observable } from "babylonjs/Misc/observable";
  23908. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23909. import { Camera } from "babylonjs/Cameras/camera";
  23910. import { Scene, IDisposable } from "babylonjs/scene";
  23911. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23912. import { Node } from "babylonjs/node";
  23913. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23916. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23917. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23918. import { Material } from "babylonjs/Materials/material";
  23919. import { Light } from "babylonjs/Lights/light";
  23920. import { Skeleton } from "babylonjs/Bones/skeleton";
  23921. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23922. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23923. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23924. import { Ray } from "babylonjs/Culling/ray";
  23925. import { Collider } from "babylonjs/Collisions/collider";
  23926. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23927. /**
  23928. * Class used to store all common mesh properties
  23929. */
  23930. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23931. /** No occlusion */
  23932. static OCCLUSION_TYPE_NONE: number;
  23933. /** Occlusion set to optimisitic */
  23934. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23935. /** Occlusion set to strict */
  23936. static OCCLUSION_TYPE_STRICT: number;
  23937. /** Use an accurante occlusion algorithm */
  23938. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23939. /** Use a conservative occlusion algorithm */
  23940. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23941. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23942. * Test order :
  23943. * Is the bounding sphere outside the frustum ?
  23944. * If not, are the bounding box vertices outside the frustum ?
  23945. * It not, then the cullable object is in the frustum.
  23946. */
  23947. static readonly CULLINGSTRATEGY_STANDARD: number;
  23948. /** Culling strategy : Bounding Sphere Only.
  23949. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23950. * It's also less accurate than the standard because some not visible objects can still be selected.
  23951. * Test : is the bounding sphere outside the frustum ?
  23952. * If not, then the cullable object is in the frustum.
  23953. */
  23954. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23955. /** Culling strategy : Optimistic Inclusion.
  23956. * This in an inclusion test first, then the standard exclusion test.
  23957. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23958. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  23959. * Anyway, it's as accurate as the standard strategy.
  23960. * Test :
  23961. * Is the cullable object bounding sphere center in the frustum ?
  23962. * If not, apply the default culling strategy.
  23963. */
  23964. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23965. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23966. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23967. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23968. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  23969. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23970. * Test :
  23971. * Is the cullable object bounding sphere center in the frustum ?
  23972. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23973. */
  23974. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23975. /**
  23976. * No billboard
  23977. */
  23978. static readonly BILLBOARDMODE_NONE: number;
  23979. /** Billboard on X axis */
  23980. static readonly BILLBOARDMODE_X: number;
  23981. /** Billboard on Y axis */
  23982. static readonly BILLBOARDMODE_Y: number;
  23983. /** Billboard on Z axis */
  23984. static readonly BILLBOARDMODE_Z: number;
  23985. /** Billboard on all axes */
  23986. static readonly BILLBOARDMODE_ALL: number;
  23987. private _facetData;
  23988. /**
  23989. * The culling strategy to use to check whether the mesh must be rendered or not.
  23990. * This value can be changed at any time and will be used on the next render mesh selection.
  23991. * The possible values are :
  23992. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23993. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23994. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23995. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23996. * Please read each static variable documentation to get details about the culling process.
  23997. * */
  23998. cullingStrategy: number;
  23999. /**
  24000. * Gets the number of facets in the mesh
  24001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24002. */
  24003. readonly facetNb: number;
  24004. /**
  24005. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24007. */
  24008. partitioningSubdivisions: number;
  24009. /**
  24010. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24011. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24013. */
  24014. partitioningBBoxRatio: number;
  24015. /**
  24016. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24017. * Works only for updatable meshes.
  24018. * Doesn't work with multi-materials
  24019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24020. */
  24021. mustDepthSortFacets: boolean;
  24022. /**
  24023. * The location (Vector3) where the facet depth sort must be computed from.
  24024. * By default, the active camera position.
  24025. * Used only when facet depth sort is enabled
  24026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24027. */
  24028. facetDepthSortFrom: Vector3;
  24029. /**
  24030. * gets a boolean indicating if facetData is enabled
  24031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24032. */
  24033. readonly isFacetDataEnabled: boolean;
  24034. /** @hidden */
  24035. _updateNonUniformScalingState(value: boolean): boolean;
  24036. /**
  24037. * An event triggered when this mesh collides with another one
  24038. */
  24039. onCollideObservable: Observable<AbstractMesh>;
  24040. private _onCollideObserver;
  24041. /** Set a function to call when this mesh collides with another one */
  24042. onCollide: () => void;
  24043. /**
  24044. * An event triggered when the collision's position changes
  24045. */
  24046. onCollisionPositionChangeObservable: Observable<Vector3>;
  24047. private _onCollisionPositionChangeObserver;
  24048. /** Set a function to call when the collision's position changes */
  24049. onCollisionPositionChange: () => void;
  24050. /**
  24051. * An event triggered when material is changed
  24052. */
  24053. onMaterialChangedObservable: Observable<AbstractMesh>;
  24054. /**
  24055. * Gets or sets the orientation for POV movement & rotation
  24056. */
  24057. definedFacingForward: boolean;
  24058. /** @hidden */
  24059. _occlusionQuery: Nullable<WebGLQuery>;
  24060. private _visibility;
  24061. /**
  24062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24063. */
  24064. /**
  24065. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24066. */
  24067. visibility: number;
  24068. /** Gets or sets the alpha index used to sort transparent meshes
  24069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24070. */
  24071. alphaIndex: number;
  24072. /**
  24073. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24074. */
  24075. isVisible: boolean;
  24076. /**
  24077. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24078. */
  24079. isPickable: boolean;
  24080. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24081. showSubMeshesBoundingBox: boolean;
  24082. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24084. */
  24085. isBlocker: boolean;
  24086. /**
  24087. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24088. */
  24089. enablePointerMoveEvents: boolean;
  24090. /**
  24091. * Specifies the rendering group id for this mesh (0 by default)
  24092. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24093. */
  24094. renderingGroupId: number;
  24095. private _material;
  24096. /** Gets or sets current material */
  24097. material: Nullable<Material>;
  24098. private _receiveShadows;
  24099. /**
  24100. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24101. * @see http://doc.babylonjs.com/babylon101/shadows
  24102. */
  24103. receiveShadows: boolean;
  24104. /** Defines color to use when rendering outline */
  24105. outlineColor: Color3;
  24106. /** Define width to use when rendering outline */
  24107. outlineWidth: number;
  24108. /** Defines color to use when rendering overlay */
  24109. overlayColor: Color3;
  24110. /** Defines alpha to use when rendering overlay */
  24111. overlayAlpha: number;
  24112. private _hasVertexAlpha;
  24113. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24114. hasVertexAlpha: boolean;
  24115. private _useVertexColors;
  24116. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  24117. useVertexColors: boolean;
  24118. private _computeBonesUsingShaders;
  24119. /**
  24120. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24121. */
  24122. computeBonesUsingShaders: boolean;
  24123. private _numBoneInfluencers;
  24124. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24125. numBoneInfluencers: number;
  24126. private _applyFog;
  24127. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24128. applyFog: boolean;
  24129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24130. useOctreeForRenderingSelection: boolean;
  24131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24132. useOctreeForPicking: boolean;
  24133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24134. useOctreeForCollisions: boolean;
  24135. private _layerMask;
  24136. /**
  24137. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24138. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24139. */
  24140. layerMask: number;
  24141. /**
  24142. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24143. */
  24144. alwaysSelectAsActiveMesh: boolean;
  24145. /**
  24146. * Gets or sets the current action manager
  24147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24148. */
  24149. actionManager: Nullable<AbstractActionManager>;
  24150. private _checkCollisions;
  24151. private _collisionMask;
  24152. private _collisionGroup;
  24153. /**
  24154. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24156. */
  24157. ellipsoid: Vector3;
  24158. /**
  24159. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24161. */
  24162. ellipsoidOffset: Vector3;
  24163. private _collider;
  24164. private _oldPositionForCollisions;
  24165. private _diffPositionForCollisions;
  24166. /**
  24167. * Gets or sets a collision mask used to mask collisions (default is -1).
  24168. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24169. */
  24170. collisionMask: number;
  24171. /**
  24172. * Gets or sets the current collision group mask (-1 by default).
  24173. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24174. */
  24175. collisionGroup: number;
  24176. /**
  24177. * Defines edge width used when edgesRenderer is enabled
  24178. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24179. */
  24180. edgesWidth: number;
  24181. /**
  24182. * Defines edge color used when edgesRenderer is enabled
  24183. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24184. */
  24185. edgesColor: Color4;
  24186. /** @hidden */
  24187. _edgesRenderer: Nullable<IEdgesRenderer>;
  24188. /** @hidden */
  24189. _masterMesh: Nullable<AbstractMesh>;
  24190. /** @hidden */
  24191. _boundingInfo: Nullable<BoundingInfo>;
  24192. /** @hidden */
  24193. _renderId: number;
  24194. /**
  24195. * Gets or sets the list of subMeshes
  24196. * @see http://doc.babylonjs.com/how_to/multi_materials
  24197. */
  24198. subMeshes: SubMesh[];
  24199. /** @hidden */
  24200. _intersectionsInProgress: AbstractMesh[];
  24201. /** @hidden */
  24202. _unIndexed: boolean;
  24203. /** @hidden */
  24204. _lightSources: Light[];
  24205. /** @hidden */
  24206. readonly _positions: Nullable<Vector3[]>;
  24207. /** @hidden */
  24208. _waitingActions: any;
  24209. /** @hidden */
  24210. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24211. private _skeleton;
  24212. /** @hidden */
  24213. _bonesTransformMatrices: Nullable<Float32Array>;
  24214. /**
  24215. * Gets or sets a skeleton to apply skining transformations
  24216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24217. */
  24218. skeleton: Nullable<Skeleton>;
  24219. /**
  24220. * An event triggered when the mesh is rebuilt.
  24221. */
  24222. onRebuildObservable: Observable<AbstractMesh>;
  24223. /**
  24224. * Creates a new AbstractMesh
  24225. * @param name defines the name of the mesh
  24226. * @param scene defines the hosting scene
  24227. */
  24228. constructor(name: string, scene?: Nullable<Scene>);
  24229. /**
  24230. * Returns the string "AbstractMesh"
  24231. * @returns "AbstractMesh"
  24232. */
  24233. getClassName(): string;
  24234. /**
  24235. * Gets a string representation of the current mesh
  24236. * @param fullDetails defines a boolean indicating if full details must be included
  24237. * @returns a string representation of the current mesh
  24238. */
  24239. toString(fullDetails?: boolean): string;
  24240. /** @hidden */
  24241. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24242. /** @hidden */
  24243. _rebuild(): void;
  24244. /** @hidden */
  24245. _resyncLightSources(): void;
  24246. /** @hidden */
  24247. _resyncLighSource(light: Light): void;
  24248. /** @hidden */
  24249. _unBindEffect(): void;
  24250. /** @hidden */
  24251. _removeLightSource(light: Light): void;
  24252. private _markSubMeshesAsDirty;
  24253. /** @hidden */
  24254. _markSubMeshesAsLightDirty(): void;
  24255. /** @hidden */
  24256. _markSubMeshesAsAttributesDirty(): void;
  24257. /** @hidden */
  24258. _markSubMeshesAsMiscDirty(): void;
  24259. /**
  24260. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24261. */
  24262. scaling: Vector3;
  24263. /**
  24264. * Returns true if the mesh is blocked. Implemented by child classes
  24265. */
  24266. readonly isBlocked: boolean;
  24267. /**
  24268. * Returns the mesh itself by default. Implemented by child classes
  24269. * @param camera defines the camera to use to pick the right LOD level
  24270. * @returns the currentAbstractMesh
  24271. */
  24272. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24273. /**
  24274. * Returns 0 by default. Implemented by child classes
  24275. * @returns an integer
  24276. */
  24277. getTotalVertices(): number;
  24278. /**
  24279. * Returns a positive integer : the total number of indices in this mesh geometry.
  24280. * @returns the numner of indices or zero if the mesh has no geometry.
  24281. */
  24282. getTotalIndices(): number;
  24283. /**
  24284. * Returns null by default. Implemented by child classes
  24285. * @returns null
  24286. */
  24287. getIndices(): Nullable<IndicesArray>;
  24288. /**
  24289. * Returns the array of the requested vertex data kind. Implemented by child classes
  24290. * @param kind defines the vertex data kind to use
  24291. * @returns null
  24292. */
  24293. getVerticesData(kind: string): Nullable<FloatArray>;
  24294. /**
  24295. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24296. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24297. * Note that a new underlying VertexBuffer object is created each call.
  24298. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24299. * @param kind defines vertex data kind:
  24300. * * VertexBuffer.PositionKind
  24301. * * VertexBuffer.UVKind
  24302. * * VertexBuffer.UV2Kind
  24303. * * VertexBuffer.UV3Kind
  24304. * * VertexBuffer.UV4Kind
  24305. * * VertexBuffer.UV5Kind
  24306. * * VertexBuffer.UV6Kind
  24307. * * VertexBuffer.ColorKind
  24308. * * VertexBuffer.MatricesIndicesKind
  24309. * * VertexBuffer.MatricesIndicesExtraKind
  24310. * * VertexBuffer.MatricesWeightsKind
  24311. * * VertexBuffer.MatricesWeightsExtraKind
  24312. * @param data defines the data source
  24313. * @param updatable defines if the data must be flagged as updatable (or static)
  24314. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  24315. * @returns the current mesh
  24316. */
  24317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24318. /**
  24319. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24320. * If the mesh has no geometry, it is simply returned as it is.
  24321. * @param kind defines vertex data kind:
  24322. * * VertexBuffer.PositionKind
  24323. * * VertexBuffer.UVKind
  24324. * * VertexBuffer.UV2Kind
  24325. * * VertexBuffer.UV3Kind
  24326. * * VertexBuffer.UV4Kind
  24327. * * VertexBuffer.UV5Kind
  24328. * * VertexBuffer.UV6Kind
  24329. * * VertexBuffer.ColorKind
  24330. * * VertexBuffer.MatricesIndicesKind
  24331. * * VertexBuffer.MatricesIndicesExtraKind
  24332. * * VertexBuffer.MatricesWeightsKind
  24333. * * VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  24336. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24337. * @returns the current mesh
  24338. */
  24339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24340. /**
  24341. * Sets the mesh indices,
  24342. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24343. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24344. * @param totalVertices Defines the total number of vertices
  24345. * @returns the current mesh
  24346. */
  24347. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24348. /**
  24349. * Gets a boolean indicating if specific vertex data is present
  24350. * @param kind defines the vertex data kind to use
  24351. * @returns true is data kind is present
  24352. */
  24353. isVerticesDataPresent(kind: string): boolean;
  24354. /**
  24355. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24356. * @returns a BoundingInfo
  24357. */
  24358. getBoundingInfo(): BoundingInfo;
  24359. /**
  24360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24362. * @returns the current mesh
  24363. */
  24364. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24365. /**
  24366. * Overwrite the current bounding info
  24367. * @param boundingInfo defines the new bounding info
  24368. * @returns the current mesh
  24369. */
  24370. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24371. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24372. readonly useBones: boolean;
  24373. /** @hidden */
  24374. _preActivate(): void;
  24375. /** @hidden */
  24376. _preActivateForIntermediateRendering(renderId: number): void;
  24377. /** @hidden */
  24378. _activate(renderId: number): void;
  24379. /**
  24380. * Gets the current world matrix
  24381. * @returns a Matrix
  24382. */
  24383. getWorldMatrix(): Matrix;
  24384. /** @hidden */
  24385. _getWorldMatrixDeterminant(): number;
  24386. /**
  24387. * Perform relative position change from the point of view of behind the front of the mesh.
  24388. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24389. * Supports definition of mesh facing forward or backward
  24390. * @param amountRight defines the distance on the right axis
  24391. * @param amountUp defines the distance on the up axis
  24392. * @param amountForward defines the distance on the forward axis
  24393. * @returns the current mesh
  24394. */
  24395. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24396. /**
  24397. * Calculate relative position change from the point of view of behind the front of the mesh.
  24398. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24399. * Supports definition of mesh facing forward or backward
  24400. * @param amountRight defines the distance on the right axis
  24401. * @param amountUp defines the distance on the up axis
  24402. * @param amountForward defines the distance on the forward axis
  24403. * @returns the new displacement vector
  24404. */
  24405. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24406. /**
  24407. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24408. * Supports definition of mesh facing forward or backward
  24409. * @param flipBack defines the flip
  24410. * @param twirlClockwise defines the twirl
  24411. * @param tiltRight defines the tilt
  24412. * @returns the current mesh
  24413. */
  24414. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24415. /**
  24416. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24417. * Supports definition of mesh facing forward or backward.
  24418. * @param flipBack defines the flip
  24419. * @param twirlClockwise defines the twirl
  24420. * @param tiltRight defines the tilt
  24421. * @returns the new rotation vector
  24422. */
  24423. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24424. /**
  24425. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24426. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24427. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  24428. * @returns the new bounding vectors
  24429. */
  24430. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24431. min: Vector3;
  24432. max: Vector3;
  24433. };
  24434. /**
  24435. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24436. * This means the mesh underlying bounding box and sphere are recomputed.
  24437. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24438. * @returns the current mesh
  24439. */
  24440. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24441. /** @hidden */
  24442. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24443. /** @hidden */
  24444. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24445. /** @hidden */
  24446. _updateBoundingInfo(): AbstractMesh;
  24447. /** @hidden */
  24448. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24449. /** @hidden */
  24450. protected _afterComputeWorldMatrix(): void;
  24451. /**
  24452. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24453. * A mesh is in the frustum if its bounding box intersects the frustum
  24454. * @param frustumPlanes defines the frustum to test
  24455. * @returns true if the mesh is in the frustum planes
  24456. */
  24457. isInFrustum(frustumPlanes: Plane[]): boolean;
  24458. /**
  24459. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24460. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24461. * @param frustumPlanes defines the frustum to test
  24462. * @returns true if the mesh is completely in the frustum planes
  24463. */
  24464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24465. /**
  24466. * True if the mesh intersects another mesh or a SolidParticle object
  24467. * @param mesh defines a target mesh or SolidParticle to test
  24468. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  24469. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24470. * @returns true if there is an intersection
  24471. */
  24472. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24473. /**
  24474. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24475. * @param point defines the point to test
  24476. * @returns true if there is an intersection
  24477. */
  24478. intersectsPoint(point: Vector3): boolean;
  24479. /**
  24480. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24481. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24482. */
  24483. checkCollisions: boolean;
  24484. /**
  24485. * Gets Collider object used to compute collisions (not physics)
  24486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24487. */
  24488. readonly collider: Collider;
  24489. /**
  24490. * Move the mesh using collision engine
  24491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24492. * @param displacement defines the requested displacement vector
  24493. * @returns the current mesh
  24494. */
  24495. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24496. private _onCollisionPositionChange;
  24497. /** @hidden */
  24498. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24499. /** @hidden */
  24500. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24501. /** @hidden */
  24502. _checkCollision(collider: Collider): AbstractMesh;
  24503. /** @hidden */
  24504. _generatePointsArray(): boolean;
  24505. /**
  24506. * Checks if the passed Ray intersects with the mesh
  24507. * @param ray defines the ray to use
  24508. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24510. * @returns the picking info
  24511. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24512. */
  24513. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24514. /**
  24515. * Clones the current mesh
  24516. * @param name defines the mesh name
  24517. * @param newParent defines the new mesh parent
  24518. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24519. * @returns the new mesh
  24520. */
  24521. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24522. /**
  24523. * Disposes all the submeshes of the current meshnp
  24524. * @returns the current mesh
  24525. */
  24526. releaseSubMeshes(): AbstractMesh;
  24527. /**
  24528. * Releases resources associated with this abstract mesh.
  24529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24531. */
  24532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24533. /**
  24534. * Adds the passed mesh as a child to the current mesh
  24535. * @param mesh defines the child mesh
  24536. * @returns the current mesh
  24537. */
  24538. addChild(mesh: AbstractMesh): AbstractMesh;
  24539. /**
  24540. * Removes the passed mesh from the current mesh children list
  24541. * @param mesh defines the child mesh
  24542. * @returns the current mesh
  24543. */
  24544. removeChild(mesh: AbstractMesh): AbstractMesh;
  24545. /** @hidden */
  24546. private _initFacetData;
  24547. /**
  24548. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24549. * This method can be called within the render loop.
  24550. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  24551. * @returns the current mesh
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. updateFacetData(): AbstractMesh;
  24555. /**
  24556. * Returns the facetLocalNormals array.
  24557. * The normals are expressed in the mesh local spac
  24558. * @returns an array of Vector3
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24560. */
  24561. getFacetLocalNormals(): Vector3[];
  24562. /**
  24563. * Returns the facetLocalPositions array.
  24564. * The facet positions are expressed in the mesh local space
  24565. * @returns an array of Vector3
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24567. */
  24568. getFacetLocalPositions(): Vector3[];
  24569. /**
  24570. * Returns the facetLocalPartioning array
  24571. * @returns an array of array of numbers
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24573. */
  24574. getFacetLocalPartitioning(): number[][];
  24575. /**
  24576. * Returns the i-th facet position in the world system.
  24577. * This method allocates a new Vector3 per call
  24578. * @param i defines the facet index
  24579. * @returns a new Vector3
  24580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24581. */
  24582. getFacetPosition(i: number): Vector3;
  24583. /**
  24584. * Sets the reference Vector3 with the i-th facet position in the world system
  24585. * @param i defines the facet index
  24586. * @param ref defines the target vector
  24587. * @returns the current mesh
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24589. */
  24590. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24591. /**
  24592. * Returns the i-th facet normal in the world system.
  24593. * This method allocates a new Vector3 per call
  24594. * @param i defines the facet index
  24595. * @returns a new Vector3
  24596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24597. */
  24598. getFacetNormal(i: number): Vector3;
  24599. /**
  24600. * Sets the reference Vector3 with the i-th facet normal in the world system
  24601. * @param i defines the facet index
  24602. * @param ref defines the target vector
  24603. * @returns the current mesh
  24604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24605. */
  24606. getFacetNormalToRef(i: number, ref: Vector3): this;
  24607. /**
  24608. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  24609. * @param x defines x coordinate
  24610. * @param y defines y coordinate
  24611. * @param z defines z coordinate
  24612. * @returns the array of facet indexes
  24613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24614. */
  24615. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24616. /**
  24617. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24618. * @param projected sets as the (x,y,z) world projection on the facet
  24619. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  24620. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  24621. * @param x defines x coordinate
  24622. * @param y defines y coordinate
  24623. * @param z defines z coordinate
  24624. * @returns the face index if found (or null instead)
  24625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24626. */
  24627. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24628. /**
  24629. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24630. * @param projected sets as the (x,y,z) local projection on the facet
  24631. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  24632. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  24633. * @param x defines x coordinate
  24634. * @param y defines y coordinate
  24635. * @param z defines z coordinate
  24636. * @returns the face index if found (or null instead)
  24637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24638. */
  24639. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24640. /**
  24641. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24642. * @returns the parameters
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24644. */
  24645. getFacetDataParameters(): any;
  24646. /**
  24647. * Disables the feature FacetData and frees the related memory
  24648. * @returns the current mesh
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24650. */
  24651. disableFacetData(): AbstractMesh;
  24652. /**
  24653. * Updates the AbstractMesh indices array
  24654. * @param indices defines the data source
  24655. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24656. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24657. * @returns the current mesh
  24658. */
  24659. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24660. /**
  24661. * Creates new normals data for the mesh
  24662. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24663. * @returns the current mesh
  24664. */
  24665. createNormals(updatable: boolean): AbstractMesh;
  24666. /**
  24667. * Align the mesh with a normal
  24668. * @param normal defines the normal to use
  24669. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24670. * @returns the current mesh
  24671. */
  24672. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24673. /** @hidden */
  24674. _checkOcclusionQuery(): boolean;
  24675. }
  24676. }
  24677. declare module "babylonjs/Actions/actionEvent" {
  24678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Sprite } from "babylonjs/Sprites/sprite";
  24681. import { Scene } from "babylonjs/scene";
  24682. import { Vector2 } from "babylonjs/Maths/math";
  24683. /**
  24684. * Interface used to define ActionEvent
  24685. */
  24686. export interface IActionEvent {
  24687. /** The mesh or sprite that triggered the action */
  24688. source: any;
  24689. /** The X mouse cursor position at the time of the event */
  24690. pointerX: number;
  24691. /** The Y mouse cursor position at the time of the event */
  24692. pointerY: number;
  24693. /** The mesh that is currently pointed at (can be null) */
  24694. meshUnderPointer: Nullable<AbstractMesh>;
  24695. /** the original (browser) event that triggered the ActionEvent */
  24696. sourceEvent?: any;
  24697. /** additional data for the event */
  24698. additionalData?: any;
  24699. }
  24700. /**
  24701. * ActionEvent is the event being sent when an action is triggered.
  24702. */
  24703. export class ActionEvent implements IActionEvent {
  24704. /** The mesh or sprite that triggered the action */
  24705. source: any;
  24706. /** The X mouse cursor position at the time of the event */
  24707. pointerX: number;
  24708. /** The Y mouse cursor position at the time of the event */
  24709. pointerY: number;
  24710. /** The mesh that is currently pointed at (can be null) */
  24711. meshUnderPointer: Nullable<AbstractMesh>;
  24712. /** the original (browser) event that triggered the ActionEvent */
  24713. sourceEvent?: any;
  24714. /** additional data for the event */
  24715. additionalData?: any;
  24716. /**
  24717. * Creates a new ActionEvent
  24718. * @param source The mesh or sprite that triggered the action
  24719. * @param pointerX The X mouse cursor position at the time of the event
  24720. * @param pointerY The Y mouse cursor position at the time of the event
  24721. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24722. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24723. * @param additionalData additional data for the event
  24724. */
  24725. constructor(
  24726. /** The mesh or sprite that triggered the action */
  24727. source: any,
  24728. /** The X mouse cursor position at the time of the event */
  24729. pointerX: number,
  24730. /** The Y mouse cursor position at the time of the event */
  24731. pointerY: number,
  24732. /** The mesh that is currently pointed at (can be null) */
  24733. meshUnderPointer: Nullable<AbstractMesh>,
  24734. /** the original (browser) event that triggered the ActionEvent */
  24735. sourceEvent?: any,
  24736. /** additional data for the event */
  24737. additionalData?: any);
  24738. /**
  24739. * Helper function to auto-create an ActionEvent from a source mesh.
  24740. * @param source The source mesh that triggered the event
  24741. * @param evt The original (browser) event
  24742. * @param additionalData additional data for the event
  24743. * @returns the new ActionEvent
  24744. */
  24745. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24746. /**
  24747. * Helper function to auto-create an ActionEvent from a source sprite
  24748. * @param source The source sprite that triggered the event
  24749. * @param scene Scene associated with the sprite
  24750. * @param evt The original (browser) event
  24751. * @param additionalData additional data for the event
  24752. * @returns the new ActionEvent
  24753. */
  24754. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24755. /**
  24756. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24757. * @param scene the scene where the event occurred
  24758. * @param evt The original (browser) event
  24759. * @returns the new ActionEvent
  24760. */
  24761. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24762. /**
  24763. * Helper function to auto-create an ActionEvent from a primitive
  24764. * @param prim defines the target primitive
  24765. * @param pointerPos defines the pointer position
  24766. * @param evt The original (browser) event
  24767. * @param additionalData additional data for the event
  24768. * @returns the new ActionEvent
  24769. */
  24770. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24771. }
  24772. }
  24773. declare module "babylonjs/Actions/abstractActionManager" {
  24774. import { IDisposable } from "babylonjs/scene";
  24775. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24776. import { IAction } from "babylonjs/Actions/action";
  24777. import { Nullable } from "babylonjs/types";
  24778. /**
  24779. * Abstract class used to decouple action Manager from scene and meshes.
  24780. * Do not instantiate.
  24781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24782. */
  24783. export abstract class AbstractActionManager implements IDisposable {
  24784. /** Gets the list of active triggers */
  24785. static Triggers: {
  24786. [key: string]: number;
  24787. };
  24788. /** Gets the cursor to use when hovering items */
  24789. hoverCursor: string;
  24790. /** Gets the list of actions */
  24791. actions: IAction[];
  24792. /**
  24793. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24794. */
  24795. isRecursive: boolean;
  24796. /**
  24797. * Releases all associated resources
  24798. */
  24799. abstract dispose(): void;
  24800. /**
  24801. * Does this action manager has pointer triggers
  24802. */
  24803. abstract readonly hasPointerTriggers: boolean;
  24804. /**
  24805. * Does this action manager has pick triggers
  24806. */
  24807. abstract readonly hasPickTriggers: boolean;
  24808. /**
  24809. * Process a specific trigger
  24810. * @param trigger defines the trigger to process
  24811. * @param evt defines the event details to be processed
  24812. */
  24813. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24814. /**
  24815. * Does this action manager handles actions of any of the given triggers
  24816. * @param triggers defines the triggers to be tested
  24817. * @return a boolean indicating whether one (or more) of the triggers is handled
  24818. */
  24819. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24820. /**
  24821. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24822. * speed.
  24823. * @param triggerA defines the trigger to be tested
  24824. * @param triggerB defines the trigger to be tested
  24825. * @return a boolean indicating whether one (or more) of the triggers is handled
  24826. */
  24827. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24828. /**
  24829. * Does this action manager handles actions of a given trigger
  24830. * @param trigger defines the trigger to be tested
  24831. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24832. * @return whether the trigger is handled
  24833. */
  24834. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24835. /**
  24836. * Serialize this manager to a JSON object
  24837. * @param name defines the property name to store this manager
  24838. * @returns a JSON representation of this manager
  24839. */
  24840. abstract serialize(name: string): any;
  24841. /**
  24842. * Registers an action to this action manager
  24843. * @param action defines the action to be registered
  24844. * @return the action amended (prepared) after registration
  24845. */
  24846. abstract registerAction(action: IAction): Nullable<IAction>;
  24847. /**
  24848. * Unregisters an action to this action manager
  24849. * @param action defines the action to be unregistered
  24850. * @return a boolean indicating whether the action has been unregistered
  24851. */
  24852. abstract unregisterAction(action: IAction): Boolean;
  24853. /**
  24854. * Does exist one action manager with at least one trigger
  24855. **/
  24856. static readonly HasTriggers: boolean;
  24857. /**
  24858. * Does exist one action manager with at least one pick trigger
  24859. **/
  24860. static readonly HasPickTriggers: boolean;
  24861. /**
  24862. * Does exist one action manager that handles actions of a given trigger
  24863. * @param trigger defines the trigger to be tested
  24864. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24865. **/
  24866. static HasSpecificTrigger(trigger: number): boolean;
  24867. }
  24868. }
  24869. declare module "babylonjs/node" {
  24870. import { Scene } from "babylonjs/scene";
  24871. import { Nullable } from "babylonjs/types";
  24872. import { Matrix } from "babylonjs/Maths/math";
  24873. import { Engine } from "babylonjs/Engines/engine";
  24874. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24875. import { Observable } from "babylonjs/Misc/observable";
  24876. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24877. import { Animatable } from "babylonjs/Animations/animatable";
  24878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24879. import { Animation } from "babylonjs/Animations/animation";
  24880. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24882. /**
  24883. * Defines how a node can be built from a string name.
  24884. */
  24885. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24886. /**
  24887. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24888. */
  24889. export class Node implements IBehaviorAware<Node> {
  24890. /** @hidden */
  24891. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24892. private static _NodeConstructors;
  24893. /**
  24894. * Add a new node constructor
  24895. * @param type defines the type name of the node to construct
  24896. * @param constructorFunc defines the constructor function
  24897. */
  24898. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24899. /**
  24900. * Returns a node constructor based on type name
  24901. * @param type defines the type name
  24902. * @param name defines the new node name
  24903. * @param scene defines the hosting scene
  24904. * @param options defines optional options to transmit to constructors
  24905. * @returns the new constructor or null
  24906. */
  24907. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24908. /**
  24909. * Gets or sets the name of the node
  24910. */
  24911. name: string;
  24912. /**
  24913. * Gets or sets the id of the node
  24914. */
  24915. id: string;
  24916. /**
  24917. * Gets or sets the unique id of the node
  24918. */
  24919. uniqueId: number;
  24920. /**
  24921. * Gets or sets a string used to store user defined state for the node
  24922. */
  24923. state: string;
  24924. /**
  24925. * Gets or sets an object used to store user defined information for the node
  24926. */
  24927. metadata: any;
  24928. /**
  24929. * For internal use only. Please do not use.
  24930. */
  24931. reservedDataStore: any;
  24932. /**
  24933. * Gets or sets a boolean used to define if the node must be serialized
  24934. */
  24935. doNotSerialize: boolean;
  24936. /** @hidden */
  24937. _isDisposed: boolean;
  24938. /**
  24939. * Gets a list of Animations associated with the node
  24940. */
  24941. animations: import("babylonjs/Animations/animation").Animation[];
  24942. protected _ranges: {
  24943. [name: string]: Nullable<AnimationRange>;
  24944. };
  24945. /**
  24946. * Callback raised when the node is ready to be used
  24947. */
  24948. onReady: (node: Node) => void;
  24949. private _isEnabled;
  24950. private _isParentEnabled;
  24951. private _isReady;
  24952. /** @hidden */
  24953. _currentRenderId: number;
  24954. private _parentRenderId;
  24955. protected _childRenderId: number;
  24956. /** @hidden */
  24957. _waitingParentId: Nullable<string>;
  24958. /** @hidden */
  24959. _scene: Scene;
  24960. /** @hidden */
  24961. _cache: any;
  24962. private _parentNode;
  24963. private _children;
  24964. /** @hidden */
  24965. _worldMatrix: Matrix;
  24966. /** @hidden */
  24967. _worldMatrixDeterminant: number;
  24968. /** @hidden */
  24969. private _sceneRootNodesIndex;
  24970. /**
  24971. * Gets a boolean indicating if the node has been disposed
  24972. * @returns true if the node was disposed
  24973. */
  24974. isDisposed(): boolean;
  24975. /**
  24976. * Gets or sets the parent of the node
  24977. */
  24978. parent: Nullable<Node>;
  24979. private addToSceneRootNodes;
  24980. private removeFromSceneRootNodes;
  24981. private _animationPropertiesOverride;
  24982. /**
  24983. * Gets or sets the animation properties override
  24984. */
  24985. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24986. /**
  24987. * Gets a string idenfifying the name of the class
  24988. * @returns "Node" string
  24989. */
  24990. getClassName(): string;
  24991. /** @hidden */
  24992. readonly _isNode: boolean;
  24993. /**
  24994. * An event triggered when the mesh is disposed
  24995. */
  24996. onDisposeObservable: Observable<Node>;
  24997. private _onDisposeObserver;
  24998. /**
  24999. * Sets a callback that will be raised when the node will be disposed
  25000. */
  25001. onDispose: () => void;
  25002. /**
  25003. * Creates a new Node
  25004. * @param name the name and id to be given to this node
  25005. * @param scene the scene this node will be added to
  25006. * @param addToRootNodes the node will be added to scene.rootNodes
  25007. */
  25008. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25009. /**
  25010. * Gets the scene of the node
  25011. * @returns a scene
  25012. */
  25013. getScene(): Scene;
  25014. /**
  25015. * Gets the engine of the node
  25016. * @returns a Engine
  25017. */
  25018. getEngine(): Engine;
  25019. private _behaviors;
  25020. /**
  25021. * Attach a behavior to the node
  25022. * @see http://doc.babylonjs.com/features/behaviour
  25023. * @param behavior defines the behavior to attach
  25024. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25025. * @returns the current Node
  25026. */
  25027. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25028. /**
  25029. * Remove an attached behavior
  25030. * @see http://doc.babylonjs.com/features/behaviour
  25031. * @param behavior defines the behavior to attach
  25032. * @returns the current Node
  25033. */
  25034. removeBehavior(behavior: Behavior<Node>): Node;
  25035. /**
  25036. * Gets the list of attached behaviors
  25037. * @see http://doc.babylonjs.com/features/behaviour
  25038. */
  25039. readonly behaviors: Behavior<Node>[];
  25040. /**
  25041. * Gets an attached behavior by name
  25042. * @param name defines the name of the behavior to look for
  25043. * @see http://doc.babylonjs.com/features/behaviour
  25044. * @returns null if behavior was not found else the requested behavior
  25045. */
  25046. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25047. /**
  25048. * Returns the latest update of the World matrix
  25049. * @returns a Matrix
  25050. */
  25051. getWorldMatrix(): Matrix;
  25052. /** @hidden */
  25053. _getWorldMatrixDeterminant(): number;
  25054. /**
  25055. * Returns directly the latest state of the mesh World matrix.
  25056. * A Matrix is returned.
  25057. */
  25058. readonly worldMatrixFromCache: Matrix;
  25059. /** @hidden */
  25060. _initCache(): void;
  25061. /** @hidden */
  25062. updateCache(force?: boolean): void;
  25063. /** @hidden */
  25064. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25065. /** @hidden */
  25066. _updateCache(ignoreParentClass?: boolean): void;
  25067. /** @hidden */
  25068. _isSynchronized(): boolean;
  25069. /** @hidden */
  25070. _markSyncedWithParent(): void;
  25071. /** @hidden */
  25072. isSynchronizedWithParent(): boolean;
  25073. /** @hidden */
  25074. isSynchronized(): boolean;
  25075. /**
  25076. * Is this node ready to be used/rendered
  25077. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25078. * @return true if the node is ready
  25079. */
  25080. isReady(completeCheck?: boolean): boolean;
  25081. /**
  25082. * Is this node enabled?
  25083. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  25084. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  25085. * @return whether this node (and its parent) is enabled
  25086. */
  25087. isEnabled(checkAncestors?: boolean): boolean;
  25088. /** @hidden */
  25089. protected _syncParentEnabledState(): void;
  25090. /**
  25091. * Set the enabled state of this node
  25092. * @param value defines the new enabled state
  25093. */
  25094. setEnabled(value: boolean): void;
  25095. /**
  25096. * Is this node a descendant of the given node?
  25097. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25098. * @param ancestor defines the parent node to inspect
  25099. * @returns a boolean indicating if this node is a descendant of the given node
  25100. */
  25101. isDescendantOf(ancestor: Node): boolean;
  25102. /** @hidden */
  25103. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25104. /**
  25105. * Will return all nodes that have this node as ascendant
  25106. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  25107. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  25108. * @return all children nodes of all types
  25109. */
  25110. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25111. /**
  25112. * Get all child-meshes of this node
  25113. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  25114. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  25115. * @returns an array of AbstractMesh
  25116. */
  25117. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25118. /**
  25119. * Get all direct children of this node
  25120. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  25121. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  25122. * @returns an array of Node
  25123. */
  25124. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25125. /** @hidden */
  25126. _setReady(state: boolean): void;
  25127. /**
  25128. * Get an animation by name
  25129. * @param name defines the name of the animation to look for
  25130. * @returns null if not found else the requested animation
  25131. */
  25132. getAnimationByName(name: string): Nullable<Animation>;
  25133. /**
  25134. * Creates an animation range for this node
  25135. * @param name defines the name of the range
  25136. * @param from defines the starting key
  25137. * @param to defines the end key
  25138. */
  25139. createAnimationRange(name: string, from: number, to: number): void;
  25140. /**
  25141. * Delete a specific animation range
  25142. * @param name defines the name of the range to delete
  25143. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25144. */
  25145. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25146. /**
  25147. * Get an animation range by name
  25148. * @param name defines the name of the animation range to look for
  25149. * @returns null if not found else the requested animation range
  25150. */
  25151. getAnimationRange(name: string): Nullable<AnimationRange>;
  25152. /**
  25153. * Gets the list of all animation ranges defined on this node
  25154. * @returns an array
  25155. */
  25156. getAnimationRanges(): Nullable<AnimationRange>[];
  25157. /**
  25158. * Will start the animation sequence
  25159. * @param name defines the range frames for animation sequence
  25160. * @param loop defines if the animation should loop (false by default)
  25161. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25162. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25163. * @returns the object created for this animation. If range does not exist, it will return null
  25164. */
  25165. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25166. /**
  25167. * Serialize animation ranges into a JSON compatible object
  25168. * @returns serialization object
  25169. */
  25170. serializeAnimationRanges(): any;
  25171. /**
  25172. * Computes the world matrix of the node
  25173. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25174. * @returns the world matrix
  25175. */
  25176. computeWorldMatrix(force?: boolean): Matrix;
  25177. /**
  25178. * Releases resources associated with this node.
  25179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25181. */
  25182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25183. /**
  25184. * Parse animation range data from a serialization object and store them into a given node
  25185. * @param node defines where to store the animation ranges
  25186. * @param parsedNode defines the serialization object to read data from
  25187. * @param scene defines the hosting scene
  25188. */
  25189. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25190. }
  25191. }
  25192. declare module "babylonjs/Animations/animation" {
  25193. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25194. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25195. import { Nullable } from "babylonjs/types";
  25196. import { Scene } from "babylonjs/scene";
  25197. import { IAnimatable } from "babylonjs/Misc/tools";
  25198. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25199. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25200. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25201. import { Node } from "babylonjs/node";
  25202. import { Animatable } from "babylonjs/Animations/animatable";
  25203. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25204. /**
  25205. * Class used to store any kind of animation
  25206. */
  25207. export class Animation {
  25208. /**Name of the animation */
  25209. name: string;
  25210. /**Property to animate */
  25211. targetProperty: string;
  25212. /**The frames per second of the animation */
  25213. framePerSecond: number;
  25214. /**The data type of the animation */
  25215. dataType: number;
  25216. /**The loop mode of the animation */
  25217. loopMode?: number | undefined;
  25218. /**Specifies if blending should be enabled */
  25219. enableBlending?: boolean | undefined;
  25220. /**
  25221. * Use matrix interpolation instead of using direct key value when animating matrices
  25222. */
  25223. static AllowMatricesInterpolation: boolean;
  25224. /**
  25225. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25226. */
  25227. static AllowMatrixDecomposeForInterpolation: boolean;
  25228. /**
  25229. * Stores the key frames of the animation
  25230. */
  25231. private _keys;
  25232. /**
  25233. * Stores the easing function of the animation
  25234. */
  25235. private _easingFunction;
  25236. /**
  25237. * @hidden Internal use only
  25238. */
  25239. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25240. /**
  25241. * The set of event that will be linked to this animation
  25242. */
  25243. private _events;
  25244. /**
  25245. * Stores an array of target property paths
  25246. */
  25247. targetPropertyPath: string[];
  25248. /**
  25249. * Stores the blending speed of the animation
  25250. */
  25251. blendingSpeed: number;
  25252. /**
  25253. * Stores the animation ranges for the animation
  25254. */
  25255. private _ranges;
  25256. /**
  25257. * @hidden Internal use
  25258. */
  25259. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25260. /**
  25261. * Sets up an animation
  25262. * @param property The property to animate
  25263. * @param animationType The animation type to apply
  25264. * @param framePerSecond The frames per second of the animation
  25265. * @param easingFunction The easing function used in the animation
  25266. * @returns The created animation
  25267. */
  25268. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25269. /**
  25270. * Create and start an animation on a node
  25271. * @param name defines the name of the global animation that will be run on all nodes
  25272. * @param node defines the root node where the animation will take place
  25273. * @param targetProperty defines property to animate
  25274. * @param framePerSecond defines the number of frame per second yo use
  25275. * @param totalFrame defines the number of frames in total
  25276. * @param from defines the initial value
  25277. * @param to defines the final value
  25278. * @param loopMode defines which loop mode you want to use (off by default)
  25279. * @param easingFunction defines the easing function to use (linear by default)
  25280. * @param onAnimationEnd defines the callback to call when animation end
  25281. * @returns the animatable created for this animation
  25282. */
  25283. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25284. /**
  25285. * Create and start an animation on a node and its descendants
  25286. * @param name defines the name of the global animation that will be run on all nodes
  25287. * @param node defines the root node where the animation will take place
  25288. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  25289. * @param targetProperty defines property to animate
  25290. * @param framePerSecond defines the number of frame per second to use
  25291. * @param totalFrame defines the number of frames in total
  25292. * @param from defines the initial value
  25293. * @param to defines the final value
  25294. * @param loopMode defines which loop mode you want to use (off by default)
  25295. * @param easingFunction defines the easing function to use (linear by default)
  25296. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25297. * @returns the list of animatables created for all nodes
  25298. * @example https://www.babylonjs-playground.com/#MH0VLI
  25299. */
  25300. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  25301. /**
  25302. * Creates a new animation, merges it with the existing animations and starts it
  25303. * @param name Name of the animation
  25304. * @param node Node which contains the scene that begins the animations
  25305. * @param targetProperty Specifies which property to animate
  25306. * @param framePerSecond The frames per second of the animation
  25307. * @param totalFrame The total number of frames
  25308. * @param from The frame at the beginning of the animation
  25309. * @param to The frame at the end of the animation
  25310. * @param loopMode Specifies the loop mode of the animation
  25311. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25312. * @param onAnimationEnd Callback to run once the animation is complete
  25313. * @returns Nullable animation
  25314. */
  25315. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25316. /**
  25317. * Transition property of an host to the target Value
  25318. * @param property The property to transition
  25319. * @param targetValue The target Value of the property
  25320. * @param host The object where the property to animate belongs
  25321. * @param scene Scene used to run the animation
  25322. * @param frameRate Framerate (in frame/s) to use
  25323. * @param transition The transition type we want to use
  25324. * @param duration The duration of the animation, in milliseconds
  25325. * @param onAnimationEnd Callback trigger at the end of the animation
  25326. * @returns Nullable animation
  25327. */
  25328. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25329. /**
  25330. * Return the array of runtime animations currently using this animation
  25331. */
  25332. readonly runtimeAnimations: RuntimeAnimation[];
  25333. /**
  25334. * Specifies if any of the runtime animations are currently running
  25335. */
  25336. readonly hasRunningRuntimeAnimations: boolean;
  25337. /**
  25338. * Initializes the animation
  25339. * @param name Name of the animation
  25340. * @param targetProperty Property to animate
  25341. * @param framePerSecond The frames per second of the animation
  25342. * @param dataType The data type of the animation
  25343. * @param loopMode The loop mode of the animation
  25344. * @param enableBlending Specifies if blending should be enabled
  25345. */
  25346. constructor(
  25347. /**Name of the animation */
  25348. name: string,
  25349. /**Property to animate */
  25350. targetProperty: string,
  25351. /**The frames per second of the animation */
  25352. framePerSecond: number,
  25353. /**The data type of the animation */
  25354. dataType: number,
  25355. /**The loop mode of the animation */
  25356. loopMode?: number | undefined,
  25357. /**Specifies if blending should be enabled */
  25358. enableBlending?: boolean | undefined);
  25359. /**
  25360. * Converts the animation to a string
  25361. * @param fullDetails support for multiple levels of logging within scene loading
  25362. * @returns String form of the animation
  25363. */
  25364. toString(fullDetails?: boolean): string;
  25365. /**
  25366. * Add an event to this animation
  25367. * @param event Event to add
  25368. */
  25369. addEvent(event: AnimationEvent): void;
  25370. /**
  25371. * Remove all events found at the given frame
  25372. * @param frame The frame to remove events from
  25373. */
  25374. removeEvents(frame: number): void;
  25375. /**
  25376. * Retrieves all the events from the animation
  25377. * @returns Events from the animation
  25378. */
  25379. getEvents(): AnimationEvent[];
  25380. /**
  25381. * Creates an animation range
  25382. * @param name Name of the animation range
  25383. * @param from Starting frame of the animation range
  25384. * @param to Ending frame of the animation
  25385. */
  25386. createRange(name: string, from: number, to: number): void;
  25387. /**
  25388. * Deletes an animation range by name
  25389. * @param name Name of the animation range to delete
  25390. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25391. */
  25392. deleteRange(name: string, deleteFrames?: boolean): void;
  25393. /**
  25394. * Gets the animation range by name, or null if not defined
  25395. * @param name Name of the animation range
  25396. * @returns Nullable animation range
  25397. */
  25398. getRange(name: string): Nullable<AnimationRange>;
  25399. /**
  25400. * Gets the key frames from the animation
  25401. * @returns The key frames of the animation
  25402. */
  25403. getKeys(): Array<IAnimationKey>;
  25404. /**
  25405. * Gets the highest frame rate of the animation
  25406. * @returns Highest frame rate of the animation
  25407. */
  25408. getHighestFrame(): number;
  25409. /**
  25410. * Gets the easing function of the animation
  25411. * @returns Easing function of the animation
  25412. */
  25413. getEasingFunction(): IEasingFunction;
  25414. /**
  25415. * Sets the easing function of the animation
  25416. * @param easingFunction A custom mathematical formula for animation
  25417. */
  25418. setEasingFunction(easingFunction: EasingFunction): void;
  25419. /**
  25420. * Interpolates a scalar linearly
  25421. * @param startValue Start value of the animation curve
  25422. * @param endValue End value of the animation curve
  25423. * @param gradient Scalar amount to interpolate
  25424. * @returns Interpolated scalar value
  25425. */
  25426. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25427. /**
  25428. * Interpolates a scalar cubically
  25429. * @param startValue Start value of the animation curve
  25430. * @param outTangent End tangent of the animation
  25431. * @param endValue End value of the animation curve
  25432. * @param inTangent Start tangent of the animation curve
  25433. * @param gradient Scalar amount to interpolate
  25434. * @returns Interpolated scalar value
  25435. */
  25436. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25437. /**
  25438. * Interpolates a quaternion using a spherical linear interpolation
  25439. * @param startValue Start value of the animation curve
  25440. * @param endValue End value of the animation curve
  25441. * @param gradient Scalar amount to interpolate
  25442. * @returns Interpolated quaternion value
  25443. */
  25444. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25445. /**
  25446. * Interpolates a quaternion cubically
  25447. * @param startValue Start value of the animation curve
  25448. * @param outTangent End tangent of the animation curve
  25449. * @param endValue End value of the animation curve
  25450. * @param inTangent Start tangent of the animation curve
  25451. * @param gradient Scalar amount to interpolate
  25452. * @returns Interpolated quaternion value
  25453. */
  25454. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25455. /**
  25456. * Interpolates a Vector3 linearl
  25457. * @param startValue Start value of the animation curve
  25458. * @param endValue End value of the animation curve
  25459. * @param gradient Scalar amount to interpolate
  25460. * @returns Interpolated scalar value
  25461. */
  25462. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25463. /**
  25464. * Interpolates a Vector3 cubically
  25465. * @param startValue Start value of the animation curve
  25466. * @param outTangent End tangent of the animation
  25467. * @param endValue End value of the animation curve
  25468. * @param inTangent Start tangent of the animation curve
  25469. * @param gradient Scalar amount to interpolate
  25470. * @returns InterpolatedVector3 value
  25471. */
  25472. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25473. /**
  25474. * Interpolates a Vector2 linearly
  25475. * @param startValue Start value of the animation curve
  25476. * @param endValue End value of the animation curve
  25477. * @param gradient Scalar amount to interpolate
  25478. * @returns Interpolated Vector2 value
  25479. */
  25480. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25481. /**
  25482. * Interpolates a Vector2 cubically
  25483. * @param startValue Start value of the animation curve
  25484. * @param outTangent End tangent of the animation
  25485. * @param endValue End value of the animation curve
  25486. * @param inTangent Start tangent of the animation curve
  25487. * @param gradient Scalar amount to interpolate
  25488. * @returns Interpolated Vector2 value
  25489. */
  25490. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25491. /**
  25492. * Interpolates a size linearly
  25493. * @param startValue Start value of the animation curve
  25494. * @param endValue End value of the animation curve
  25495. * @param gradient Scalar amount to interpolate
  25496. * @returns Interpolated Size value
  25497. */
  25498. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25499. /**
  25500. * Interpolates a Color3 linearly
  25501. * @param startValue Start value of the animation curve
  25502. * @param endValue End value of the animation curve
  25503. * @param gradient Scalar amount to interpolate
  25504. * @returns Interpolated Color3 value
  25505. */
  25506. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25507. /**
  25508. * @hidden Internal use only
  25509. */
  25510. _getKeyValue(value: any): any;
  25511. /**
  25512. * @hidden Internal use only
  25513. */
  25514. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25515. /**
  25516. * Defines the function to use to interpolate matrices
  25517. * @param startValue defines the start matrix
  25518. * @param endValue defines the end matrix
  25519. * @param gradient defines the gradient between both matrices
  25520. * @param result defines an optional target matrix where to store the interpolation
  25521. * @returns the interpolated matrix
  25522. */
  25523. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25524. /**
  25525. * Makes a copy of the animation
  25526. * @returns Cloned animation
  25527. */
  25528. clone(): Animation;
  25529. /**
  25530. * Sets the key frames of the animation
  25531. * @param values The animation key frames to set
  25532. */
  25533. setKeys(values: Array<IAnimationKey>): void;
  25534. /**
  25535. * Serializes the animation to an object
  25536. * @returns Serialized object
  25537. */
  25538. serialize(): any;
  25539. /**
  25540. * Float animation type
  25541. */
  25542. private static _ANIMATIONTYPE_FLOAT;
  25543. /**
  25544. * Vector3 animation type
  25545. */
  25546. private static _ANIMATIONTYPE_VECTOR3;
  25547. /**
  25548. * Quaternion animation type
  25549. */
  25550. private static _ANIMATIONTYPE_QUATERNION;
  25551. /**
  25552. * Matrix animation type
  25553. */
  25554. private static _ANIMATIONTYPE_MATRIX;
  25555. /**
  25556. * Color3 animation type
  25557. */
  25558. private static _ANIMATIONTYPE_COLOR3;
  25559. /**
  25560. * Vector2 animation type
  25561. */
  25562. private static _ANIMATIONTYPE_VECTOR2;
  25563. /**
  25564. * Size animation type
  25565. */
  25566. private static _ANIMATIONTYPE_SIZE;
  25567. /**
  25568. * Relative Loop Mode
  25569. */
  25570. private static _ANIMATIONLOOPMODE_RELATIVE;
  25571. /**
  25572. * Cycle Loop Mode
  25573. */
  25574. private static _ANIMATIONLOOPMODE_CYCLE;
  25575. /**
  25576. * Constant Loop Mode
  25577. */
  25578. private static _ANIMATIONLOOPMODE_CONSTANT;
  25579. /**
  25580. * Get the float animation type
  25581. */
  25582. static readonly ANIMATIONTYPE_FLOAT: number;
  25583. /**
  25584. * Get the Vector3 animation type
  25585. */
  25586. static readonly ANIMATIONTYPE_VECTOR3: number;
  25587. /**
  25588. * Get the Vector2 animation type
  25589. */
  25590. static readonly ANIMATIONTYPE_VECTOR2: number;
  25591. /**
  25592. * Get the Size animation type
  25593. */
  25594. static readonly ANIMATIONTYPE_SIZE: number;
  25595. /**
  25596. * Get the Quaternion animation type
  25597. */
  25598. static readonly ANIMATIONTYPE_QUATERNION: number;
  25599. /**
  25600. * Get the Matrix animation type
  25601. */
  25602. static readonly ANIMATIONTYPE_MATRIX: number;
  25603. /**
  25604. * Get the Color3 animation type
  25605. */
  25606. static readonly ANIMATIONTYPE_COLOR3: number;
  25607. /**
  25608. * Get the Relative Loop Mode
  25609. */
  25610. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25611. /**
  25612. * Get the Cycle Loop Mode
  25613. */
  25614. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25615. /**
  25616. * Get the Constant Loop Mode
  25617. */
  25618. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25619. /** @hidden */
  25620. static _UniversalLerp(left: any, right: any, amount: number): any;
  25621. /**
  25622. * Parses an animation object and creates an animation
  25623. * @param parsedAnimation Parsed animation object
  25624. * @returns Animation object
  25625. */
  25626. static Parse(parsedAnimation: any): Animation;
  25627. /**
  25628. * Appends the serialized animations from the source animations
  25629. * @param source Source containing the animations
  25630. * @param destination Target to store the animations
  25631. */
  25632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25633. }
  25634. }
  25635. declare module "babylonjs/Materials/Textures/baseTexture" {
  25636. import { Observable } from "babylonjs/Misc/observable";
  25637. import { IAnimatable } from "babylonjs/Misc/tools";
  25638. import { Nullable } from "babylonjs/types";
  25639. import { Scene } from "babylonjs/scene";
  25640. import { Matrix, ISize } from "babylonjs/Maths/math";
  25641. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25643. /**
  25644. * Base class of all the textures in babylon.
  25645. * It groups all the common properties the materials, post process, lights... might need
  25646. * in order to make a correct use of the texture.
  25647. */
  25648. export class BaseTexture implements IAnimatable {
  25649. /**
  25650. * Default anisotropic filtering level for the application.
  25651. * It is set to 4 as a good tradeoff between perf and quality.
  25652. */
  25653. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25654. /**
  25655. * Gets or sets the unique id of the texture
  25656. */
  25657. uniqueId: number;
  25658. /**
  25659. * Define the name of the texture.
  25660. */
  25661. name: string;
  25662. /**
  25663. * Gets or sets an object used to store user defined information.
  25664. */
  25665. metadata: any;
  25666. /**
  25667. * For internal use only. Please do not use.
  25668. */
  25669. reservedDataStore: any;
  25670. private _hasAlpha;
  25671. /**
  25672. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25673. */
  25674. hasAlpha: boolean;
  25675. /**
  25676. * Defines if the alpha value should be determined via the rgb values.
  25677. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25678. */
  25679. getAlphaFromRGB: boolean;
  25680. /**
  25681. * Intensity or strength of the texture.
  25682. * It is commonly used by materials to fine tune the intensity of the texture
  25683. */
  25684. level: number;
  25685. /**
  25686. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25687. * This is part of the texture as textures usually maps to one uv set.
  25688. */
  25689. coordinatesIndex: number;
  25690. private _coordinatesMode;
  25691. /**
  25692. * How a texture is mapped.
  25693. *
  25694. * | Value | Type | Description |
  25695. * | ----- | ----------------------------------- | ----------- |
  25696. * | 0 | EXPLICIT_MODE | |
  25697. * | 1 | SPHERICAL_MODE | |
  25698. * | 2 | PLANAR_MODE | |
  25699. * | 3 | CUBIC_MODE | |
  25700. * | 4 | PROJECTION_MODE | |
  25701. * | 5 | SKYBOX_MODE | |
  25702. * | 6 | INVCUBIC_MODE | |
  25703. * | 7 | EQUIRECTANGULAR_MODE | |
  25704. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25705. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25706. */
  25707. coordinatesMode: number;
  25708. /**
  25709. * | Value | Type | Description |
  25710. * | ----- | ------------------ | ----------- |
  25711. * | 0 | CLAMP_ADDRESSMODE | |
  25712. * | 1 | WRAP_ADDRESSMODE | |
  25713. * | 2 | MIRROR_ADDRESSMODE | |
  25714. */
  25715. wrapU: number;
  25716. /**
  25717. * | Value | Type | Description |
  25718. * | ----- | ------------------ | ----------- |
  25719. * | 0 | CLAMP_ADDRESSMODE | |
  25720. * | 1 | WRAP_ADDRESSMODE | |
  25721. * | 2 | MIRROR_ADDRESSMODE | |
  25722. */
  25723. wrapV: number;
  25724. /**
  25725. * | Value | Type | Description |
  25726. * | ----- | ------------------ | ----------- |
  25727. * | 0 | CLAMP_ADDRESSMODE | |
  25728. * | 1 | WRAP_ADDRESSMODE | |
  25729. * | 2 | MIRROR_ADDRESSMODE | |
  25730. */
  25731. wrapR: number;
  25732. /**
  25733. * With compliant hardware and browser (supporting anisotropic filtering)
  25734. * this defines the level of anisotropic filtering in the texture.
  25735. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25736. */
  25737. anisotropicFilteringLevel: number;
  25738. /**
  25739. * Define if the texture is a cube texture or if false a 2d texture.
  25740. */
  25741. isCube: boolean;
  25742. /**
  25743. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25744. */
  25745. is3D: boolean;
  25746. /**
  25747. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25748. * HDR texture are usually stored in linear space.
  25749. * This only impacts the PBR and Background materials
  25750. */
  25751. gammaSpace: boolean;
  25752. /**
  25753. * Gets whether or not the texture contains RGBD data.
  25754. */
  25755. readonly isRGBD: boolean;
  25756. /**
  25757. * Is Z inverted in the texture (useful in a cube texture).
  25758. */
  25759. invertZ: boolean;
  25760. /**
  25761. * Are mip maps generated for this texture or not.
  25762. */
  25763. readonly noMipmap: boolean;
  25764. /**
  25765. * @hidden
  25766. */
  25767. lodLevelInAlpha: boolean;
  25768. /**
  25769. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25770. */
  25771. lodGenerationOffset: number;
  25772. /**
  25773. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25774. */
  25775. lodGenerationScale: number;
  25776. /**
  25777. * Define if the texture is a render target.
  25778. */
  25779. isRenderTarget: boolean;
  25780. /**
  25781. * Define the unique id of the texture in the scene.
  25782. */
  25783. readonly uid: string;
  25784. /**
  25785. * Return a string representation of the texture.
  25786. * @returns the texture as a string
  25787. */
  25788. toString(): string;
  25789. /**
  25790. * Get the class name of the texture.
  25791. * @returns "BaseTexture"
  25792. */
  25793. getClassName(): string;
  25794. /**
  25795. * Define the list of animation attached to the texture.
  25796. */
  25797. animations: import("babylonjs/Animations/animation").Animation[];
  25798. /**
  25799. * An event triggered when the texture is disposed.
  25800. */
  25801. onDisposeObservable: Observable<BaseTexture>;
  25802. private _onDisposeObserver;
  25803. /**
  25804. * Callback triggered when the texture has been disposed.
  25805. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25806. */
  25807. onDispose: () => void;
  25808. /**
  25809. * Define the current state of the loading sequence when in delayed load mode.
  25810. */
  25811. delayLoadState: number;
  25812. private _scene;
  25813. /** @hidden */
  25814. _texture: Nullable<InternalTexture>;
  25815. private _uid;
  25816. /**
  25817. * Define if the texture is preventinga material to render or not.
  25818. * If not and the texture is not ready, the engine will use a default black texture instead.
  25819. */
  25820. readonly isBlocking: boolean;
  25821. /**
  25822. * Instantiates a new BaseTexture.
  25823. * Base class of all the textures in babylon.
  25824. * It groups all the common properties the materials, post process, lights... might need
  25825. * in order to make a correct use of the texture.
  25826. * @param scene Define the scene the texture blongs to
  25827. */
  25828. constructor(scene: Nullable<Scene>);
  25829. /**
  25830. * Get the scene the texture belongs to.
  25831. * @returns the scene or null if undefined
  25832. */
  25833. getScene(): Nullable<Scene>;
  25834. /**
  25835. * Get the texture transform matrix used to offset tile the texture for istance.
  25836. * @returns the transformation matrix
  25837. */
  25838. getTextureMatrix(): Matrix;
  25839. /**
  25840. * Get the texture reflection matrix used to rotate/transform the reflection.
  25841. * @returns the reflection matrix
  25842. */
  25843. getReflectionTextureMatrix(): Matrix;
  25844. /**
  25845. * Get the underlying lower level texture from Babylon.
  25846. * @returns the insternal texture
  25847. */
  25848. getInternalTexture(): Nullable<InternalTexture>;
  25849. /**
  25850. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25851. * @returns true if ready or not blocking
  25852. */
  25853. isReadyOrNotBlocking(): boolean;
  25854. /**
  25855. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25856. * @returns true if fully ready
  25857. */
  25858. isReady(): boolean;
  25859. private _cachedSize;
  25860. /**
  25861. * Get the size of the texture.
  25862. * @returns the texture size.
  25863. */
  25864. getSize(): ISize;
  25865. /**
  25866. * Get the base size of the texture.
  25867. * It can be different from the size if the texture has been resized for POT for instance
  25868. * @returns the base size
  25869. */
  25870. getBaseSize(): ISize;
  25871. /**
  25872. * Update the sampling mode of the texture.
  25873. * Default is Trilinear mode.
  25874. *
  25875. * | Value | Type | Description |
  25876. * | ----- | ------------------ | ----------- |
  25877. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25878. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25879. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25880. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25881. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25882. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25883. * | 7 | NEAREST_LINEAR | |
  25884. * | 8 | NEAREST_NEAREST | |
  25885. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25886. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25887. * | 11 | LINEAR_LINEAR | |
  25888. * | 12 | LINEAR_NEAREST | |
  25889. *
  25890. * > _mag_: magnification filter (close to the viewer)
  25891. * > _min_: minification filter (far from the viewer)
  25892. * > _mip_: filter used between mip map levels
  25893. *@param samplingMode Define the new sampling mode of the texture
  25894. */
  25895. updateSamplingMode(samplingMode: number): void;
  25896. /**
  25897. * Scales the texture if is `canRescale()`
  25898. * @param ratio the resize factor we want to use to rescale
  25899. */
  25900. scale(ratio: number): void;
  25901. /**
  25902. * Get if the texture can rescale.
  25903. */
  25904. readonly canRescale: boolean;
  25905. /** @hidden */
  25906. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25907. /** @hidden */
  25908. _rebuild(): void;
  25909. /**
  25910. * Triggers the load sequence in delayed load mode.
  25911. */
  25912. delayLoad(): void;
  25913. /**
  25914. * Clones the texture.
  25915. * @returns the cloned texture
  25916. */
  25917. clone(): Nullable<BaseTexture>;
  25918. /**
  25919. * Get the texture underlying type (INT, FLOAT...)
  25920. */
  25921. readonly textureType: number;
  25922. /**
  25923. * Get the texture underlying format (RGB, RGBA...)
  25924. */
  25925. readonly textureFormat: number;
  25926. /**
  25927. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25928. * This will returns an RGBA array buffer containing either in values (0-255) or
  25929. * float values (0-1) depending of the underlying buffer type.
  25930. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25931. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25932. * @param buffer defines a user defined buffer to fill with data (can be null)
  25933. * @returns The Array buffer containing the pixels data.
  25934. */
  25935. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25936. /**
  25937. * Release and destroy the underlying lower level texture aka internalTexture.
  25938. */
  25939. releaseInternalTexture(): void;
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. /** @hidden */
  25947. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25948. /** @hidden */
  25949. readonly _lodTextureMid: Nullable<BaseTexture>;
  25950. /** @hidden */
  25951. readonly _lodTextureLow: Nullable<BaseTexture>;
  25952. /**
  25953. * Dispose the texture and release its associated resources.
  25954. */
  25955. dispose(): void;
  25956. /**
  25957. * Serialize the texture into a JSON representation that can be parsed later on.
  25958. * @returns the JSON representation of the texture
  25959. */
  25960. serialize(): any;
  25961. /**
  25962. * Helper function to be called back once a list of texture contains only ready textures.
  25963. * @param textures Define the list of textures to wait for
  25964. * @param callback Define the callback triggered once the entire list will be ready
  25965. */
  25966. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25967. }
  25968. }
  25969. declare module "babylonjs/Materials/uniformBuffer" {
  25970. import { Nullable, FloatArray } from "babylonjs/types";
  25971. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25972. import { Engine } from "babylonjs/Engines/engine";
  25973. import { Effect } from "babylonjs/Materials/effect";
  25974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25975. /**
  25976. * Uniform buffer objects.
  25977. *
  25978. * Handles blocks of uniform on the GPU.
  25979. *
  25980. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25981. *
  25982. * For more information, please refer to :
  25983. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25984. */
  25985. export class UniformBuffer {
  25986. private _engine;
  25987. private _buffer;
  25988. private _data;
  25989. private _bufferData;
  25990. private _dynamic?;
  25991. private _uniformLocations;
  25992. private _uniformSizes;
  25993. private _uniformLocationPointer;
  25994. private _needSync;
  25995. private _noUBO;
  25996. private _currentEffect;
  25997. private static _MAX_UNIFORM_SIZE;
  25998. private static _tempBuffer;
  25999. /**
  26000. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26001. * This is dynamic to allow compat with webgl 1 and 2.
  26002. * You will need to pass the name of the uniform as well as the value.
  26003. */
  26004. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26005. /**
  26006. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26007. * This is dynamic to allow compat with webgl 1 and 2.
  26008. * You will need to pass the name of the uniform as well as the value.
  26009. */
  26010. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26011. /**
  26012. * Lambda to Update a single float in a uniform buffer.
  26013. * This is dynamic to allow compat with webgl 1 and 2.
  26014. * You will need to pass the name of the uniform as well as the value.
  26015. */
  26016. updateFloat: (name: string, x: number) => void;
  26017. /**
  26018. * Lambda to Update a vec2 of float in a uniform buffer.
  26019. * This is dynamic to allow compat with webgl 1 and 2.
  26020. * You will need to pass the name of the uniform as well as the value.
  26021. */
  26022. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26023. /**
  26024. * Lambda to Update a vec3 of float in a uniform buffer.
  26025. * This is dynamic to allow compat with webgl 1 and 2.
  26026. * You will need to pass the name of the uniform as well as the value.
  26027. */
  26028. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26029. /**
  26030. * Lambda to Update a vec4 of float in a uniform buffer.
  26031. * This is dynamic to allow compat with webgl 1 and 2.
  26032. * You will need to pass the name of the uniform as well as the value.
  26033. */
  26034. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26035. /**
  26036. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26037. * This is dynamic to allow compat with webgl 1 and 2.
  26038. * You will need to pass the name of the uniform as well as the value.
  26039. */
  26040. updateMatrix: (name: string, mat: Matrix) => void;
  26041. /**
  26042. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26043. * This is dynamic to allow compat with webgl 1 and 2.
  26044. * You will need to pass the name of the uniform as well as the value.
  26045. */
  26046. updateVector3: (name: string, vector: Vector3) => void;
  26047. /**
  26048. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26049. * This is dynamic to allow compat with webgl 1 and 2.
  26050. * You will need to pass the name of the uniform as well as the value.
  26051. */
  26052. updateVector4: (name: string, vector: Vector4) => void;
  26053. /**
  26054. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26055. * This is dynamic to allow compat with webgl 1 and 2.
  26056. * You will need to pass the name of the uniform as well as the value.
  26057. */
  26058. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26059. /**
  26060. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26061. * This is dynamic to allow compat with webgl 1 and 2.
  26062. * You will need to pass the name of the uniform as well as the value.
  26063. */
  26064. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26065. /**
  26066. * Instantiates a new Uniform buffer objects.
  26067. *
  26068. * Handles blocks of uniform on the GPU.
  26069. *
  26070. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26071. *
  26072. * For more information, please refer to :
  26073. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26074. * @param engine Define the engine the buffer is associated with
  26075. * @param data Define the data contained in the buffer
  26076. * @param dynamic Define if the buffer is updatable
  26077. */
  26078. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26079. /**
  26080. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26081. * or just falling back on setUniformXXX calls.
  26082. */
  26083. readonly useUbo: boolean;
  26084. /**
  26085. * Indicates if the WebGL underlying uniform buffer is in sync
  26086. * with the javascript cache data.
  26087. */
  26088. readonly isSync: boolean;
  26089. /**
  26090. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26091. * Also, a dynamic UniformBuffer will disable cache verification and always
  26092. * update the underlying WebGL uniform buffer to the GPU.
  26093. * @returns if Dynamic, otherwise false
  26094. */
  26095. isDynamic(): boolean;
  26096. /**
  26097. * The data cache on JS side.
  26098. * @returns the underlying data as a float array
  26099. */
  26100. getData(): Float32Array;
  26101. /**
  26102. * The underlying WebGL Uniform buffer.
  26103. * @returns the webgl buffer
  26104. */
  26105. getBuffer(): Nullable<WebGLBuffer>;
  26106. /**
  26107. * std140 layout specifies how to align data within an UBO structure.
  26108. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26109. * for specs.
  26110. */
  26111. private _fillAlignment;
  26112. /**
  26113. * Adds an uniform in the buffer.
  26114. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26115. * for the layout to be correct !
  26116. * @param name Name of the uniform, as used in the uniform block in the shader.
  26117. * @param size Data size, or data directly.
  26118. */
  26119. addUniform(name: string, size: number | number[]): void;
  26120. /**
  26121. * Adds a Matrix 4x4 to the uniform buffer.
  26122. * @param name Name of the uniform, as used in the uniform block in the shader.
  26123. * @param mat A 4x4 matrix.
  26124. */
  26125. addMatrix(name: string, mat: Matrix): void;
  26126. /**
  26127. * Adds a vec2 to the uniform buffer.
  26128. * @param name Name of the uniform, as used in the uniform block in the shader.
  26129. * @param x Define the x component value of the vec2
  26130. * @param y Define the y component value of the vec2
  26131. */
  26132. addFloat2(name: string, x: number, y: number): void;
  26133. /**
  26134. * Adds a vec3 to the uniform buffer.
  26135. * @param name Name of the uniform, as used in the uniform block in the shader.
  26136. * @param x Define the x component value of the vec3
  26137. * @param y Define the y component value of the vec3
  26138. * @param z Define the z component value of the vec3
  26139. */
  26140. addFloat3(name: string, x: number, y: number, z: number): void;
  26141. /**
  26142. * Adds a vec3 to the uniform buffer.
  26143. * @param name Name of the uniform, as used in the uniform block in the shader.
  26144. * @param color Define the vec3 from a Color
  26145. */
  26146. addColor3(name: string, color: Color3): void;
  26147. /**
  26148. * Adds a vec4 to the uniform buffer.
  26149. * @param name Name of the uniform, as used in the uniform block in the shader.
  26150. * @param color Define the rgb components from a Color
  26151. * @param alpha Define the a component of the vec4
  26152. */
  26153. addColor4(name: string, color: Color3, alpha: number): void;
  26154. /**
  26155. * Adds a vec3 to the uniform buffer.
  26156. * @param name Name of the uniform, as used in the uniform block in the shader.
  26157. * @param vector Define the vec3 components from a Vector
  26158. */
  26159. addVector3(name: string, vector: Vector3): void;
  26160. /**
  26161. * Adds a Matrix 3x3 to the uniform buffer.
  26162. * @param name Name of the uniform, as used in the uniform block in the shader.
  26163. */
  26164. addMatrix3x3(name: string): void;
  26165. /**
  26166. * Adds a Matrix 2x2 to the uniform buffer.
  26167. * @param name Name of the uniform, as used in the uniform block in the shader.
  26168. */
  26169. addMatrix2x2(name: string): void;
  26170. /**
  26171. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26172. */
  26173. create(): void;
  26174. /** @hidden */
  26175. _rebuild(): void;
  26176. /**
  26177. * Updates the WebGL Uniform Buffer on the GPU.
  26178. * If the `dynamic` flag is set to true, no cache comparison is done.
  26179. * Otherwise, the buffer will be updated only if the cache differs.
  26180. */
  26181. update(): void;
  26182. /**
  26183. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26184. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26185. * @param data Define the flattened data
  26186. * @param size Define the size of the data.
  26187. */
  26188. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26189. private _updateMatrix3x3ForUniform;
  26190. private _updateMatrix3x3ForEffect;
  26191. private _updateMatrix2x2ForEffect;
  26192. private _updateMatrix2x2ForUniform;
  26193. private _updateFloatForEffect;
  26194. private _updateFloatForUniform;
  26195. private _updateFloat2ForEffect;
  26196. private _updateFloat2ForUniform;
  26197. private _updateFloat3ForEffect;
  26198. private _updateFloat3ForUniform;
  26199. private _updateFloat4ForEffect;
  26200. private _updateFloat4ForUniform;
  26201. private _updateMatrixForEffect;
  26202. private _updateMatrixForUniform;
  26203. private _updateVector3ForEffect;
  26204. private _updateVector3ForUniform;
  26205. private _updateVector4ForEffect;
  26206. private _updateVector4ForUniform;
  26207. private _updateColor3ForEffect;
  26208. private _updateColor3ForUniform;
  26209. private _updateColor4ForEffect;
  26210. private _updateColor4ForUniform;
  26211. /**
  26212. * Sets a sampler uniform on the effect.
  26213. * @param name Define the name of the sampler.
  26214. * @param texture Define the texture to set in the sampler
  26215. */
  26216. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26217. /**
  26218. * Directly updates the value of the uniform in the cache AND on the GPU.
  26219. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26220. * @param data Define the flattened data
  26221. */
  26222. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26223. /**
  26224. * Binds this uniform buffer to an effect.
  26225. * @param effect Define the effect to bind the buffer to
  26226. * @param name Name of the uniform block in the shader.
  26227. */
  26228. bindToEffect(effect: Effect, name: string): void;
  26229. /**
  26230. * Disposes the uniform buffer.
  26231. */
  26232. dispose(): void;
  26233. }
  26234. }
  26235. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26236. import { Nullable } from "babylonjs/types";
  26237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26238. /**
  26239. * This represents the required contract to create a new type of texture loader.
  26240. */
  26241. export interface IInternalTextureLoader {
  26242. /**
  26243. * Defines wether the loader supports cascade loading the different faces.
  26244. */
  26245. supportCascades: boolean;
  26246. /**
  26247. * This returns if the loader support the current file information.
  26248. * @param extension defines the file extension of the file being loaded
  26249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26250. * @param fallback defines the fallback internal texture if any
  26251. * @param isBase64 defines whether the texture is encoded as a base64
  26252. * @param isBuffer defines whether the texture data are stored as a buffer
  26253. * @returns true if the loader can load the specified file
  26254. */
  26255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26256. /**
  26257. * Transform the url before loading if required.
  26258. * @param rootUrl the url of the texture
  26259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26260. * @returns the transformed texture
  26261. */
  26262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26263. /**
  26264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26265. * @param rootUrl the url of the texture
  26266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26267. * @returns the fallback texture
  26268. */
  26269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26270. /**
  26271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26272. * @param data contains the texture data
  26273. * @param texture defines the BabylonJS internal texture
  26274. * @param createPolynomials will be true if polynomials have been requested
  26275. * @param onLoad defines the callback to trigger once the texture is ready
  26276. * @param onError defines the callback to trigger in case of error
  26277. */
  26278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26279. /**
  26280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26281. * @param data contains the texture data
  26282. * @param texture defines the BabylonJS internal texture
  26283. * @param callback defines the method to call once ready to upload
  26284. */
  26285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26286. }
  26287. }
  26288. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26289. import { Scene } from "babylonjs/scene";
  26290. import { Engine } from "babylonjs/Engines/engine";
  26291. import { Texture } from "babylonjs/Materials/Textures/texture";
  26292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26293. /**
  26294. * Creation options of the multi render target texture.
  26295. */
  26296. export interface IMultiRenderTargetOptions {
  26297. /**
  26298. * Define if the texture needs to create mip maps after render.
  26299. */
  26300. generateMipMaps?: boolean;
  26301. /**
  26302. * Define the types of all the draw buffers we want to create
  26303. */
  26304. types?: number[];
  26305. /**
  26306. * Define the sampling modes of all the draw buffers we want to create
  26307. */
  26308. samplingModes?: number[];
  26309. /**
  26310. * Define if a depth buffer is required
  26311. */
  26312. generateDepthBuffer?: boolean;
  26313. /**
  26314. * Define if a stencil buffer is required
  26315. */
  26316. generateStencilBuffer?: boolean;
  26317. /**
  26318. * Define if a depth texture is required instead of a depth buffer
  26319. */
  26320. generateDepthTexture?: boolean;
  26321. /**
  26322. * Define the number of desired draw buffers
  26323. */
  26324. textureCount?: number;
  26325. /**
  26326. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26327. */
  26328. doNotChangeAspectRatio?: boolean;
  26329. /**
  26330. * Define the default type of the buffers we are creating
  26331. */
  26332. defaultType?: number;
  26333. }
  26334. /**
  26335. * A multi render target, like a render target provides the ability to render to a texture.
  26336. * Unlike the render target, it can render to several draw buffers in one draw.
  26337. * This is specially interesting in deferred rendering or for any effects requiring more than
  26338. * just one color from a single pass.
  26339. */
  26340. export class MultiRenderTarget extends RenderTargetTexture {
  26341. private _internalTextures;
  26342. private _textures;
  26343. private _multiRenderTargetOptions;
  26344. /**
  26345. * Get if draw buffers are currently supported by the used hardware and browser.
  26346. */
  26347. readonly isSupported: boolean;
  26348. /**
  26349. * Get the list of textures generated by the multi render target.
  26350. */
  26351. readonly textures: Texture[];
  26352. /**
  26353. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26354. */
  26355. readonly depthTexture: Texture;
  26356. /**
  26357. * Set the wrapping mode on U of all the textures we are rendering to.
  26358. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26359. */
  26360. wrapU: number;
  26361. /**
  26362. * Set the wrapping mode on V of all the textures we are rendering to.
  26363. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26364. */
  26365. wrapV: number;
  26366. /**
  26367. * Instantiate a new multi render target texture.
  26368. * A multi render target, like a render target provides the ability to render to a texture.
  26369. * Unlike the render target, it can render to several draw buffers in one draw.
  26370. * This is specially interesting in deferred rendering or for any effects requiring more than
  26371. * just one color from a single pass.
  26372. * @param name Define the name of the texture
  26373. * @param size Define the size of the buffers to render to
  26374. * @param count Define the number of target we are rendering into
  26375. * @param scene Define the scene the texture belongs to
  26376. * @param options Define the options used to create the multi render target
  26377. */
  26378. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26379. /** @hidden */
  26380. _rebuild(): void;
  26381. private _createInternalTextures;
  26382. private _createTextures;
  26383. /**
  26384. * Define the number of samples used if MSAA is enabled.
  26385. */
  26386. samples: number;
  26387. /**
  26388. * Resize all the textures in the multi render target.
  26389. * Be carrefull as it will recreate all the data in the new texture.
  26390. * @param size Define the new size
  26391. */
  26392. resize(size: any): void;
  26393. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26394. /**
  26395. * Dispose the render targets and their associated resources
  26396. */
  26397. dispose(): void;
  26398. /**
  26399. * Release all the underlying texture used as draw buffers.
  26400. */
  26401. releaseInternalTextures(): void;
  26402. }
  26403. }
  26404. declare module "babylonjs/Audio/analyser" {
  26405. import { Scene } from "babylonjs/scene";
  26406. /**
  26407. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26409. */
  26410. export class Analyser {
  26411. /**
  26412. * Gets or sets the smoothing
  26413. * @ignorenaming
  26414. */
  26415. SMOOTHING: number;
  26416. /**
  26417. * Gets or sets the FFT table size
  26418. * @ignorenaming
  26419. */
  26420. FFT_SIZE: number;
  26421. /**
  26422. * Gets or sets the bar graph amplitude
  26423. * @ignorenaming
  26424. */
  26425. BARGRAPHAMPLITUDE: number;
  26426. /**
  26427. * Gets or sets the position of the debug canvas
  26428. * @ignorenaming
  26429. */
  26430. DEBUGCANVASPOS: {
  26431. x: number;
  26432. y: number;
  26433. };
  26434. /**
  26435. * Gets or sets the debug canvas size
  26436. * @ignorenaming
  26437. */
  26438. DEBUGCANVASSIZE: {
  26439. width: number;
  26440. height: number;
  26441. };
  26442. private _byteFreqs;
  26443. private _byteTime;
  26444. private _floatFreqs;
  26445. private _webAudioAnalyser;
  26446. private _debugCanvas;
  26447. private _debugCanvasContext;
  26448. private _scene;
  26449. private _registerFunc;
  26450. private _audioEngine;
  26451. /**
  26452. * Creates a new analyser
  26453. * @param scene defines hosting scene
  26454. */
  26455. constructor(scene: Scene);
  26456. /**
  26457. * Get the number of data values you will have to play with for the visualization
  26458. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26459. * @returns a number
  26460. */
  26461. getFrequencyBinCount(): number;
  26462. /**
  26463. * Gets the current frequency data as a byte array
  26464. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26465. * @returns a Uint8Array
  26466. */
  26467. getByteFrequencyData(): Uint8Array;
  26468. /**
  26469. * Gets the current waveform as a byte array
  26470. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26471. * @returns a Uint8Array
  26472. */
  26473. getByteTimeDomainData(): Uint8Array;
  26474. /**
  26475. * Gets the current frequency data as a float array
  26476. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26477. * @returns a Float32Array
  26478. */
  26479. getFloatFrequencyData(): Float32Array;
  26480. /**
  26481. * Renders the debug canvas
  26482. */
  26483. drawDebugCanvas(): void;
  26484. /**
  26485. * Stops rendering the debug canvas and removes it
  26486. */
  26487. stopDebugCanvas(): void;
  26488. /**
  26489. * Connects two audio nodes
  26490. * @param inputAudioNode defines first node to connect
  26491. * @param outputAudioNode defines second node to connect
  26492. */
  26493. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26494. /**
  26495. * Releases all associated resources
  26496. */
  26497. dispose(): void;
  26498. }
  26499. }
  26500. declare module "babylonjs/Audio/audioEngine" {
  26501. import { IDisposable } from "babylonjs/scene";
  26502. import { Analyser } from "babylonjs/Audio/analyser";
  26503. import { Nullable } from "babylonjs/types";
  26504. import { Observable } from "babylonjs/Misc/observable";
  26505. /**
  26506. * This represents an audio engine and it is responsible
  26507. * to play, synchronize and analyse sounds throughout the application.
  26508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26509. */
  26510. export interface IAudioEngine extends IDisposable {
  26511. /**
  26512. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26513. */
  26514. readonly canUseWebAudio: boolean;
  26515. /**
  26516. * Gets the current AudioContext if available.
  26517. */
  26518. readonly audioContext: Nullable<AudioContext>;
  26519. /**
  26520. * The master gain node defines the global audio volume of your audio engine.
  26521. */
  26522. readonly masterGain: GainNode;
  26523. /**
  26524. * Gets whether or not mp3 are supported by your browser.
  26525. */
  26526. readonly isMP3supported: boolean;
  26527. /**
  26528. * Gets whether or not ogg are supported by your browser.
  26529. */
  26530. readonly isOGGsupported: boolean;
  26531. /**
  26532. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26533. * @ignoreNaming
  26534. */
  26535. WarnedWebAudioUnsupported: boolean;
  26536. /**
  26537. * Defines if the audio engine relies on a custom unlocked button.
  26538. * In this case, the embedded button will not be displayed.
  26539. */
  26540. useCustomUnlockedButton: boolean;
  26541. /**
  26542. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26543. */
  26544. readonly unlocked: boolean;
  26545. /**
  26546. * Event raised when audio has been unlocked on the browser.
  26547. */
  26548. onAudioUnlockedObservable: Observable<AudioEngine>;
  26549. /**
  26550. * Event raised when audio has been locked on the browser.
  26551. */
  26552. onAudioLockedObservable: Observable<AudioEngine>;
  26553. /**
  26554. * Flags the audio engine in Locked state.
  26555. * This happens due to new browser policies preventing audio to autoplay.
  26556. */
  26557. lock(): void;
  26558. /**
  26559. * Unlocks the audio engine once a user action has been done on the dom.
  26560. * This is helpful to resume play once browser policies have been satisfied.
  26561. */
  26562. unlock(): void;
  26563. }
  26564. /**
  26565. * This represents the default audio engine used in babylon.
  26566. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26568. */
  26569. export class AudioEngine implements IAudioEngine {
  26570. private _audioContext;
  26571. private _audioContextInitialized;
  26572. private _muteButton;
  26573. private _hostElement;
  26574. /**
  26575. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26576. */
  26577. canUseWebAudio: boolean;
  26578. /**
  26579. * The master gain node defines the global audio volume of your audio engine.
  26580. */
  26581. masterGain: GainNode;
  26582. /**
  26583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26584. * @ignoreNaming
  26585. */
  26586. WarnedWebAudioUnsupported: boolean;
  26587. /**
  26588. * Gets whether or not mp3 are supported by your browser.
  26589. */
  26590. isMP3supported: boolean;
  26591. /**
  26592. * Gets whether or not ogg are supported by your browser.
  26593. */
  26594. isOGGsupported: boolean;
  26595. /**
  26596. * Gets whether audio has been unlocked on the device.
  26597. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26598. * a user interaction has happened.
  26599. */
  26600. unlocked: boolean;
  26601. /**
  26602. * Defines if the audio engine relies on a custom unlocked button.
  26603. * In this case, the embedded button will not be displayed.
  26604. */
  26605. useCustomUnlockedButton: boolean;
  26606. /**
  26607. * Event raised when audio has been unlocked on the browser.
  26608. */
  26609. onAudioUnlockedObservable: Observable<AudioEngine>;
  26610. /**
  26611. * Event raised when audio has been locked on the browser.
  26612. */
  26613. onAudioLockedObservable: Observable<AudioEngine>;
  26614. /**
  26615. * Gets the current AudioContext if available.
  26616. */
  26617. readonly audioContext: Nullable<AudioContext>;
  26618. private _connectedAnalyser;
  26619. /**
  26620. * Instantiates a new audio engine.
  26621. *
  26622. * There should be only one per page as some browsers restrict the number
  26623. * of audio contexts you can create.
  26624. * @param hostElement defines the host element where to display the mute icon if necessary
  26625. */
  26626. constructor(hostElement?: Nullable<HTMLElement>);
  26627. /**
  26628. * Flags the audio engine in Locked state.
  26629. * This happens due to new browser policies preventing audio to autoplay.
  26630. */
  26631. lock(): void;
  26632. /**
  26633. * Unlocks the audio engine once a user action has been done on the dom.
  26634. * This is helpful to resume play once browser policies have been satisfied.
  26635. */
  26636. unlock(): void;
  26637. private _resumeAudioContext;
  26638. private _initializeAudioContext;
  26639. private _tryToRun;
  26640. private _triggerRunningState;
  26641. private _triggerSuspendedState;
  26642. private _displayMuteButton;
  26643. private _moveButtonToTopLeft;
  26644. private _onResize;
  26645. private _hideMuteButton;
  26646. /**
  26647. * Destroy and release the resources associated with the audio ccontext.
  26648. */
  26649. dispose(): void;
  26650. /**
  26651. * Gets the global volume sets on the master gain.
  26652. * @returns the global volume if set or -1 otherwise
  26653. */
  26654. getGlobalVolume(): number;
  26655. /**
  26656. * Sets the global volume of your experience (sets on the master gain).
  26657. * @param newVolume Defines the new global volume of the application
  26658. */
  26659. setGlobalVolume(newVolume: number): void;
  26660. /**
  26661. * Connect the audio engine to an audio analyser allowing some amazing
  26662. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26664. * @param analyser The analyser to connect to the engine
  26665. */
  26666. connectToAnalyser(analyser: Analyser): void;
  26667. }
  26668. }
  26669. declare module "babylonjs/Loading/loadingScreen" {
  26670. /**
  26671. * Interface used to present a loading screen while loading a scene
  26672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26673. */
  26674. export interface ILoadingScreen {
  26675. /**
  26676. * Function called to display the loading screen
  26677. */
  26678. displayLoadingUI: () => void;
  26679. /**
  26680. * Function called to hide the loading screen
  26681. */
  26682. hideLoadingUI: () => void;
  26683. /**
  26684. * Gets or sets the color to use for the background
  26685. */
  26686. loadingUIBackgroundColor: string;
  26687. /**
  26688. * Gets or sets the text to display while loading
  26689. */
  26690. loadingUIText: string;
  26691. }
  26692. /**
  26693. * Class used for the default loading screen
  26694. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26695. */
  26696. export class DefaultLoadingScreen implements ILoadingScreen {
  26697. private _renderingCanvas;
  26698. private _loadingText;
  26699. private _loadingDivBackgroundColor;
  26700. private _loadingDiv;
  26701. private _loadingTextDiv;
  26702. /**
  26703. * Creates a new default loading screen
  26704. * @param _renderingCanvas defines the canvas used to render the scene
  26705. * @param _loadingText defines the default text to display
  26706. * @param _loadingDivBackgroundColor defines the default background color
  26707. */
  26708. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26709. /**
  26710. * Function called to display the loading screen
  26711. */
  26712. displayLoadingUI(): void;
  26713. /**
  26714. * Function called to hide the loading screen
  26715. */
  26716. hideLoadingUI(): void;
  26717. /**
  26718. * Gets or sets the text to display while loading
  26719. */
  26720. loadingUIText: string;
  26721. /**
  26722. * Gets or sets the color to use for the background
  26723. */
  26724. loadingUIBackgroundColor: string;
  26725. private _resizeLoadingUI;
  26726. }
  26727. }
  26728. declare module "babylonjs/Materials/Textures/videoTexture" {
  26729. import { Observable } from "babylonjs/Misc/observable";
  26730. import { Nullable } from "babylonjs/types";
  26731. import { Scene } from "babylonjs/scene";
  26732. import { Texture } from "babylonjs/Materials/Textures/texture";
  26733. /**
  26734. * Settings for finer control over video usage
  26735. */
  26736. export interface VideoTextureSettings {
  26737. /**
  26738. * Applies `autoplay` to video, if specified
  26739. */
  26740. autoPlay?: boolean;
  26741. /**
  26742. * Applies `loop` to video, if specified
  26743. */
  26744. loop?: boolean;
  26745. /**
  26746. * Automatically updates internal texture from video at every frame in the render loop
  26747. */
  26748. autoUpdateTexture: boolean;
  26749. /**
  26750. * Image src displayed during the video loading or until the user interacts with the video.
  26751. */
  26752. poster?: string;
  26753. }
  26754. /**
  26755. * If you want to display a video in your scene, this is the special texture for that.
  26756. * This special texture works similar to other textures, with the exception of a few parameters.
  26757. * @see https://doc.babylonjs.com/how_to/video_texture
  26758. */
  26759. export class VideoTexture extends Texture {
  26760. /**
  26761. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26762. */
  26763. readonly autoUpdateTexture: boolean;
  26764. /**
  26765. * The video instance used by the texture internally
  26766. */
  26767. readonly video: HTMLVideoElement;
  26768. private _onUserActionRequestedObservable;
  26769. /**
  26770. * Event triggerd when a dom action is required by the user to play the video.
  26771. * This happens due to recent changes in browser policies preventing video to auto start.
  26772. */
  26773. readonly onUserActionRequestedObservable: Observable<Texture>;
  26774. private _generateMipMaps;
  26775. private _engine;
  26776. private _stillImageCaptured;
  26777. private _displayingPosterTexture;
  26778. private _settings;
  26779. private _createInternalTextureOnEvent;
  26780. /**
  26781. * Creates a video texture.
  26782. * If you want to display a video in your scene, this is the special texture for that.
  26783. * This special texture works similar to other textures, with the exception of a few parameters.
  26784. * @see https://doc.babylonjs.com/how_to/video_texture
  26785. * @param name optional name, will detect from video source, if not defined
  26786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26787. * @param scene is obviously the current scene.
  26788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26789. * @param invertY is false by default but can be used to invert video on Y axis
  26790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26791. * @param settings allows finer control over video usage
  26792. */
  26793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26794. private _getName;
  26795. private _getVideo;
  26796. private _createInternalTexture;
  26797. private reset;
  26798. /**
  26799. * @hidden Internal method to initiate `update`.
  26800. */
  26801. _rebuild(): void;
  26802. /**
  26803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26804. */
  26805. update(): void;
  26806. /**
  26807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26809. */
  26810. updateTexture(isVisible: boolean): void;
  26811. protected _updateInternalTexture: () => void;
  26812. /**
  26813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26814. * @param url New url.
  26815. */
  26816. updateURL(url: string): void;
  26817. /**
  26818. * Dispose the texture and release its associated resources.
  26819. */
  26820. dispose(): void;
  26821. /**
  26822. * Creates a video texture straight from a stream.
  26823. * @param scene Define the scene the texture should be created in
  26824. * @param stream Define the stream the texture should be created from
  26825. * @returns The created video texture as a promise
  26826. */
  26827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26828. /**
  26829. * Creates a video texture straight from your WebCam video feed.
  26830. * @param scene Define the scene the texture should be created in
  26831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26833. * @returns The created video texture as a promise
  26834. */
  26835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26836. minWidth: number;
  26837. maxWidth: number;
  26838. minHeight: number;
  26839. maxHeight: number;
  26840. deviceId: string;
  26841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26842. /**
  26843. * Creates a video texture straight from your WebCam video feed.
  26844. * @param scene Define the scene the texture should be created in
  26845. * @param onReady Define a callback to triggered once the texture will be ready
  26846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26848. */
  26849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26850. minWidth: number;
  26851. maxWidth: number;
  26852. minHeight: number;
  26853. maxHeight: number;
  26854. deviceId: string;
  26855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26856. }
  26857. }
  26858. declare module "babylonjs/Engines/engine" {
  26859. import { Observable } from "babylonjs/Misc/observable";
  26860. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26861. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26862. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26863. import { Camera } from "babylonjs/Cameras/camera";
  26864. import { Scene } from "babylonjs/scene";
  26865. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26866. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26867. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26869. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26870. import { Material } from "babylonjs/Materials/material";
  26871. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26874. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26875. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26876. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26877. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26878. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26879. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26880. import { WebRequest } from "babylonjs/Misc/webRequest";
  26881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26882. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26883. /**
  26884. * Interface for attribute information associated with buffer instanciation
  26885. */
  26886. export class InstancingAttributeInfo {
  26887. /**
  26888. * Index/offset of the attribute in the vertex shader
  26889. */
  26890. index: number;
  26891. /**
  26892. * size of the attribute, 1, 2, 3 or 4
  26893. */
  26894. attributeSize: number;
  26895. /**
  26896. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26897. * default is FLOAT
  26898. */
  26899. attribyteType: number;
  26900. /**
  26901. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26902. */
  26903. normalized: boolean;
  26904. /**
  26905. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26906. */
  26907. offset: number;
  26908. /**
  26909. * Name of the GLSL attribute, for debugging purpose only
  26910. */
  26911. attributeName: string;
  26912. }
  26913. /**
  26914. * Define options used to create a depth texture
  26915. */
  26916. export class DepthTextureCreationOptions {
  26917. /** Specifies whether or not a stencil should be allocated in the texture */
  26918. generateStencil?: boolean;
  26919. /** Specifies whether or not bilinear filtering is enable on the texture */
  26920. bilinearFiltering?: boolean;
  26921. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26922. comparisonFunction?: number;
  26923. /** Specifies if the created texture is a cube texture */
  26924. isCube?: boolean;
  26925. }
  26926. /**
  26927. * Class used to describe the capabilities of the engine relatively to the current browser
  26928. */
  26929. export class EngineCapabilities {
  26930. /** Maximum textures units per fragment shader */
  26931. maxTexturesImageUnits: number;
  26932. /** Maximum texture units per vertex shader */
  26933. maxVertexTextureImageUnits: number;
  26934. /** Maximum textures units in the entire pipeline */
  26935. maxCombinedTexturesImageUnits: number;
  26936. /** Maximum texture size */
  26937. maxTextureSize: number;
  26938. /** Maximum cube texture size */
  26939. maxCubemapTextureSize: number;
  26940. /** Maximum render texture size */
  26941. maxRenderTextureSize: number;
  26942. /** Maximum number of vertex attributes */
  26943. maxVertexAttribs: number;
  26944. /** Maximum number of varyings */
  26945. maxVaryingVectors: number;
  26946. /** Maximum number of uniforms per vertex shader */
  26947. maxVertexUniformVectors: number;
  26948. /** Maximum number of uniforms per fragment shader */
  26949. maxFragmentUniformVectors: number;
  26950. /** Defines if standard derivates (dx/dy) are supported */
  26951. standardDerivatives: boolean;
  26952. /** Defines if s3tc texture compression is supported */
  26953. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26954. /** Defines if pvrtc texture compression is supported */
  26955. pvrtc: any;
  26956. /** Defines if etc1 texture compression is supported */
  26957. etc1: any;
  26958. /** Defines if etc2 texture compression is supported */
  26959. etc2: any;
  26960. /** Defines if astc texture compression is supported */
  26961. astc: any;
  26962. /** Defines if float textures are supported */
  26963. textureFloat: boolean;
  26964. /** Defines if vertex array objects are supported */
  26965. vertexArrayObject: boolean;
  26966. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26967. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26968. /** Gets the maximum level of anisotropy supported */
  26969. maxAnisotropy: number;
  26970. /** Defines if instancing is supported */
  26971. instancedArrays: boolean;
  26972. /** Defines if 32 bits indices are supported */
  26973. uintIndices: boolean;
  26974. /** Defines if high precision shaders are supported */
  26975. highPrecisionShaderSupported: boolean;
  26976. /** Defines if depth reading in the fragment shader is supported */
  26977. fragmentDepthSupported: boolean;
  26978. /** Defines if float texture linear filtering is supported*/
  26979. textureFloatLinearFiltering: boolean;
  26980. /** Defines if rendering to float textures is supported */
  26981. textureFloatRender: boolean;
  26982. /** Defines if half float textures are supported*/
  26983. textureHalfFloat: boolean;
  26984. /** Defines if half float texture linear filtering is supported*/
  26985. textureHalfFloatLinearFiltering: boolean;
  26986. /** Defines if rendering to half float textures is supported */
  26987. textureHalfFloatRender: boolean;
  26988. /** Defines if textureLOD shader command is supported */
  26989. textureLOD: boolean;
  26990. /** Defines if draw buffers extension is supported */
  26991. drawBuffersExtension: boolean;
  26992. /** Defines if depth textures are supported */
  26993. depthTextureExtension: boolean;
  26994. /** Defines if float color buffer are supported */
  26995. colorBufferFloat: boolean;
  26996. /** Gets disjoint timer query extension (null if not supported) */
  26997. timerQuery: EXT_disjoint_timer_query;
  26998. /** Defines if timestamp can be used with timer query */
  26999. canUseTimestampForTimerQuery: boolean;
  27000. /** Function used to let the system compiles shaders in background */
  27001. parallelShaderCompile: {
  27002. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27003. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27004. COMPLETION_STATUS_KHR: number;
  27005. };
  27006. }
  27007. /** Interface defining initialization parameters for Engine class */
  27008. export interface EngineOptions extends WebGLContextAttributes {
  27009. /**
  27010. * Defines if the engine should no exceed a specified device ratio
  27011. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27012. */
  27013. limitDeviceRatio?: number;
  27014. /**
  27015. * Defines if webvr should be enabled automatically
  27016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27017. */
  27018. autoEnableWebVR?: boolean;
  27019. /**
  27020. * Defines if webgl2 should be turned off even if supported
  27021. * @see http://doc.babylonjs.com/features/webgl2
  27022. */
  27023. disableWebGL2Support?: boolean;
  27024. /**
  27025. * Defines if webaudio should be initialized as well
  27026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27027. */
  27028. audioEngine?: boolean;
  27029. /**
  27030. * Defines if animations should run using a deterministic lock step
  27031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27032. */
  27033. deterministicLockstep?: boolean;
  27034. /** Defines the maximum steps to use with deterministic lock step mode */
  27035. lockstepMaxSteps?: number;
  27036. /**
  27037. * Defines that engine should ignore context lost events
  27038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27039. */
  27040. doNotHandleContextLost?: boolean;
  27041. /**
  27042. * Defines that engine should ignore modifying touch action attribute and style
  27043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27044. */
  27045. doNotHandleTouchAction?: boolean;
  27046. /**
  27047. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  27048. */
  27049. useHighPrecisionFloats?: boolean;
  27050. }
  27051. /**
  27052. * Defines the interface used by display changed events
  27053. */
  27054. export interface IDisplayChangedEventArgs {
  27055. /** Gets the vrDisplay object (if any) */
  27056. vrDisplay: Nullable<any>;
  27057. /** Gets a boolean indicating if webVR is supported */
  27058. vrSupported: boolean;
  27059. }
  27060. /**
  27061. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27062. */
  27063. export class Engine {
  27064. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27065. static ExceptionList: ({
  27066. key: string;
  27067. capture: string;
  27068. captureConstraint: number;
  27069. targets: string[];
  27070. } | {
  27071. key: string;
  27072. capture: null;
  27073. captureConstraint: null;
  27074. targets: string[];
  27075. })[];
  27076. /** Gets the list of created engines */
  27077. static readonly Instances: Engine[];
  27078. /**
  27079. * Gets the latest created engine
  27080. */
  27081. static readonly LastCreatedEngine: Nullable<Engine>;
  27082. /**
  27083. * Gets the latest created scene
  27084. */
  27085. static readonly LastCreatedScene: Nullable<Scene>;
  27086. /**
  27087. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27088. * @param flag defines which part of the materials must be marked as dirty
  27089. * @param predicate defines a predicate used to filter which materials should be affected
  27090. */
  27091. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27092. /**
  27093. * Hidden
  27094. */
  27095. static _TextureLoaders: IInternalTextureLoader[];
  27096. /** Defines that alpha blending is disabled */
  27097. static readonly ALPHA_DISABLE: number;
  27098. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27099. static readonly ALPHA_ADD: number;
  27100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27101. static readonly ALPHA_COMBINE: number;
  27102. /** Defines that alpha blending to DEST - SRC * DEST */
  27103. static readonly ALPHA_SUBTRACT: number;
  27104. /** Defines that alpha blending to SRC * DEST */
  27105. static readonly ALPHA_MULTIPLY: number;
  27106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27107. static readonly ALPHA_MAXIMIZED: number;
  27108. /** Defines that alpha blending to SRC + DEST */
  27109. static readonly ALPHA_ONEONE: number;
  27110. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27111. static readonly ALPHA_PREMULTIPLIED: number;
  27112. /**
  27113. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27114. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27115. */
  27116. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27117. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27118. static readonly ALPHA_INTERPOLATE: number;
  27119. /**
  27120. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27121. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27122. */
  27123. static readonly ALPHA_SCREENMODE: number;
  27124. /** Defines that the ressource is not delayed*/
  27125. static readonly DELAYLOADSTATE_NONE: number;
  27126. /** Defines that the ressource was successfully delay loaded */
  27127. static readonly DELAYLOADSTATE_LOADED: number;
  27128. /** Defines that the ressource is currently delay loading */
  27129. static readonly DELAYLOADSTATE_LOADING: number;
  27130. /** Defines that the ressource is delayed and has not started loading */
  27131. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27133. static readonly NEVER: number;
  27134. /** 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 */
  27135. static readonly ALWAYS: number;
  27136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27137. static readonly LESS: number;
  27138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27139. static readonly EQUAL: number;
  27140. /** 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 */
  27141. static readonly LEQUAL: number;
  27142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27143. static readonly GREATER: number;
  27144. /** 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 */
  27145. static readonly GEQUAL: number;
  27146. /** 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 */
  27147. static readonly NOTEQUAL: number;
  27148. /** Passed to stencilOperation to specify that stencil value must be kept */
  27149. static readonly KEEP: number;
  27150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27151. static readonly REPLACE: number;
  27152. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27153. static readonly INCR: number;
  27154. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27155. static readonly DECR: number;
  27156. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27157. static readonly INVERT: number;
  27158. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27159. static readonly INCR_WRAP: number;
  27160. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27161. static readonly DECR_WRAP: number;
  27162. /** Texture is not repeating outside of 0..1 UVs */
  27163. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27164. /** Texture is repeating outside of 0..1 UVs */
  27165. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27166. /** Texture is repeating and mirrored */
  27167. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27168. /** ALPHA */
  27169. static readonly TEXTUREFORMAT_ALPHA: number;
  27170. /** LUMINANCE */
  27171. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27172. /** LUMINANCE_ALPHA */
  27173. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27174. /** RGB */
  27175. static readonly TEXTUREFORMAT_RGB: number;
  27176. /** RGBA */
  27177. static readonly TEXTUREFORMAT_RGBA: number;
  27178. /** RED */
  27179. static readonly TEXTUREFORMAT_RED: number;
  27180. /** RED (2nd reference) */
  27181. static readonly TEXTUREFORMAT_R: number;
  27182. /** RG */
  27183. static readonly TEXTUREFORMAT_RG: number;
  27184. /** RED_INTEGER */
  27185. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27186. /** RED_INTEGER (2nd reference) */
  27187. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27188. /** RG_INTEGER */
  27189. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27190. /** RGB_INTEGER */
  27191. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27192. /** RGBA_INTEGER */
  27193. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27194. /** UNSIGNED_BYTE */
  27195. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27196. /** UNSIGNED_BYTE (2nd reference) */
  27197. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27198. /** FLOAT */
  27199. static readonly TEXTURETYPE_FLOAT: number;
  27200. /** HALF_FLOAT */
  27201. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27202. /** BYTE */
  27203. static readonly TEXTURETYPE_BYTE: number;
  27204. /** SHORT */
  27205. static readonly TEXTURETYPE_SHORT: number;
  27206. /** UNSIGNED_SHORT */
  27207. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27208. /** INT */
  27209. static readonly TEXTURETYPE_INT: number;
  27210. /** UNSIGNED_INT */
  27211. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27212. /** UNSIGNED_SHORT_4_4_4_4 */
  27213. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27214. /** UNSIGNED_SHORT_5_5_5_1 */
  27215. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27216. /** UNSIGNED_SHORT_5_6_5 */
  27217. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27218. /** UNSIGNED_INT_2_10_10_10_REV */
  27219. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27220. /** UNSIGNED_INT_24_8 */
  27221. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27222. /** UNSIGNED_INT_10F_11F_11F_REV */
  27223. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27224. /** UNSIGNED_INT_5_9_9_9_REV */
  27225. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27226. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27227. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27228. /** nearest is mag = nearest and min = nearest and mip = linear */
  27229. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27231. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27232. /** Trilinear is mag = linear and min = linear and mip = linear */
  27233. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27234. /** nearest is mag = nearest and min = nearest and mip = linear */
  27235. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27237. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27238. /** Trilinear is mag = linear and min = linear and mip = linear */
  27239. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27240. /** mag = nearest and min = nearest and mip = nearest */
  27241. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27242. /** mag = nearest and min = linear and mip = nearest */
  27243. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27244. /** mag = nearest and min = linear and mip = linear */
  27245. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27246. /** mag = nearest and min = linear and mip = none */
  27247. static readonly TEXTURE_NEAREST_LINEAR: number;
  27248. /** mag = nearest and min = nearest and mip = none */
  27249. static readonly TEXTURE_NEAREST_NEAREST: number;
  27250. /** mag = linear and min = nearest and mip = nearest */
  27251. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27252. /** mag = linear and min = nearest and mip = linear */
  27253. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27254. /** mag = linear and min = linear and mip = none */
  27255. static readonly TEXTURE_LINEAR_LINEAR: number;
  27256. /** mag = linear and min = nearest and mip = none */
  27257. static readonly TEXTURE_LINEAR_NEAREST: number;
  27258. /** Explicit coordinates mode */
  27259. static readonly TEXTURE_EXPLICIT_MODE: number;
  27260. /** Spherical coordinates mode */
  27261. static readonly TEXTURE_SPHERICAL_MODE: number;
  27262. /** Planar coordinates mode */
  27263. static readonly TEXTURE_PLANAR_MODE: number;
  27264. /** Cubic coordinates mode */
  27265. static readonly TEXTURE_CUBIC_MODE: number;
  27266. /** Projection coordinates mode */
  27267. static readonly TEXTURE_PROJECTION_MODE: number;
  27268. /** Skybox coordinates mode */
  27269. static readonly TEXTURE_SKYBOX_MODE: number;
  27270. /** Inverse Cubic coordinates mode */
  27271. static readonly TEXTURE_INVCUBIC_MODE: number;
  27272. /** Equirectangular coordinates mode */
  27273. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27274. /** Equirectangular Fixed coordinates mode */
  27275. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27276. /** Equirectangular Fixed Mirrored coordinates mode */
  27277. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27278. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27279. static readonly SCALEMODE_FLOOR: number;
  27280. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27281. static readonly SCALEMODE_NEAREST: number;
  27282. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27283. static readonly SCALEMODE_CEILING: number;
  27284. /**
  27285. * Returns the current version of the framework
  27286. */
  27287. static readonly Version: string;
  27288. /**
  27289. * Returns a string describing the current engine
  27290. */
  27291. readonly description: string;
  27292. /**
  27293. * Gets or sets the epsilon value used by collision engine
  27294. */
  27295. static CollisionsEpsilon: number;
  27296. /**
  27297. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27298. */
  27299. static ShadersRepository: string;
  27300. /**
  27301. * Method called to create the default loading screen.
  27302. * This can be overriden in your own app.
  27303. * @param canvas The rendering canvas element
  27304. * @returns The loading screen
  27305. */
  27306. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27307. /**
  27308. * Method called to create the default rescale post process on each engine.
  27309. */
  27310. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27311. /**
  27312. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27313. */
  27314. forcePOTTextures: boolean;
  27315. /**
  27316. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27317. */
  27318. isFullscreen: boolean;
  27319. /**
  27320. * Gets a boolean indicating if the pointer is currently locked
  27321. */
  27322. isPointerLock: boolean;
  27323. /**
  27324. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27325. */
  27326. cullBackFaces: boolean;
  27327. /**
  27328. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27329. */
  27330. renderEvenInBackground: boolean;
  27331. /**
  27332. * Gets or sets a boolean indicating that cache can be kept between frames
  27333. */
  27334. preventCacheWipeBetweenFrames: boolean;
  27335. /**
  27336. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27337. **/
  27338. enableOfflineSupport: boolean;
  27339. /**
  27340. * 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)
  27341. **/
  27342. disableManifestCheck: boolean;
  27343. /**
  27344. * Gets the list of created scenes
  27345. */
  27346. scenes: Scene[];
  27347. /**
  27348. * Event raised when a new scene is created
  27349. */
  27350. onNewSceneAddedObservable: Observable<Scene>;
  27351. /**
  27352. * Gets the list of created postprocesses
  27353. */
  27354. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27355. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27356. validateShaderPrograms: boolean;
  27357. /**
  27358. * Observable event triggered each time the rendering canvas is resized
  27359. */
  27360. onResizeObservable: Observable<Engine>;
  27361. /**
  27362. * Observable event triggered each time the canvas loses focus
  27363. */
  27364. onCanvasBlurObservable: Observable<Engine>;
  27365. /**
  27366. * Observable event triggered each time the canvas gains focus
  27367. */
  27368. onCanvasFocusObservable: Observable<Engine>;
  27369. /**
  27370. * Observable event triggered each time the canvas receives pointerout event
  27371. */
  27372. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27373. /**
  27374. * Observable event triggered before each texture is initialized
  27375. */
  27376. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27377. private _vrDisplay;
  27378. private _vrSupported;
  27379. private _oldSize;
  27380. private _oldHardwareScaleFactor;
  27381. private _vrExclusivePointerMode;
  27382. private _webVRInitPromise;
  27383. /**
  27384. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27385. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27386. */
  27387. readonly isInVRExclusivePointerMode: boolean;
  27388. /**
  27389. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27390. */
  27391. disableUniformBuffers: boolean;
  27392. /** @hidden */
  27393. _uniformBuffers: UniformBuffer[];
  27394. /**
  27395. * Gets a boolean indicating that the engine supports uniform buffers
  27396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27397. */
  27398. readonly supportsUniformBuffers: boolean;
  27399. /**
  27400. * Observable raised when the engine begins a new frame
  27401. */
  27402. onBeginFrameObservable: Observable<Engine>;
  27403. /**
  27404. * If set, will be used to request the next animation frame for the render loop
  27405. */
  27406. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27407. /**
  27408. * Observable raised when the engine ends the current frame
  27409. */
  27410. onEndFrameObservable: Observable<Engine>;
  27411. /**
  27412. * Observable raised when the engine is about to compile a shader
  27413. */
  27414. onBeforeShaderCompilationObservable: Observable<Engine>;
  27415. /**
  27416. * Observable raised when the engine has jsut compiled a shader
  27417. */
  27418. onAfterShaderCompilationObservable: Observable<Engine>;
  27419. /** @hidden */
  27420. _gl: WebGLRenderingContext;
  27421. private _renderingCanvas;
  27422. private _windowIsBackground;
  27423. private _webGLVersion;
  27424. protected _highPrecisionShadersAllowed: boolean;
  27425. /** @hidden */
  27426. readonly _shouldUseHighPrecisionShader: boolean;
  27427. /**
  27428. * Gets a boolean indicating that only power of 2 textures are supported
  27429. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27430. */
  27431. readonly needPOTTextures: boolean;
  27432. /** @hidden */
  27433. _badOS: boolean;
  27434. /** @hidden */
  27435. _badDesktopOS: boolean;
  27436. /**
  27437. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27438. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27439. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27440. */
  27441. disableTextureBindingOptimization: boolean;
  27442. /**
  27443. * Gets the audio engine
  27444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27445. * @ignorenaming
  27446. */
  27447. static audioEngine: IAudioEngine;
  27448. /**
  27449. * Default AudioEngine factory responsible of creating the Audio Engine.
  27450. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27451. */
  27452. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27453. /**
  27454. * Default offline support factory responsible of creating a tool used to store data locally.
  27455. * By default, this will create a Database object if the workload has been embedded.
  27456. */
  27457. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27458. private _onFocus;
  27459. private _onBlur;
  27460. private _onCanvasPointerOut;
  27461. private _onCanvasBlur;
  27462. private _onCanvasFocus;
  27463. private _onFullscreenChange;
  27464. private _onPointerLockChange;
  27465. private _onVRDisplayPointerRestricted;
  27466. private _onVRDisplayPointerUnrestricted;
  27467. private _onVrDisplayConnect;
  27468. private _onVrDisplayDisconnect;
  27469. private _onVrDisplayPresentChange;
  27470. /**
  27471. * Observable signaled when VR display mode changes
  27472. */
  27473. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27474. /**
  27475. * Observable signaled when VR request present is complete
  27476. */
  27477. onVRRequestPresentComplete: Observable<boolean>;
  27478. /**
  27479. * Observable signaled when VR request present starts
  27480. */
  27481. onVRRequestPresentStart: Observable<Engine>;
  27482. private _hardwareScalingLevel;
  27483. /** @hidden */
  27484. protected _caps: EngineCapabilities;
  27485. private _pointerLockRequested;
  27486. private _isStencilEnable;
  27487. private _colorWrite;
  27488. private _loadingScreen;
  27489. /** @hidden */
  27490. _drawCalls: PerfCounter;
  27491. /** @hidden */
  27492. _textureCollisions: PerfCounter;
  27493. private _glVersion;
  27494. private _glRenderer;
  27495. private _glVendor;
  27496. private _videoTextureSupported;
  27497. private _renderingQueueLaunched;
  27498. private _activeRenderLoops;
  27499. private _deterministicLockstep;
  27500. private _lockstepMaxSteps;
  27501. /**
  27502. * Observable signaled when a context lost event is raised
  27503. */
  27504. onContextLostObservable: Observable<Engine>;
  27505. /**
  27506. * Observable signaled when a context restored event is raised
  27507. */
  27508. onContextRestoredObservable: Observable<Engine>;
  27509. private _onContextLost;
  27510. private _onContextRestored;
  27511. private _contextWasLost;
  27512. private _doNotHandleContextLost;
  27513. /**
  27514. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27516. */
  27517. doNotHandleContextLost: boolean;
  27518. private _performanceMonitor;
  27519. private _fps;
  27520. private _deltaTime;
  27521. /**
  27522. * Turn this value on if you want to pause FPS computation when in background
  27523. */
  27524. disablePerformanceMonitorInBackground: boolean;
  27525. /**
  27526. * Gets the performance monitor attached to this engine
  27527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27528. */
  27529. readonly performanceMonitor: PerformanceMonitor;
  27530. /** @hidden */
  27531. protected _depthCullingState: _DepthCullingState;
  27532. /** @hidden */
  27533. protected _stencilState: _StencilState;
  27534. /** @hidden */
  27535. protected _alphaState: _AlphaState;
  27536. /** @hidden */
  27537. protected _alphaMode: number;
  27538. protected _internalTexturesCache: InternalTexture[];
  27539. /** @hidden */
  27540. protected _activeChannel: number;
  27541. private _currentTextureChannel;
  27542. /** @hidden */
  27543. protected _boundTexturesCache: {
  27544. [key: string]: Nullable<InternalTexture>;
  27545. };
  27546. /** @hidden */
  27547. protected _currentEffect: Nullable<Effect>;
  27548. /** @hidden */
  27549. protected _currentProgram: Nullable<WebGLProgram>;
  27550. private _compiledEffects;
  27551. private _vertexAttribArraysEnabled;
  27552. /** @hidden */
  27553. protected _cachedViewport: Nullable<Viewport>;
  27554. private _cachedVertexArrayObject;
  27555. /** @hidden */
  27556. protected _cachedVertexBuffers: any;
  27557. /** @hidden */
  27558. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27559. /** @hidden */
  27560. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27561. /** @hidden */
  27562. protected _currentRenderTarget: Nullable<InternalTexture>;
  27563. private _uintIndicesCurrentlySet;
  27564. private _currentBoundBuffer;
  27565. /** @hidden */
  27566. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27567. private _currentBufferPointers;
  27568. private _currentInstanceLocations;
  27569. private _currentInstanceBuffers;
  27570. private _textureUnits;
  27571. private _firstBoundInternalTextureTracker;
  27572. private _lastBoundInternalTextureTracker;
  27573. private _workingCanvas;
  27574. private _workingContext;
  27575. private _rescalePostProcess;
  27576. private _dummyFramebuffer;
  27577. private _externalData;
  27578. private _bindedRenderFunction;
  27579. private _vaoRecordInProgress;
  27580. private _mustWipeVertexAttributes;
  27581. private _emptyTexture;
  27582. private _emptyCubeTexture;
  27583. private _emptyTexture3D;
  27584. /** @hidden */
  27585. _frameHandler: number;
  27586. private _nextFreeTextureSlots;
  27587. private _maxSimultaneousTextures;
  27588. private _activeRequests;
  27589. private _texturesSupported;
  27590. private _textureFormatInUse;
  27591. /**
  27592. * Gets the list of texture formats supported
  27593. */
  27594. readonly texturesSupported: Array<string>;
  27595. /**
  27596. * Gets the list of texture formats in use
  27597. */
  27598. readonly textureFormatInUse: Nullable<string>;
  27599. /**
  27600. * Gets the current viewport
  27601. */
  27602. readonly currentViewport: Nullable<Viewport>;
  27603. /**
  27604. * Gets the default empty texture
  27605. */
  27606. readonly emptyTexture: InternalTexture;
  27607. /**
  27608. * Gets the default empty 3D texture
  27609. */
  27610. readonly emptyTexture3D: InternalTexture;
  27611. /**
  27612. * Gets the default empty cube texture
  27613. */
  27614. readonly emptyCubeTexture: InternalTexture;
  27615. /**
  27616. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27617. */
  27618. readonly premultipliedAlpha: boolean;
  27619. /**
  27620. * Creates a new engine
  27621. * @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
  27622. * @param antialias defines enable antialiasing (default: false)
  27623. * @param options defines further options to be sent to the getContext() function
  27624. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27625. */
  27626. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27627. private _disableTouchAction;
  27628. private _rebuildInternalTextures;
  27629. private _rebuildEffects;
  27630. /**
  27631. * Gets a boolean indicating if all created effects are ready
  27632. * @returns true if all effects are ready
  27633. */
  27634. areAllEffectsReady(): boolean;
  27635. private _rebuildBuffers;
  27636. private _initGLContext;
  27637. /**
  27638. * Gets version of the current webGL context
  27639. */
  27640. readonly webGLVersion: number;
  27641. /**
  27642. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27643. */
  27644. readonly isStencilEnable: boolean;
  27645. private _prepareWorkingCanvas;
  27646. /**
  27647. * Reset the texture cache to empty state
  27648. */
  27649. resetTextureCache(): void;
  27650. /**
  27651. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27652. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27653. * @returns true if engine is in deterministic lock step mode
  27654. */
  27655. isDeterministicLockStep(): boolean;
  27656. /**
  27657. * Gets the max steps when engine is running in deterministic lock step
  27658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27659. * @returns the max steps
  27660. */
  27661. getLockstepMaxSteps(): number;
  27662. /**
  27663. * Gets an object containing information about the current webGL context
  27664. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27665. */
  27666. getGlInfo(): {
  27667. vendor: string;
  27668. renderer: string;
  27669. version: string;
  27670. };
  27671. /**
  27672. * Gets current aspect ratio
  27673. * @param camera defines the camera to use to get the aspect ratio
  27674. * @param useScreen defines if screen size must be used (or the current render target if any)
  27675. * @returns a number defining the aspect ratio
  27676. */
  27677. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27678. /**
  27679. * Gets current screen aspect ratio
  27680. * @returns a number defining the aspect ratio
  27681. */
  27682. getScreenAspectRatio(): number;
  27683. /**
  27684. * Gets the current render width
  27685. * @param useScreen defines if screen size must be used (or the current render target if any)
  27686. * @returns a number defining the current render width
  27687. */
  27688. getRenderWidth(useScreen?: boolean): number;
  27689. /**
  27690. * Gets the current render height
  27691. * @param useScreen defines if screen size must be used (or the current render target if any)
  27692. * @returns a number defining the current render height
  27693. */
  27694. getRenderHeight(useScreen?: boolean): number;
  27695. /**
  27696. * Gets the HTML canvas attached with the current webGL context
  27697. * @returns a HTML canvas
  27698. */
  27699. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27700. /**
  27701. * Gets the client rect of the HTML canvas attached with the current webGL context
  27702. * @returns a client rectanglee
  27703. */
  27704. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27705. /**
  27706. * Defines the hardware scaling level.
  27707. * By default the hardware scaling level is computed from the window device ratio.
  27708. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  27709. * @param level defines the level to use
  27710. */
  27711. setHardwareScalingLevel(level: number): void;
  27712. /**
  27713. * Gets the current hardware scaling level.
  27714. * By default the hardware scaling level is computed from the window device ratio.
  27715. * 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.
  27716. * @returns a number indicating the current hardware scaling level
  27717. */
  27718. getHardwareScalingLevel(): number;
  27719. /**
  27720. * Gets the list of loaded textures
  27721. * @returns an array containing all loaded textures
  27722. */
  27723. getLoadedTexturesCache(): InternalTexture[];
  27724. /**
  27725. * Gets the object containing all engine capabilities
  27726. * @returns the EngineCapabilities object
  27727. */
  27728. getCaps(): EngineCapabilities;
  27729. /**
  27730. * Gets the current depth function
  27731. * @returns a number defining the depth function
  27732. */
  27733. getDepthFunction(): Nullable<number>;
  27734. /**
  27735. * Sets the current depth function
  27736. * @param depthFunc defines the function to use
  27737. */
  27738. setDepthFunction(depthFunc: number): void;
  27739. /**
  27740. * Sets the current depth function to GREATER
  27741. */
  27742. setDepthFunctionToGreater(): void;
  27743. /**
  27744. * Sets the current depth function to GEQUAL
  27745. */
  27746. setDepthFunctionToGreaterOrEqual(): void;
  27747. /**
  27748. * Sets the current depth function to LESS
  27749. */
  27750. setDepthFunctionToLess(): void;
  27751. /**
  27752. * Sets the current depth function to LEQUAL
  27753. */
  27754. setDepthFunctionToLessOrEqual(): void;
  27755. /**
  27756. * Gets a boolean indicating if stencil buffer is enabled
  27757. * @returns the current stencil buffer state
  27758. */
  27759. getStencilBuffer(): boolean;
  27760. /**
  27761. * Enable or disable the stencil buffer
  27762. * @param enable defines if the stencil buffer must be enabled or disabled
  27763. */
  27764. setStencilBuffer(enable: boolean): void;
  27765. /**
  27766. * Gets the current stencil mask
  27767. * @returns a number defining the new stencil mask to use
  27768. */
  27769. getStencilMask(): number;
  27770. /**
  27771. * Sets the current stencil mask
  27772. * @param mask defines the new stencil mask to use
  27773. */
  27774. setStencilMask(mask: number): void;
  27775. /**
  27776. * Gets the current stencil function
  27777. * @returns a number defining the stencil function to use
  27778. */
  27779. getStencilFunction(): number;
  27780. /**
  27781. * Gets the current stencil reference value
  27782. * @returns a number defining the stencil reference value to use
  27783. */
  27784. getStencilFunctionReference(): number;
  27785. /**
  27786. * Gets the current stencil mask
  27787. * @returns a number defining the stencil mask to use
  27788. */
  27789. getStencilFunctionMask(): number;
  27790. /**
  27791. * Sets the current stencil function
  27792. * @param stencilFunc defines the new stencil function to use
  27793. */
  27794. setStencilFunction(stencilFunc: number): void;
  27795. /**
  27796. * Sets the current stencil reference
  27797. * @param reference defines the new stencil reference to use
  27798. */
  27799. setStencilFunctionReference(reference: number): void;
  27800. /**
  27801. * Sets the current stencil mask
  27802. * @param mask defines the new stencil mask to use
  27803. */
  27804. setStencilFunctionMask(mask: number): void;
  27805. /**
  27806. * Gets the current stencil operation when stencil fails
  27807. * @returns a number defining stencil operation to use when stencil fails
  27808. */
  27809. getStencilOperationFail(): number;
  27810. /**
  27811. * Gets the current stencil operation when depth fails
  27812. * @returns a number defining stencil operation to use when depth fails
  27813. */
  27814. getStencilOperationDepthFail(): number;
  27815. /**
  27816. * Gets the current stencil operation when stencil passes
  27817. * @returns a number defining stencil operation to use when stencil passes
  27818. */
  27819. getStencilOperationPass(): number;
  27820. /**
  27821. * Sets the stencil operation to use when stencil fails
  27822. * @param operation defines the stencil operation to use when stencil fails
  27823. */
  27824. setStencilOperationFail(operation: number): void;
  27825. /**
  27826. * Sets the stencil operation to use when depth fails
  27827. * @param operation defines the stencil operation to use when depth fails
  27828. */
  27829. setStencilOperationDepthFail(operation: number): void;
  27830. /**
  27831. * Sets the stencil operation to use when stencil passes
  27832. * @param operation defines the stencil operation to use when stencil passes
  27833. */
  27834. setStencilOperationPass(operation: number): void;
  27835. /**
  27836. * Sets a boolean indicating if the dithering state is enabled or disabled
  27837. * @param value defines the dithering state
  27838. */
  27839. setDitheringState(value: boolean): void;
  27840. /**
  27841. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27842. * @param value defines the rasterizer state
  27843. */
  27844. setRasterizerState(value: boolean): void;
  27845. /**
  27846. * stop executing a render loop function and remove it from the execution array
  27847. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27848. */
  27849. stopRenderLoop(renderFunction?: () => void): void;
  27850. /** @hidden */
  27851. _renderLoop(): void;
  27852. /**
  27853. * Register and execute a render loop. The engine can have more than one render function
  27854. * @param renderFunction defines the function to continuously execute
  27855. */
  27856. runRenderLoop(renderFunction: () => void): void;
  27857. /**
  27858. * Toggle full screen mode
  27859. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27860. */
  27861. switchFullscreen(requestPointerLock: boolean): void;
  27862. /**
  27863. * Enters full screen mode
  27864. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27865. */
  27866. enterFullscreen(requestPointerLock: boolean): void;
  27867. /**
  27868. * Exits full screen mode
  27869. */
  27870. exitFullscreen(): void;
  27871. /**
  27872. * Clear the current render buffer or the current render target (if any is set up)
  27873. * @param color defines the color to use
  27874. * @param backBuffer defines if the back buffer must be cleared
  27875. * @param depth defines if the depth buffer must be cleared
  27876. * @param stencil defines if the stencil buffer must be cleared
  27877. */
  27878. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27879. /**
  27880. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27881. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27882. * @param y defines the y-coordinate of the corner of the clear rectangle
  27883. * @param width defines the width of the clear rectangle
  27884. * @param height defines the height of the clear rectangle
  27885. * @param clearColor defines the clear color
  27886. */
  27887. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27888. /**
  27889. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27890. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27891. * @param y defines the y-coordinate of the corner of the clear rectangle
  27892. * @param width defines the width of the clear rectangle
  27893. * @param height defines the height of the clear rectangle
  27894. */
  27895. enableScissor(x: number, y: number, width: number, height: number): void;
  27896. /**
  27897. * Disable previously set scissor test rectangle
  27898. */
  27899. disableScissor(): void;
  27900. private _viewportCached;
  27901. /** @hidden */
  27902. _viewport(x: number, y: number, width: number, height: number): void;
  27903. /**
  27904. * Set the WebGL's viewport
  27905. * @param viewport defines the viewport element to be used
  27906. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27907. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27908. */
  27909. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27910. /**
  27911. * Directly set the WebGL Viewport
  27912. * @param x defines the x coordinate of the viewport (in screen space)
  27913. * @param y defines the y coordinate of the viewport (in screen space)
  27914. * @param width defines the width of the viewport (in screen space)
  27915. * @param height defines the height of the viewport (in screen space)
  27916. * @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
  27917. */
  27918. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27919. /**
  27920. * Begin a new frame
  27921. */
  27922. beginFrame(): void;
  27923. /**
  27924. * Enf the current frame
  27925. */
  27926. endFrame(): void;
  27927. /**
  27928. * Resize the view according to the canvas' size
  27929. */
  27930. resize(): void;
  27931. /**
  27932. * Force a specific size of the canvas
  27933. * @param width defines the new canvas' width
  27934. * @param height defines the new canvas' height
  27935. */
  27936. setSize(width: number, height: number): void;
  27937. /**
  27938. * Gets a boolean indicating if a webVR device was detected
  27939. * @returns true if a webVR device was detected
  27940. */
  27941. isVRDevicePresent(): boolean;
  27942. /**
  27943. * Gets the current webVR device
  27944. * @returns the current webVR device (or null)
  27945. */
  27946. getVRDevice(): any;
  27947. /**
  27948. * Initializes a webVR display and starts listening to display change events
  27949. * The onVRDisplayChangedObservable will be notified upon these changes
  27950. * @returns The onVRDisplayChangedObservable
  27951. */
  27952. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27953. /**
  27954. * Initializes a webVR display and starts listening to display change events
  27955. * The onVRDisplayChangedObservable will be notified upon these changes
  27956. * @returns A promise containing a VRDisplay and if vr is supported
  27957. */
  27958. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27959. /**
  27960. * Call this function to switch to webVR mode
  27961. * Will do nothing if webVR is not supported or if there is no webVR device
  27962. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27963. */
  27964. enableVR(): void;
  27965. /**
  27966. * Call this function to leave webVR mode
  27967. * Will do nothing if webVR is not supported or if there is no webVR device
  27968. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27969. */
  27970. disableVR(): void;
  27971. private _onVRFullScreenTriggered;
  27972. private _getVRDisplaysAsync;
  27973. /**
  27974. * Binds the frame buffer to the specified texture.
  27975. * @param texture The texture to render to or null for the default canvas
  27976. * @param faceIndex The face of the texture to render to in case of cube texture
  27977. * @param requiredWidth The width of the target to render to
  27978. * @param requiredHeight The height of the target to render to
  27979. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27980. * @param depthStencilTexture The depth stencil texture to use to render
  27981. * @param lodLevel defines le lod level to bind to the frame buffer
  27982. */
  27983. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27984. private bindUnboundFramebuffer;
  27985. /**
  27986. * Unbind the current render target texture from the webGL context
  27987. * @param texture defines the render target texture to unbind
  27988. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27989. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27990. */
  27991. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27992. /**
  27993. * Unbind a list of render target textures from the webGL context
  27994. * This is used only when drawBuffer extension or webGL2 are active
  27995. * @param textures defines the render target textures to unbind
  27996. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27997. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27998. */
  27999. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28000. /**
  28001. * Force the mipmap generation for the given render target texture
  28002. * @param texture defines the render target texture to use
  28003. */
  28004. generateMipMapsForCubemap(texture: InternalTexture): void;
  28005. /**
  28006. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28007. */
  28008. flushFramebuffer(): void;
  28009. /**
  28010. * Unbind the current render target and bind the default framebuffer
  28011. */
  28012. restoreDefaultFramebuffer(): void;
  28013. /**
  28014. * Create an uniform buffer
  28015. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28016. * @param elements defines the content of the uniform buffer
  28017. * @returns the webGL uniform buffer
  28018. */
  28019. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28020. /**
  28021. * Create a dynamic uniform buffer
  28022. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28023. * @param elements defines the content of the uniform buffer
  28024. * @returns the webGL uniform buffer
  28025. */
  28026. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28027. /**
  28028. * Update an existing uniform buffer
  28029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28030. * @param uniformBuffer defines the target uniform buffer
  28031. * @param elements defines the content to update
  28032. * @param offset defines the offset in the uniform buffer where update should start
  28033. * @param count defines the size of the data to update
  28034. */
  28035. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28036. private _resetVertexBufferBinding;
  28037. /**
  28038. * Creates a vertex buffer
  28039. * @param data the data for the vertex buffer
  28040. * @returns the new WebGL static buffer
  28041. */
  28042. createVertexBuffer(data: DataArray): WebGLBuffer;
  28043. /**
  28044. * Creates a dynamic vertex buffer
  28045. * @param data the data for the dynamic vertex buffer
  28046. * @returns the new WebGL dynamic buffer
  28047. */
  28048. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28049. /**
  28050. * Update a dynamic index buffer
  28051. * @param indexBuffer defines the target index buffer
  28052. * @param indices defines the data to update
  28053. * @param offset defines the offset in the target index buffer where update should start
  28054. */
  28055. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28056. /**
  28057. * Updates a dynamic vertex buffer.
  28058. * @param vertexBuffer the vertex buffer to update
  28059. * @param data the data used to update the vertex buffer
  28060. * @param byteOffset the byte offset of the data
  28061. * @param byteLength the byte length of the data
  28062. */
  28063. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28064. private _resetIndexBufferBinding;
  28065. /**
  28066. * Creates a new index buffer
  28067. * @param indices defines the content of the index buffer
  28068. * @param updatable defines if the index buffer must be updatable
  28069. * @returns a new webGL buffer
  28070. */
  28071. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28072. /**
  28073. * Bind a webGL buffer to the webGL context
  28074. * @param buffer defines the buffer to bind
  28075. */
  28076. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28077. /**
  28078. * Bind an uniform buffer to the current webGL context
  28079. * @param buffer defines the buffer to bind
  28080. */
  28081. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28082. /**
  28083. * Bind a buffer to the current webGL context at a given location
  28084. * @param buffer defines the buffer to bind
  28085. * @param location defines the index where to bind the buffer
  28086. */
  28087. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28088. /**
  28089. * Bind a specific block at a given index in a specific shader program
  28090. * @param shaderProgram defines the shader program
  28091. * @param blockName defines the block name
  28092. * @param index defines the index where to bind the block
  28093. */
  28094. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28095. private bindIndexBuffer;
  28096. private bindBuffer;
  28097. /**
  28098. * update the bound buffer with the given data
  28099. * @param data defines the data to update
  28100. */
  28101. updateArrayBuffer(data: Float32Array): void;
  28102. private _vertexAttribPointer;
  28103. private _bindIndexBufferWithCache;
  28104. private _bindVertexBuffersAttributes;
  28105. /**
  28106. * Records a vertex array object
  28107. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28108. * @param vertexBuffers defines the list of vertex buffers to store
  28109. * @param indexBuffer defines the index buffer to store
  28110. * @param effect defines the effect to store
  28111. * @returns the new vertex array object
  28112. */
  28113. recordVertexArrayObject(vertexBuffers: {
  28114. [key: string]: VertexBuffer;
  28115. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28116. /**
  28117. * Bind a specific vertex array object
  28118. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28119. * @param vertexArrayObject defines the vertex array object to bind
  28120. * @param indexBuffer defines the index buffer to bind
  28121. */
  28122. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28123. /**
  28124. * Bind webGl buffers directly to the webGL context
  28125. * @param vertexBuffer defines the vertex buffer to bind
  28126. * @param indexBuffer defines the index buffer to bind
  28127. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28128. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28129. * @param effect defines the effect associated with the vertex buffer
  28130. */
  28131. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28132. private _unbindVertexArrayObject;
  28133. /**
  28134. * Bind a list of vertex buffers to the webGL context
  28135. * @param vertexBuffers defines the list of vertex buffers to bind
  28136. * @param indexBuffer defines the index buffer to bind
  28137. * @param effect defines the effect associated with the vertex buffers
  28138. */
  28139. bindBuffers(vertexBuffers: {
  28140. [key: string]: Nullable<VertexBuffer>;
  28141. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28142. /**
  28143. * Unbind all instance attributes
  28144. */
  28145. unbindInstanceAttributes(): void;
  28146. /**
  28147. * Release and free the memory of a vertex array object
  28148. * @param vao defines the vertex array object to delete
  28149. */
  28150. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28151. /** @hidden */
  28152. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28153. /**
  28154. * Creates a webGL buffer to use with instanciation
  28155. * @param capacity defines the size of the buffer
  28156. * @returns the webGL buffer
  28157. */
  28158. createInstancesBuffer(capacity: number): WebGLBuffer;
  28159. /**
  28160. * Delete a webGL buffer used with instanciation
  28161. * @param buffer defines the webGL buffer to delete
  28162. */
  28163. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28164. /**
  28165. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28166. * @param instancesBuffer defines the webGL buffer to update and bind
  28167. * @param data defines the data to store in the buffer
  28168. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28169. */
  28170. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28171. /**
  28172. * Apply all cached states (depth, culling, stencil and alpha)
  28173. */
  28174. applyStates(): void;
  28175. /**
  28176. * Send a draw order
  28177. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28178. * @param indexStart defines the starting index
  28179. * @param indexCount defines the number of index to draw
  28180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28181. */
  28182. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28183. /**
  28184. * Draw a list of points
  28185. * @param verticesStart defines the index of first vertex to draw
  28186. * @param verticesCount defines the count of vertices to draw
  28187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28188. */
  28189. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28190. /**
  28191. * Draw a list of unindexed primitives
  28192. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28193. * @param verticesStart defines the index of first vertex to draw
  28194. * @param verticesCount defines the count of vertices to draw
  28195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28196. */
  28197. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28198. /**
  28199. * Draw a list of indexed primitives
  28200. * @param fillMode defines the primitive to use
  28201. * @param indexStart defines the starting index
  28202. * @param indexCount defines the number of index to draw
  28203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28204. */
  28205. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28206. /**
  28207. * Draw a list of unindexed primitives
  28208. * @param fillMode defines the primitive to use
  28209. * @param verticesStart defines the index of first vertex to draw
  28210. * @param verticesCount defines the count of vertices to draw
  28211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28212. */
  28213. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28214. private _drawMode;
  28215. /** @hidden */
  28216. _releaseEffect(effect: Effect): void;
  28217. /** @hidden */
  28218. _deleteProgram(program: WebGLProgram): void;
  28219. /**
  28220. * Create a new effect (used to store vertex/fragment shaders)
  28221. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28222. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28223. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28224. * @param samplers defines an array of string used to represent textures
  28225. * @param defines defines the string containing the defines to use to compile the shaders
  28226. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28227. * @param onCompiled defines a function to call when the effect creation is successful
  28228. * @param onError defines a function to call when the effect creation has failed
  28229. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28230. * @returns the new Effect
  28231. */
  28232. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28233. private _compileShader;
  28234. private _compileRawShader;
  28235. /**
  28236. * Directly creates a webGL program
  28237. * @param vertexCode defines the vertex shader code to use
  28238. * @param fragmentCode defines the fragment shader code to use
  28239. * @param context defines the webGL context to use (if not set, the current one will be used)
  28240. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28241. * @returns the new webGL program
  28242. */
  28243. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28244. /**
  28245. * Creates a webGL program
  28246. * @param vertexCode defines the vertex shader code to use
  28247. * @param fragmentCode defines the fragment shader code to use
  28248. * @param defines defines the string containing the defines to use to compile the shaders
  28249. * @param context defines the webGL context to use (if not set, the current one will be used)
  28250. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28251. * @returns the new webGL program
  28252. */
  28253. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28254. private _createShaderProgram;
  28255. private _finalizeProgram;
  28256. /** @hidden */
  28257. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28258. /** @hidden */
  28259. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28260. /**
  28261. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28262. * @param shaderProgram defines the webGL program to use
  28263. * @param uniformsNames defines the list of uniform names
  28264. * @returns an array of webGL uniform locations
  28265. */
  28266. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28267. /**
  28268. * Gets the lsit of active attributes for a given webGL program
  28269. * @param shaderProgram defines the webGL program to use
  28270. * @param attributesNames defines the list of attribute names to get
  28271. * @returns an array of indices indicating the offset of each attribute
  28272. */
  28273. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28274. /**
  28275. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28276. * @param effect defines the effect to activate
  28277. */
  28278. enableEffect(effect: Nullable<Effect>): void;
  28279. /**
  28280. * Set the value of an uniform to an array of int32
  28281. * @param uniform defines the webGL uniform location where to store the value
  28282. * @param array defines the array of int32 to store
  28283. */
  28284. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28285. /**
  28286. * Set the value of an uniform to an array of int32 (stored as vec2)
  28287. * @param uniform defines the webGL uniform location where to store the value
  28288. * @param array defines the array of int32 to store
  28289. */
  28290. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28291. /**
  28292. * Set the value of an uniform to an array of int32 (stored as vec3)
  28293. * @param uniform defines the webGL uniform location where to store the value
  28294. * @param array defines the array of int32 to store
  28295. */
  28296. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28297. /**
  28298. * Set the value of an uniform to an array of int32 (stored as vec4)
  28299. * @param uniform defines the webGL uniform location where to store the value
  28300. * @param array defines the array of int32 to store
  28301. */
  28302. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28303. /**
  28304. * Set the value of an uniform to an array of float32
  28305. * @param uniform defines the webGL uniform location where to store the value
  28306. * @param array defines the array of float32 to store
  28307. */
  28308. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28309. /**
  28310. * Set the value of an uniform to an array of float32 (stored as vec2)
  28311. * @param uniform defines the webGL uniform location where to store the value
  28312. * @param array defines the array of float32 to store
  28313. */
  28314. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28315. /**
  28316. * Set the value of an uniform to an array of float32 (stored as vec3)
  28317. * @param uniform defines the webGL uniform location where to store the value
  28318. * @param array defines the array of float32 to store
  28319. */
  28320. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28321. /**
  28322. * Set the value of an uniform to an array of float32 (stored as vec4)
  28323. * @param uniform defines the webGL uniform location where to store the value
  28324. * @param array defines the array of float32 to store
  28325. */
  28326. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28327. /**
  28328. * Set the value of an uniform to an array of number
  28329. * @param uniform defines the webGL uniform location where to store the value
  28330. * @param array defines the array of number to store
  28331. */
  28332. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28333. /**
  28334. * Set the value of an uniform to an array of number (stored as vec2)
  28335. * @param uniform defines the webGL uniform location where to store the value
  28336. * @param array defines the array of number to store
  28337. */
  28338. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28339. /**
  28340. * Set the value of an uniform to an array of number (stored as vec3)
  28341. * @param uniform defines the webGL uniform location where to store the value
  28342. * @param array defines the array of number to store
  28343. */
  28344. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28345. /**
  28346. * Set the value of an uniform to an array of number (stored as vec4)
  28347. * @param uniform defines the webGL uniform location where to store the value
  28348. * @param array defines the array of number to store
  28349. */
  28350. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28351. /**
  28352. * Set the value of an uniform to an array of float32 (stored as matrices)
  28353. * @param uniform defines the webGL uniform location where to store the value
  28354. * @param matrices defines the array of float32 to store
  28355. */
  28356. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28357. /**
  28358. * Set the value of an uniform to a matrix
  28359. * @param uniform defines the webGL uniform location where to store the value
  28360. * @param matrix defines the matrix to store
  28361. */
  28362. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28363. /**
  28364. * Set the value of an uniform to a matrix (3x3)
  28365. * @param uniform defines the webGL uniform location where to store the value
  28366. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28367. */
  28368. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28369. /**
  28370. * Set the value of an uniform to a matrix (2x2)
  28371. * @param uniform defines the webGL uniform location where to store the value
  28372. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28373. */
  28374. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28375. /**
  28376. * Set the value of an uniform to a number (int)
  28377. * @param uniform defines the webGL uniform location where to store the value
  28378. * @param value defines the int number to store
  28379. */
  28380. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28381. /**
  28382. * Set the value of an uniform to a number (float)
  28383. * @param uniform defines the webGL uniform location where to store the value
  28384. * @param value defines the float number to store
  28385. */
  28386. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28387. /**
  28388. * Set the value of an uniform to a vec2
  28389. * @param uniform defines the webGL uniform location where to store the value
  28390. * @param x defines the 1st component of the value
  28391. * @param y defines the 2nd component of the value
  28392. */
  28393. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28394. /**
  28395. * Set the value of an uniform to a vec3
  28396. * @param uniform defines the webGL uniform location where to store the value
  28397. * @param x defines the 1st component of the value
  28398. * @param y defines the 2nd component of the value
  28399. * @param z defines the 3rd component of the value
  28400. */
  28401. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28402. /**
  28403. * Set the value of an uniform to a boolean
  28404. * @param uniform defines the webGL uniform location where to store the value
  28405. * @param bool defines the boolean to store
  28406. */
  28407. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28408. /**
  28409. * Set the value of an uniform to a vec4
  28410. * @param uniform defines the webGL uniform location where to store the value
  28411. * @param x defines the 1st component of the value
  28412. * @param y defines the 2nd component of the value
  28413. * @param z defines the 3rd component of the value
  28414. * @param w defines the 4th component of the value
  28415. */
  28416. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28417. /**
  28418. * Set the value of an uniform to a Color3
  28419. * @param uniform defines the webGL uniform location where to store the value
  28420. * @param color3 defines the color to store
  28421. */
  28422. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28423. /**
  28424. * Set the value of an uniform to a Color3 and an alpha value
  28425. * @param uniform defines the webGL uniform location where to store the value
  28426. * @param color3 defines the color to store
  28427. * @param alpha defines the alpha component to store
  28428. */
  28429. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28430. /**
  28431. * Sets a Color4 on a uniform variable
  28432. * @param uniform defines the uniform location
  28433. * @param color4 defines the value to be set
  28434. */
  28435. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28436. /**
  28437. * Set various states to the webGL context
  28438. * @param culling defines backface culling state
  28439. * @param zOffset defines the value to apply to zOffset (0 by default)
  28440. * @param force defines if states must be applied even if cache is up to date
  28441. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28442. */
  28443. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28444. /**
  28445. * Set the z offset to apply to current rendering
  28446. * @param value defines the offset to apply
  28447. */
  28448. setZOffset(value: number): void;
  28449. /**
  28450. * Gets the current value of the zOffset
  28451. * @returns the current zOffset state
  28452. */
  28453. getZOffset(): number;
  28454. /**
  28455. * Enable or disable depth buffering
  28456. * @param enable defines the state to set
  28457. */
  28458. setDepthBuffer(enable: boolean): void;
  28459. /**
  28460. * Gets a boolean indicating if depth writing is enabled
  28461. * @returns the current depth writing state
  28462. */
  28463. getDepthWrite(): boolean;
  28464. /**
  28465. * Enable or disable depth writing
  28466. * @param enable defines the state to set
  28467. */
  28468. setDepthWrite(enable: boolean): void;
  28469. /**
  28470. * Enable or disable color writing
  28471. * @param enable defines the state to set
  28472. */
  28473. setColorWrite(enable: boolean): void;
  28474. /**
  28475. * Gets a boolean indicating if color writing is enabled
  28476. * @returns the current color writing state
  28477. */
  28478. getColorWrite(): boolean;
  28479. /**
  28480. * Sets alpha constants used by some alpha blending modes
  28481. * @param r defines the red component
  28482. * @param g defines the green component
  28483. * @param b defines the blue component
  28484. * @param a defines the alpha component
  28485. */
  28486. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28487. /**
  28488. * Sets the current alpha mode
  28489. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28490. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28492. */
  28493. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28494. /**
  28495. * Gets the current alpha mode
  28496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28497. * @returns the current alpha mode
  28498. */
  28499. getAlphaMode(): number;
  28500. /**
  28501. * Clears the list of texture accessible through engine.
  28502. * This can help preventing texture load conflict due to name collision.
  28503. */
  28504. clearInternalTexturesCache(): void;
  28505. /**
  28506. * Force the entire cache to be cleared
  28507. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28508. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28509. */
  28510. wipeCaches(bruteForce?: boolean): void;
  28511. /**
  28512. * Set the compressed texture format to use, based on the formats you have, and the formats
  28513. * supported by the hardware / browser.
  28514. *
  28515. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28516. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28517. * to API arguments needed to compressed textures. This puts the burden on the container
  28518. * generator to house the arcane code for determining these for current & future formats.
  28519. *
  28520. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28521. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28522. *
  28523. * Note: The result of this call is not taken into account when a texture is base64.
  28524. *
  28525. * @param formatsAvailable defines the list of those format families you have created
  28526. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28527. *
  28528. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28529. * @returns The extension selected.
  28530. */
  28531. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28532. private _getSamplingParameters;
  28533. private _partialLoadImg;
  28534. private _cascadeLoadImgs;
  28535. /** @hidden */
  28536. _createTexture(): WebGLTexture;
  28537. /**
  28538. * Usually called from Texture.ts.
  28539. * Passed information to create a WebGLTexture
  28540. * @param urlArg defines a value which contains one of the following:
  28541. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28542. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28543. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28544. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28545. * @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)
  28546. * @param scene needed for loading to the correct scene
  28547. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28548. * @param onLoad optional callback to be called upon successful completion
  28549. * @param onError optional callback to be called upon failure
  28550. * @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
  28551. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28552. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28553. * @param forcedExtension defines the extension to use to pick the right loader
  28554. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28556. */
  28557. 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;
  28558. private _rescaleTexture;
  28559. /**
  28560. * Update a raw texture
  28561. * @param texture defines the texture to update
  28562. * @param data defines the data to store in the texture
  28563. * @param format defines the format of the data
  28564. * @param invertY defines if data must be stored with Y axis inverted
  28565. * @param compression defines the compression used (null by default)
  28566. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28567. */
  28568. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28569. /**
  28570. * Creates a raw texture
  28571. * @param data defines the data to store in the texture
  28572. * @param width defines the width of the texture
  28573. * @param height defines the height of the texture
  28574. * @param format defines the format of the data
  28575. * @param generateMipMaps defines if the engine should generate the mip levels
  28576. * @param invertY defines if data must be stored with Y axis inverted
  28577. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28578. * @param compression defines the compression used (null by default)
  28579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28580. * @returns the raw texture inside an InternalTexture
  28581. */
  28582. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28583. private _unpackFlipYCached;
  28584. /**
  28585. * In case you are sharing the context with other applications, it might
  28586. * be interested to not cache the unpack flip y state to ensure a consistent
  28587. * value would be set.
  28588. */
  28589. enableUnpackFlipYCached: boolean;
  28590. /** @hidden */
  28591. _unpackFlipY(value: boolean): void;
  28592. /** @hidden */
  28593. _getUnpackAlignement(): number;
  28594. /**
  28595. * Creates a dynamic texture
  28596. * @param width defines the width of the texture
  28597. * @param height defines the height of the texture
  28598. * @param generateMipMaps defines if the engine should generate the mip levels
  28599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28600. * @returns the dynamic texture inside an InternalTexture
  28601. */
  28602. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28603. /**
  28604. * Update the sampling mode of a given texture
  28605. * @param samplingMode defines the required sampling mode
  28606. * @param texture defines the texture to update
  28607. */
  28608. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28609. /**
  28610. * Update the content of a dynamic texture
  28611. * @param texture defines the texture to update
  28612. * @param canvas defines the canvas containing the source
  28613. * @param invertY defines if data must be stored with Y axis inverted
  28614. * @param premulAlpha defines if alpha is stored as premultiplied
  28615. * @param format defines the format of the data
  28616. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28617. */
  28618. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28619. /**
  28620. * Update a video texture
  28621. * @param texture defines the texture to update
  28622. * @param video defines the video element to use
  28623. * @param invertY defines if data must be stored with Y axis inverted
  28624. */
  28625. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28626. /**
  28627. * Updates a depth texture Comparison Mode and Function.
  28628. * If the comparison Function is equal to 0, the mode will be set to none.
  28629. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28630. * @param texture The texture to set the comparison function for
  28631. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28632. */
  28633. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28634. private _setupDepthStencilTexture;
  28635. /**
  28636. * Creates a depth stencil texture.
  28637. * This is only available in WebGL 2 or with the depth texture extension available.
  28638. * @param size The size of face edge in the texture.
  28639. * @param options The options defining the texture.
  28640. * @returns The texture
  28641. */
  28642. createDepthStencilTexture(size: number | {
  28643. width: number;
  28644. height: number;
  28645. }, options: DepthTextureCreationOptions): InternalTexture;
  28646. /**
  28647. * Creates a depth stencil texture.
  28648. * This is only available in WebGL 2 or with the depth texture extension available.
  28649. * @param size The size of face edge in the texture.
  28650. * @param options The options defining the texture.
  28651. * @returns The texture
  28652. */
  28653. private _createDepthStencilTexture;
  28654. /**
  28655. * Creates a depth stencil cube texture.
  28656. * This is only available in WebGL 2.
  28657. * @param size The size of face edge in the cube texture.
  28658. * @param options The options defining the cube texture.
  28659. * @returns The cube texture
  28660. */
  28661. private _createDepthStencilCubeTexture;
  28662. /**
  28663. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28664. * @param renderTarget The render target to set the frame buffer for
  28665. */
  28666. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28667. /**
  28668. * Creates a new render target texture
  28669. * @param size defines the size of the texture
  28670. * @param options defines the options used to create the texture
  28671. * @returns a new render target texture stored in an InternalTexture
  28672. */
  28673. createRenderTargetTexture(size: number | {
  28674. width: number;
  28675. height: number;
  28676. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28677. /**
  28678. * Create a multi render target texture
  28679. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28680. * @param size defines the size of the texture
  28681. * @param options defines the creation options
  28682. * @returns the cube texture as an InternalTexture
  28683. */
  28684. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28685. private _setupFramebufferDepthAttachments;
  28686. /**
  28687. * Updates the sample count of a render target texture
  28688. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28689. * @param texture defines the texture to update
  28690. * @param samples defines the sample count to set
  28691. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28692. */
  28693. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28694. /**
  28695. * Update the sample count for a given multiple render target texture
  28696. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28697. * @param textures defines the textures to update
  28698. * @param samples defines the sample count to set
  28699. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28700. */
  28701. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28702. /** @hidden */
  28703. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28704. /** @hidden */
  28705. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28706. /** @hidden */
  28707. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28708. /** @hidden */
  28709. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28710. /**
  28711. * Creates a new render target cube texture
  28712. * @param size defines the size of the texture
  28713. * @param options defines the options used to create the texture
  28714. * @returns a new render target cube texture stored in an InternalTexture
  28715. */
  28716. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28717. /**
  28718. * Creates a cube texture
  28719. * @param rootUrl defines the url where the files to load is located
  28720. * @param scene defines the current scene
  28721. * @param files defines the list of files to load (1 per face)
  28722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28723. * @param onLoad defines an optional callback raised when the texture is loaded
  28724. * @param onError defines an optional callback raised if there is an issue to load the texture
  28725. * @param format defines the format of the data
  28726. * @param forcedExtension defines the extension to use to pick the right loader
  28727. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28728. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28729. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28730. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28731. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28732. * @returns the cube texture as an InternalTexture
  28733. */
  28734. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28735. /**
  28736. * @hidden
  28737. */
  28738. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28739. /**
  28740. * Update a raw cube texture
  28741. * @param texture defines the texture to udpdate
  28742. * @param data defines the data to store
  28743. * @param format defines the data format
  28744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28745. * @param invertY defines if data must be stored with Y axis inverted
  28746. * @param compression defines the compression used (null by default)
  28747. * @param level defines which level of the texture to update
  28748. */
  28749. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28750. /**
  28751. * Creates a new raw cube texture
  28752. * @param data defines the array of data to use to create each face
  28753. * @param size defines the size of the textures
  28754. * @param format defines the format of the data
  28755. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28756. * @param generateMipMaps defines if the engine should generate the mip levels
  28757. * @param invertY defines if data must be stored with Y axis inverted
  28758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28759. * @param compression defines the compression used (null by default)
  28760. * @returns the cube texture as an InternalTexture
  28761. */
  28762. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28763. /**
  28764. * Creates a new raw cube texture from a specified url
  28765. * @param url defines the url where the data is located
  28766. * @param scene defines the current scene
  28767. * @param size defines the size of the textures
  28768. * @param format defines the format of the data
  28769. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28770. * @param noMipmap defines if the engine should avoid generating the mip levels
  28771. * @param callback defines a callback used to extract texture data from loaded data
  28772. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28773. * @param onLoad defines a callback called when texture is loaded
  28774. * @param onError defines a callback called if there is an error
  28775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28776. * @param invertY defines if data must be stored with Y axis inverted
  28777. * @returns the cube texture as an InternalTexture
  28778. */
  28779. 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;
  28780. /**
  28781. * Update a raw 3D texture
  28782. * @param texture defines the texture to update
  28783. * @param data defines the data to store
  28784. * @param format defines the data format
  28785. * @param invertY defines if data must be stored with Y axis inverted
  28786. * @param compression defines the used compression (can be null)
  28787. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28788. */
  28789. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28790. /**
  28791. * Creates a new raw 3D texture
  28792. * @param data defines the data used to create the texture
  28793. * @param width defines the width of the texture
  28794. * @param height defines the height of the texture
  28795. * @param depth defines the depth of the texture
  28796. * @param format defines the format of the texture
  28797. * @param generateMipMaps defines if the engine must generate mip levels
  28798. * @param invertY defines if data must be stored with Y axis inverted
  28799. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28800. * @param compression defines the compressed used (can be null)
  28801. * @param textureType defines the compressed used (can be null)
  28802. * @returns a new raw 3D texture (stored in an InternalTexture)
  28803. */
  28804. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28805. private _prepareWebGLTextureContinuation;
  28806. private _prepareWebGLTexture;
  28807. private _convertRGBtoRGBATextureData;
  28808. /** @hidden */
  28809. _releaseFramebufferObjects(texture: InternalTexture): void;
  28810. /** @hidden */
  28811. _releaseTexture(texture: InternalTexture): void;
  28812. private setProgram;
  28813. private _boundUniforms;
  28814. /**
  28815. * Binds an effect to the webGL context
  28816. * @param effect defines the effect to bind
  28817. */
  28818. bindSamplers(effect: Effect): void;
  28819. private _moveBoundTextureOnTop;
  28820. private _getCorrectTextureChannel;
  28821. private _linkTrackers;
  28822. private _removeDesignatedSlot;
  28823. private _activateCurrentTexture;
  28824. /** @hidden */
  28825. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28826. /** @hidden */
  28827. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28828. /**
  28829. * Sets a texture to the webGL context from a postprocess
  28830. * @param channel defines the channel to use
  28831. * @param postProcess defines the source postprocess
  28832. */
  28833. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28834. /**
  28835. * Binds the output of the passed in post process to the texture channel specified
  28836. * @param channel The channel the texture should be bound to
  28837. * @param postProcess The post process which's output should be bound
  28838. */
  28839. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28840. /**
  28841. * Unbind all textures from the webGL context
  28842. */
  28843. unbindAllTextures(): void;
  28844. /**
  28845. * Sets a texture to the according uniform.
  28846. * @param channel The texture channel
  28847. * @param uniform The uniform to set
  28848. * @param texture The texture to apply
  28849. */
  28850. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28851. /**
  28852. * Sets a depth stencil texture from a render target to the according uniform.
  28853. * @param channel The texture channel
  28854. * @param uniform The uniform to set
  28855. * @param texture The render target texture containing the depth stencil texture to apply
  28856. */
  28857. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28858. private _bindSamplerUniformToChannel;
  28859. private _getTextureWrapMode;
  28860. private _setTexture;
  28861. /**
  28862. * Sets an array of texture to the webGL context
  28863. * @param channel defines the channel where the texture array must be set
  28864. * @param uniform defines the associated uniform location
  28865. * @param textures defines the array of textures to bind
  28866. */
  28867. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28868. /** @hidden */
  28869. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28870. private _setTextureParameterFloat;
  28871. private _setTextureParameterInteger;
  28872. /**
  28873. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28874. * @param x defines the x coordinate of the rectangle where pixels must be read
  28875. * @param y defines the y coordinate of the rectangle where pixels must be read
  28876. * @param width defines the width of the rectangle where pixels must be read
  28877. * @param height defines the height of the rectangle where pixels must be read
  28878. * @returns a Uint8Array containing RGBA colors
  28879. */
  28880. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28881. /**
  28882. * Add an externaly attached data from its key.
  28883. * This method call will fail and return false, if such key already exists.
  28884. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28885. * @param key the unique key that identifies the data
  28886. * @param data the data object to associate to the key for this Engine instance
  28887. * @return true if no such key were already present and the data was added successfully, false otherwise
  28888. */
  28889. addExternalData<T>(key: string, data: T): boolean;
  28890. /**
  28891. * Get an externaly attached data from its key
  28892. * @param key the unique key that identifies the data
  28893. * @return the associated data, if present (can be null), or undefined if not present
  28894. */
  28895. getExternalData<T>(key: string): T;
  28896. /**
  28897. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28898. * @param key the unique key that identifies the data
  28899. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28900. * @return the associated data, can be null if the factory returned null.
  28901. */
  28902. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28903. /**
  28904. * Remove an externaly attached data from the Engine instance
  28905. * @param key the unique key that identifies the data
  28906. * @return true if the data was successfully removed, false if it doesn't exist
  28907. */
  28908. removeExternalData(key: string): boolean;
  28909. /**
  28910. * Unbind all vertex attributes from the webGL context
  28911. */
  28912. unbindAllAttributes(): void;
  28913. /**
  28914. * 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
  28915. */
  28916. releaseEffects(): void;
  28917. /**
  28918. * Dispose and release all associated resources
  28919. */
  28920. dispose(): void;
  28921. /**
  28922. * Display the loading screen
  28923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28924. */
  28925. displayLoadingUI(): void;
  28926. /**
  28927. * Hide the loading screen
  28928. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28929. */
  28930. hideLoadingUI(): void;
  28931. /**
  28932. * Gets the current loading screen object
  28933. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28934. */
  28935. /**
  28936. * Sets the current loading screen object
  28937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28938. */
  28939. loadingScreen: ILoadingScreen;
  28940. /**
  28941. * Sets the current loading screen text
  28942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28943. */
  28944. loadingUIText: string;
  28945. /**
  28946. * Sets the current loading screen background color
  28947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28948. */
  28949. loadingUIBackgroundColor: string;
  28950. /**
  28951. * Attach a new callback raised when context lost event is fired
  28952. * @param callback defines the callback to call
  28953. */
  28954. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28955. /**
  28956. * Attach a new callback raised when context restored event is fired
  28957. * @param callback defines the callback to call
  28958. */
  28959. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28960. /**
  28961. * Gets the source code of the vertex shader associated with a specific webGL program
  28962. * @param program defines the program to use
  28963. * @returns a string containing the source code of the vertex shader associated with the program
  28964. */
  28965. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28966. /**
  28967. * Gets the source code of the fragment shader associated with a specific webGL program
  28968. * @param program defines the program to use
  28969. * @returns a string containing the source code of the fragment shader associated with the program
  28970. */
  28971. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28972. /**
  28973. * Get the current error code of the webGL context
  28974. * @returns the error code
  28975. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28976. */
  28977. getError(): number;
  28978. /**
  28979. * Gets the current framerate
  28980. * @returns a number representing the framerate
  28981. */
  28982. getFps(): number;
  28983. /**
  28984. * Gets the time spent between current and previous frame
  28985. * @returns a number representing the delta time in ms
  28986. */
  28987. getDeltaTime(): number;
  28988. private _measureFps;
  28989. /** @hidden */
  28990. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28991. private _canRenderToFloatFramebuffer;
  28992. private _canRenderToHalfFloatFramebuffer;
  28993. private _canRenderToFramebuffer;
  28994. /** @hidden */
  28995. _getWebGLTextureType(type: number): number;
  28996. private _getInternalFormat;
  28997. /** @hidden */
  28998. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28999. /** @hidden */
  29000. _getRGBAMultiSampleBufferFormat(type: number): number;
  29001. /** @hidden */
  29002. _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;
  29003. /** @hidden */
  29004. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29005. private _partialLoadFile;
  29006. private _cascadeLoadFiles;
  29007. /**
  29008. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29009. * @returns true if the engine can be created
  29010. * @ignorenaming
  29011. */
  29012. static isSupported(): boolean;
  29013. }
  29014. }
  29015. declare module "babylonjs/Materials/effect" {
  29016. import { Observable } from "babylonjs/Misc/observable";
  29017. import { Nullable } from "babylonjs/types";
  29018. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29019. import { Engine } from "babylonjs/Engines/engine";
  29020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29023. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29025. /**
  29026. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29027. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29028. */
  29029. export class EffectFallbacks {
  29030. private _defines;
  29031. private _currentRank;
  29032. private _maxRank;
  29033. private _mesh;
  29034. /**
  29035. * Removes the fallback from the bound mesh.
  29036. */
  29037. unBindMesh(): void;
  29038. /**
  29039. * Adds a fallback on the specified property.
  29040. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29041. * @param define The name of the define in the shader
  29042. */
  29043. addFallback(rank: number, define: string): void;
  29044. /**
  29045. * Sets the mesh to use CPU skinning when needing to fallback.
  29046. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29047. * @param mesh The mesh to use the fallbacks.
  29048. */
  29049. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29050. /**
  29051. * Checks to see if more fallbacks are still availible.
  29052. */
  29053. readonly isMoreFallbacks: boolean;
  29054. /**
  29055. * Removes the defines that shoould be removed when falling back.
  29056. * @param currentDefines defines the current define statements for the shader.
  29057. * @param effect defines the current effect we try to compile
  29058. * @returns The resulting defines with defines of the current rank removed.
  29059. */
  29060. reduce(currentDefines: string, effect: Effect): string;
  29061. }
  29062. /**
  29063. * Options to be used when creating an effect.
  29064. */
  29065. export class EffectCreationOptions {
  29066. /**
  29067. * Atrributes that will be used in the shader.
  29068. */
  29069. attributes: string[];
  29070. /**
  29071. * Uniform varible names that will be set in the shader.
  29072. */
  29073. uniformsNames: string[];
  29074. /**
  29075. * Uniform buffer varible names that will be set in the shader.
  29076. */
  29077. uniformBuffersNames: string[];
  29078. /**
  29079. * Sampler texture variable names that will be set in the shader.
  29080. */
  29081. samplers: string[];
  29082. /**
  29083. * Define statements that will be set in the shader.
  29084. */
  29085. defines: any;
  29086. /**
  29087. * Possible fallbacks for this effect to improve performance when needed.
  29088. */
  29089. fallbacks: Nullable<EffectFallbacks>;
  29090. /**
  29091. * Callback that will be called when the shader is compiled.
  29092. */
  29093. onCompiled: Nullable<(effect: Effect) => void>;
  29094. /**
  29095. * Callback that will be called if an error occurs during shader compilation.
  29096. */
  29097. onError: Nullable<(effect: Effect, errors: string) => void>;
  29098. /**
  29099. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29100. */
  29101. indexParameters: any;
  29102. /**
  29103. * Max number of lights that can be used in the shader.
  29104. */
  29105. maxSimultaneousLights: number;
  29106. /**
  29107. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29108. */
  29109. transformFeedbackVaryings: Nullable<string[]>;
  29110. }
  29111. /**
  29112. * Effect containing vertex and fragment shader that can be executed on an object.
  29113. */
  29114. export class Effect {
  29115. /**
  29116. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29117. */
  29118. static ShadersRepository: string;
  29119. /**
  29120. * Name of the effect.
  29121. */
  29122. name: any;
  29123. /**
  29124. * String container all the define statements that should be set on the shader.
  29125. */
  29126. defines: string;
  29127. /**
  29128. * Callback that will be called when the shader is compiled.
  29129. */
  29130. onCompiled: Nullable<(effect: Effect) => void>;
  29131. /**
  29132. * Callback that will be called if an error occurs during shader compilation.
  29133. */
  29134. onError: Nullable<(effect: Effect, errors: string) => void>;
  29135. /**
  29136. * Callback that will be called when effect is bound.
  29137. */
  29138. onBind: Nullable<(effect: Effect) => void>;
  29139. /**
  29140. * Unique ID of the effect.
  29141. */
  29142. uniqueId: number;
  29143. /**
  29144. * Observable that will be called when the shader is compiled.
  29145. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29146. */
  29147. onCompileObservable: Observable<Effect>;
  29148. /**
  29149. * Observable that will be called if an error occurs during shader compilation.
  29150. */
  29151. onErrorObservable: Observable<Effect>;
  29152. /** @hidden */
  29153. _onBindObservable: Nullable<Observable<Effect>>;
  29154. /**
  29155. * Observable that will be called when effect is bound.
  29156. */
  29157. readonly onBindObservable: Observable<Effect>;
  29158. /** @hidden */
  29159. _bonesComputationForcedToCPU: boolean;
  29160. private static _uniqueIdSeed;
  29161. private _engine;
  29162. private _uniformBuffersNames;
  29163. private _uniformsNames;
  29164. private _samplers;
  29165. private _isReady;
  29166. private _compilationError;
  29167. private _attributesNames;
  29168. private _attributes;
  29169. private _uniforms;
  29170. /**
  29171. * Key for the effect.
  29172. * @hidden
  29173. */
  29174. _key: string;
  29175. private _indexParameters;
  29176. private _fallbacks;
  29177. private _vertexSourceCode;
  29178. private _fragmentSourceCode;
  29179. private _vertexSourceCodeOverride;
  29180. private _fragmentSourceCodeOverride;
  29181. private _transformFeedbackVaryings;
  29182. /**
  29183. * Compiled shader to webGL program.
  29184. * @hidden
  29185. */
  29186. _program: WebGLProgram;
  29187. private _valueCache;
  29188. private static _baseCache;
  29189. /**
  29190. * Instantiates an effect.
  29191. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29192. * @param baseName Name of the effect.
  29193. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29194. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29195. * @param samplers List of sampler variables that will be passed to the shader.
  29196. * @param engine Engine to be used to render the effect
  29197. * @param defines Define statements to be added to the shader.
  29198. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29199. * @param onCompiled Callback that will be called when the shader is compiled.
  29200. * @param onError Callback that will be called if an error occurs during shader compilation.
  29201. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29202. */
  29203. 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);
  29204. /**
  29205. * Unique key for this effect
  29206. */
  29207. readonly key: string;
  29208. /**
  29209. * If the effect has been compiled and prepared.
  29210. * @returns if the effect is compiled and prepared.
  29211. */
  29212. isReady(): boolean;
  29213. /**
  29214. * The engine the effect was initialized with.
  29215. * @returns the engine.
  29216. */
  29217. getEngine(): Engine;
  29218. /**
  29219. * The compiled webGL program for the effect
  29220. * @returns the webGL program.
  29221. */
  29222. getProgram(): WebGLProgram;
  29223. /**
  29224. * The set of names of attribute variables for the shader.
  29225. * @returns An array of attribute names.
  29226. */
  29227. getAttributesNames(): string[];
  29228. /**
  29229. * Returns the attribute at the given index.
  29230. * @param index The index of the attribute.
  29231. * @returns The location of the attribute.
  29232. */
  29233. getAttributeLocation(index: number): number;
  29234. /**
  29235. * Returns the attribute based on the name of the variable.
  29236. * @param name of the attribute to look up.
  29237. * @returns the attribute location.
  29238. */
  29239. getAttributeLocationByName(name: string): number;
  29240. /**
  29241. * The number of attributes.
  29242. * @returns the numnber of attributes.
  29243. */
  29244. getAttributesCount(): number;
  29245. /**
  29246. * Gets the index of a uniform variable.
  29247. * @param uniformName of the uniform to look up.
  29248. * @returns the index.
  29249. */
  29250. getUniformIndex(uniformName: string): number;
  29251. /**
  29252. * Returns the attribute based on the name of the variable.
  29253. * @param uniformName of the uniform to look up.
  29254. * @returns the location of the uniform.
  29255. */
  29256. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29257. /**
  29258. * Returns an array of sampler variable names
  29259. * @returns The array of sampler variable neames.
  29260. */
  29261. getSamplers(): string[];
  29262. /**
  29263. * The error from the last compilation.
  29264. * @returns the error string.
  29265. */
  29266. getCompilationError(): string;
  29267. /**
  29268. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29269. * @param func The callback to be used.
  29270. */
  29271. executeWhenCompiled(func: (effect: Effect) => void): void;
  29272. private _checkIsReady;
  29273. /** @hidden */
  29274. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29275. /** @hidden */
  29276. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29277. /** @hidden */
  29278. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29279. private _processShaderConversion;
  29280. private _processIncludes;
  29281. private _processPrecision;
  29282. /**
  29283. * Recompiles the webGL program
  29284. * @param vertexSourceCode The source code for the vertex shader.
  29285. * @param fragmentSourceCode The source code for the fragment shader.
  29286. * @param onCompiled Callback called when completed.
  29287. * @param onError Callback called on error.
  29288. * @hidden
  29289. */
  29290. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29291. /**
  29292. * Gets the uniform locations of the the specified variable names
  29293. * @param names THe names of the variables to lookup.
  29294. * @returns Array of locations in the same order as variable names.
  29295. */
  29296. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29297. /**
  29298. * Prepares the effect
  29299. * @hidden
  29300. */
  29301. _prepareEffect(): void;
  29302. /**
  29303. * Checks if the effect is supported. (Must be called after compilation)
  29304. */
  29305. readonly isSupported: boolean;
  29306. /**
  29307. * Binds a texture to the engine to be used as output of the shader.
  29308. * @param channel Name of the output variable.
  29309. * @param texture Texture to bind.
  29310. * @hidden
  29311. */
  29312. _bindTexture(channel: string, texture: InternalTexture): void;
  29313. /**
  29314. * Sets a texture on the engine to be used in the shader.
  29315. * @param channel Name of the sampler variable.
  29316. * @param texture Texture to set.
  29317. */
  29318. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29319. /**
  29320. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29321. * @param channel Name of the sampler variable.
  29322. * @param texture Texture to set.
  29323. */
  29324. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29325. /**
  29326. * Sets an array of textures on the engine to be used in the shader.
  29327. * @param channel Name of the variable.
  29328. * @param textures Textures to set.
  29329. */
  29330. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29331. /**
  29332. * 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)
  29333. * @param channel Name of the sampler variable.
  29334. * @param postProcess Post process to get the input texture from.
  29335. */
  29336. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29337. /**
  29338. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29339. * 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)
  29340. * @param channel Name of the sampler variable.
  29341. * @param postProcess Post process to get the output texture from.
  29342. */
  29343. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29344. /** @hidden */
  29345. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29346. /** @hidden */
  29347. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29348. /** @hidden */
  29349. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29350. /** @hidden */
  29351. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29352. /**
  29353. * Binds a buffer to a uniform.
  29354. * @param buffer Buffer to bind.
  29355. * @param name Name of the uniform variable to bind to.
  29356. */
  29357. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29358. /**
  29359. * Binds block to a uniform.
  29360. * @param blockName Name of the block to bind.
  29361. * @param index Index to bind.
  29362. */
  29363. bindUniformBlock(blockName: string, index: number): void;
  29364. /**
  29365. * Sets an interger value on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param value Value to be set.
  29368. * @returns this effect.
  29369. */
  29370. setInt(uniformName: string, value: number): Effect;
  29371. /**
  29372. * Sets an int array on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setIntArray(uniformName: string, array: Int32Array): Effect;
  29378. /**
  29379. * 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)
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29392. /**
  29393. * 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)
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29399. /**
  29400. * Sets an float array on a uniform variable.
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29406. /**
  29407. * 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)
  29408. * @param uniformName Name of the variable.
  29409. * @param array array to be set.
  29410. * @returns this effect.
  29411. */
  29412. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29413. /**
  29414. * 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)
  29415. * @param uniformName Name of the variable.
  29416. * @param array array to be set.
  29417. * @returns this effect.
  29418. */
  29419. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29420. /**
  29421. * 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)
  29422. * @param uniformName Name of the variable.
  29423. * @param array array to be set.
  29424. * @returns this effect.
  29425. */
  29426. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29427. /**
  29428. * Sets an array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setArray(uniformName: string, array: number[]): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setArray2(uniformName: string, array: number[]): Effect;
  29441. /**
  29442. * 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)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setArray3(uniformName: string, array: number[]): Effect;
  29448. /**
  29449. * 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)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setArray4(uniformName: string, array: number[]): Effect;
  29455. /**
  29456. * Sets matrices on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param matrices matrices to be set.
  29459. * @returns this effect.
  29460. */
  29461. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29462. /**
  29463. * Sets matrix on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param matrix matrix to be set.
  29466. * @returns this effect.
  29467. */
  29468. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29469. /**
  29470. * 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)
  29471. * @param uniformName Name of the variable.
  29472. * @param matrix matrix to be set.
  29473. * @returns this effect.
  29474. */
  29475. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29476. /**
  29477. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29478. * @param uniformName Name of the variable.
  29479. * @param matrix matrix to be set.
  29480. * @returns this effect.
  29481. */
  29482. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29483. /**
  29484. * Sets a float on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param value value to be set.
  29487. * @returns this effect.
  29488. */
  29489. setFloat(uniformName: string, value: number): Effect;
  29490. /**
  29491. * Sets a boolean on a uniform variable.
  29492. * @param uniformName Name of the variable.
  29493. * @param bool value to be set.
  29494. * @returns this effect.
  29495. */
  29496. setBool(uniformName: string, bool: boolean): Effect;
  29497. /**
  29498. * Sets a Vector2 on a uniform variable.
  29499. * @param uniformName Name of the variable.
  29500. * @param vector2 vector2 to be set.
  29501. * @returns this effect.
  29502. */
  29503. setVector2(uniformName: string, vector2: Vector2): Effect;
  29504. /**
  29505. * Sets a float2 on a uniform variable.
  29506. * @param uniformName Name of the variable.
  29507. * @param x First float in float2.
  29508. * @param y Second float in float2.
  29509. * @returns this effect.
  29510. */
  29511. setFloat2(uniformName: string, x: number, y: number): Effect;
  29512. /**
  29513. * Sets a Vector3 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param vector3 Value to be set.
  29516. * @returns this effect.
  29517. */
  29518. setVector3(uniformName: string, vector3: Vector3): Effect;
  29519. /**
  29520. * Sets a float3 on a uniform variable.
  29521. * @param uniformName Name of the variable.
  29522. * @param x First float in float3.
  29523. * @param y Second float in float3.
  29524. * @param z Third float in float3.
  29525. * @returns this effect.
  29526. */
  29527. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29528. /**
  29529. * Sets a Vector4 on a uniform variable.
  29530. * @param uniformName Name of the variable.
  29531. * @param vector4 Value to be set.
  29532. * @returns this effect.
  29533. */
  29534. setVector4(uniformName: string, vector4: Vector4): Effect;
  29535. /**
  29536. * Sets a float4 on a uniform variable.
  29537. * @param uniformName Name of the variable.
  29538. * @param x First float in float4.
  29539. * @param y Second float in float4.
  29540. * @param z Third float in float4.
  29541. * @param w Fourth float in float4.
  29542. * @returns this effect.
  29543. */
  29544. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29545. /**
  29546. * Sets a Color3 on a uniform variable.
  29547. * @param uniformName Name of the variable.
  29548. * @param color3 Value to be set.
  29549. * @returns this effect.
  29550. */
  29551. setColor3(uniformName: string, color3: Color3): Effect;
  29552. /**
  29553. * Sets a Color4 on a uniform variable.
  29554. * @param uniformName Name of the variable.
  29555. * @param color3 Value to be set.
  29556. * @param alpha Alpha value to be set.
  29557. * @returns this effect.
  29558. */
  29559. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29560. /**
  29561. * Sets a Color4 on a uniform variable
  29562. * @param uniformName defines the name of the variable
  29563. * @param color4 defines the value to be set
  29564. * @returns this effect.
  29565. */
  29566. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29567. /**
  29568. * This function will add a new shader to the shader store
  29569. * @param name the name of the shader
  29570. * @param pixelShader optional pixel shader content
  29571. * @param vertexShader optional vertex shader content
  29572. */
  29573. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29574. /**
  29575. * Store of each shader (The can be looked up using effect.key)
  29576. */
  29577. static ShadersStore: {
  29578. [key: string]: string;
  29579. };
  29580. /**
  29581. * Store of each included file for a shader (The can be looked up using effect.key)
  29582. */
  29583. static IncludesShadersStore: {
  29584. [key: string]: string;
  29585. };
  29586. /**
  29587. * Resets the cache of effects.
  29588. */
  29589. static ResetCache(): void;
  29590. }
  29591. }
  29592. declare module "babylonjs/Materials/colorCurves" {
  29593. import { Effect } from "babylonjs/Materials/effect";
  29594. /**
  29595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29597. * 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;
  29598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29599. */
  29600. export class ColorCurves {
  29601. private _dirty;
  29602. private _tempColor;
  29603. private _globalCurve;
  29604. private _highlightsCurve;
  29605. private _midtonesCurve;
  29606. private _shadowsCurve;
  29607. private _positiveCurve;
  29608. private _negativeCurve;
  29609. private _globalHue;
  29610. private _globalDensity;
  29611. private _globalSaturation;
  29612. private _globalExposure;
  29613. /**
  29614. * Gets the global Hue value.
  29615. * 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).
  29616. */
  29617. /**
  29618. * Sets the global Hue value.
  29619. * 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).
  29620. */
  29621. globalHue: number;
  29622. /**
  29623. * Gets the global Density value.
  29624. * 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.
  29625. * Values less than zero provide a filter of opposite hue.
  29626. */
  29627. /**
  29628. * Sets the global Density value.
  29629. * 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.
  29630. * Values less than zero provide a filter of opposite hue.
  29631. */
  29632. globalDensity: number;
  29633. /**
  29634. * Gets the global Saturation value.
  29635. * 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.
  29636. */
  29637. /**
  29638. * Sets the global Saturation value.
  29639. * 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.
  29640. */
  29641. globalSaturation: number;
  29642. /**
  29643. * Gets the global Exposure value.
  29644. * 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.
  29645. */
  29646. /**
  29647. * Sets the global Exposure value.
  29648. * 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.
  29649. */
  29650. globalExposure: number;
  29651. private _highlightsHue;
  29652. private _highlightsDensity;
  29653. private _highlightsSaturation;
  29654. private _highlightsExposure;
  29655. /**
  29656. * Gets the highlights Hue value.
  29657. * 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).
  29658. */
  29659. /**
  29660. * Sets the highlights Hue value.
  29661. * 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).
  29662. */
  29663. highlightsHue: number;
  29664. /**
  29665. * Gets the highlights Density value.
  29666. * 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.
  29667. * Values less than zero provide a filter of opposite hue.
  29668. */
  29669. /**
  29670. * Sets the highlights Density value.
  29671. * 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.
  29672. * Values less than zero provide a filter of opposite hue.
  29673. */
  29674. highlightsDensity: number;
  29675. /**
  29676. * Gets the highlights Saturation value.
  29677. * 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.
  29678. */
  29679. /**
  29680. * Sets the highlights Saturation value.
  29681. * 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.
  29682. */
  29683. highlightsSaturation: number;
  29684. /**
  29685. * Gets the highlights Exposure value.
  29686. * 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.
  29687. */
  29688. /**
  29689. * Sets the highlights Exposure value.
  29690. * 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.
  29691. */
  29692. highlightsExposure: number;
  29693. private _midtonesHue;
  29694. private _midtonesDensity;
  29695. private _midtonesSaturation;
  29696. private _midtonesExposure;
  29697. /**
  29698. * Gets the midtones Hue value.
  29699. * 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).
  29700. */
  29701. /**
  29702. * Sets the midtones Hue value.
  29703. * 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).
  29704. */
  29705. midtonesHue: number;
  29706. /**
  29707. * Gets the midtones Density value.
  29708. * 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.
  29709. * Values less than zero provide a filter of opposite hue.
  29710. */
  29711. /**
  29712. * Sets the midtones Density value.
  29713. * 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.
  29714. * Values less than zero provide a filter of opposite hue.
  29715. */
  29716. midtonesDensity: number;
  29717. /**
  29718. * Gets the midtones Saturation value.
  29719. * 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.
  29720. */
  29721. /**
  29722. * Sets the midtones Saturation value.
  29723. * 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.
  29724. */
  29725. midtonesSaturation: number;
  29726. /**
  29727. * Gets the midtones Exposure value.
  29728. * 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.
  29729. */
  29730. /**
  29731. * Sets the midtones Exposure value.
  29732. * 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.
  29733. */
  29734. midtonesExposure: number;
  29735. private _shadowsHue;
  29736. private _shadowsDensity;
  29737. private _shadowsSaturation;
  29738. private _shadowsExposure;
  29739. /**
  29740. * Gets the shadows Hue value.
  29741. * 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).
  29742. */
  29743. /**
  29744. * Sets the shadows Hue value.
  29745. * 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).
  29746. */
  29747. shadowsHue: number;
  29748. /**
  29749. * Gets the shadows Density value.
  29750. * 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.
  29751. * Values less than zero provide a filter of opposite hue.
  29752. */
  29753. /**
  29754. * Sets the shadows Density value.
  29755. * 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.
  29756. * Values less than zero provide a filter of opposite hue.
  29757. */
  29758. shadowsDensity: number;
  29759. /**
  29760. * Gets the shadows Saturation value.
  29761. * 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.
  29762. */
  29763. /**
  29764. * Sets the shadows Saturation value.
  29765. * 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.
  29766. */
  29767. shadowsSaturation: number;
  29768. /**
  29769. * Gets the shadows Exposure value.
  29770. * 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.
  29771. */
  29772. /**
  29773. * Sets the shadows Exposure value.
  29774. * 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.
  29775. */
  29776. shadowsExposure: number;
  29777. /**
  29778. * Returns the class name
  29779. * @returns The class name
  29780. */
  29781. getClassName(): string;
  29782. /**
  29783. * Binds the color curves to the shader.
  29784. * @param colorCurves The color curve to bind
  29785. * @param effect The effect to bind to
  29786. * @param positiveUniform The positive uniform shader parameter
  29787. * @param neutralUniform The neutral uniform shader parameter
  29788. * @param negativeUniform The negative uniform shader parameter
  29789. */
  29790. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29791. /**
  29792. * Prepare the list of uniforms associated with the ColorCurves effects.
  29793. * @param uniformsList The list of uniforms used in the effect
  29794. */
  29795. static PrepareUniforms(uniformsList: string[]): void;
  29796. /**
  29797. * Returns color grading data based on a hue, density, saturation and exposure value.
  29798. * @param filterHue The hue of the color filter.
  29799. * @param filterDensity The density of the color filter.
  29800. * @param saturation The saturation.
  29801. * @param exposure The exposure.
  29802. * @param result The result data container.
  29803. */
  29804. private getColorGradingDataToRef;
  29805. /**
  29806. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29807. * @param value The input slider value in range [-100,100].
  29808. * @returns Adjusted value.
  29809. */
  29810. private static applyColorGradingSliderNonlinear;
  29811. /**
  29812. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29813. * @param hue The hue (H) input.
  29814. * @param saturation The saturation (S) input.
  29815. * @param brightness The brightness (B) input.
  29816. * @result An RGBA color represented as Vector4.
  29817. */
  29818. private static fromHSBToRef;
  29819. /**
  29820. * Returns a value clamped between min and max
  29821. * @param value The value to clamp
  29822. * @param min The minimum of value
  29823. * @param max The maximum of value
  29824. * @returns The clamped value.
  29825. */
  29826. private static clamp;
  29827. /**
  29828. * Clones the current color curve instance.
  29829. * @return The cloned curves
  29830. */
  29831. clone(): ColorCurves;
  29832. /**
  29833. * Serializes the current color curve instance to a json representation.
  29834. * @return a JSON representation
  29835. */
  29836. serialize(): any;
  29837. /**
  29838. * Parses the color curve from a json representation.
  29839. * @param source the JSON source to parse
  29840. * @return The parsed curves
  29841. */
  29842. static Parse(source: any): ColorCurves;
  29843. }
  29844. }
  29845. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29846. import { Observable } from "babylonjs/Misc/observable";
  29847. import { Nullable } from "babylonjs/types";
  29848. import { Color4 } from "babylonjs/Maths/math";
  29849. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29850. import { Effect } from "babylonjs/Materials/effect";
  29851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29853. /**
  29854. * Interface to follow in your material defines to integrate easily the
  29855. * Image proccessing functions.
  29856. * @hidden
  29857. */
  29858. export interface IImageProcessingConfigurationDefines {
  29859. IMAGEPROCESSING: boolean;
  29860. VIGNETTE: boolean;
  29861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29862. VIGNETTEBLENDMODEOPAQUE: boolean;
  29863. TONEMAPPING: boolean;
  29864. TONEMAPPING_ACES: boolean;
  29865. CONTRAST: boolean;
  29866. EXPOSURE: boolean;
  29867. COLORCURVES: boolean;
  29868. COLORGRADING: boolean;
  29869. COLORGRADING3D: boolean;
  29870. SAMPLER3DGREENDEPTH: boolean;
  29871. SAMPLER3DBGRMAP: boolean;
  29872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29873. }
  29874. /**
  29875. * @hidden
  29876. */
  29877. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29878. IMAGEPROCESSING: boolean;
  29879. VIGNETTE: boolean;
  29880. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29881. VIGNETTEBLENDMODEOPAQUE: boolean;
  29882. TONEMAPPING: boolean;
  29883. TONEMAPPING_ACES: boolean;
  29884. CONTRAST: boolean;
  29885. COLORCURVES: boolean;
  29886. COLORGRADING: boolean;
  29887. COLORGRADING3D: boolean;
  29888. SAMPLER3DGREENDEPTH: boolean;
  29889. SAMPLER3DBGRMAP: boolean;
  29890. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29891. EXPOSURE: boolean;
  29892. constructor();
  29893. }
  29894. /**
  29895. * This groups together the common properties used for image processing either in direct forward pass
  29896. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29897. * or not.
  29898. */
  29899. export class ImageProcessingConfiguration {
  29900. /**
  29901. * Default tone mapping applied in BabylonJS.
  29902. */
  29903. static readonly TONEMAPPING_STANDARD: number;
  29904. /**
  29905. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29906. * to other engines rendering to increase portability.
  29907. */
  29908. static readonly TONEMAPPING_ACES: number;
  29909. /**
  29910. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29911. */
  29912. colorCurves: Nullable<ColorCurves>;
  29913. private _colorCurvesEnabled;
  29914. /**
  29915. * Gets wether the color curves effect is enabled.
  29916. */
  29917. /**
  29918. * Sets wether the color curves effect is enabled.
  29919. */
  29920. colorCurvesEnabled: boolean;
  29921. private _colorGradingTexture;
  29922. /**
  29923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29924. */
  29925. /**
  29926. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29927. */
  29928. colorGradingTexture: Nullable<BaseTexture>;
  29929. private _colorGradingEnabled;
  29930. /**
  29931. * Gets wether the color grading effect is enabled.
  29932. */
  29933. /**
  29934. * Sets wether the color grading effect is enabled.
  29935. */
  29936. colorGradingEnabled: boolean;
  29937. private _colorGradingWithGreenDepth;
  29938. /**
  29939. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29940. */
  29941. /**
  29942. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29943. */
  29944. colorGradingWithGreenDepth: boolean;
  29945. private _colorGradingBGR;
  29946. /**
  29947. * Gets wether the color grading texture contains BGR values.
  29948. */
  29949. /**
  29950. * Sets wether the color grading texture contains BGR values.
  29951. */
  29952. colorGradingBGR: boolean;
  29953. /** @hidden */
  29954. _exposure: number;
  29955. /**
  29956. * Gets the Exposure used in the effect.
  29957. */
  29958. /**
  29959. * Sets the Exposure used in the effect.
  29960. */
  29961. exposure: number;
  29962. private _toneMappingEnabled;
  29963. /**
  29964. * Gets wether the tone mapping effect is enabled.
  29965. */
  29966. /**
  29967. * Sets wether the tone mapping effect is enabled.
  29968. */
  29969. toneMappingEnabled: boolean;
  29970. private _toneMappingType;
  29971. /**
  29972. * Gets the type of tone mapping effect.
  29973. */
  29974. /**
  29975. * Sets the type of tone mapping effect used in BabylonJS.
  29976. */
  29977. toneMappingType: number;
  29978. protected _contrast: number;
  29979. /**
  29980. * Gets the contrast used in the effect.
  29981. */
  29982. /**
  29983. * Sets the contrast used in the effect.
  29984. */
  29985. contrast: number;
  29986. /**
  29987. * Vignette stretch size.
  29988. */
  29989. vignetteStretch: number;
  29990. /**
  29991. * Vignette centre X Offset.
  29992. */
  29993. vignetteCentreX: number;
  29994. /**
  29995. * Vignette centre Y Offset.
  29996. */
  29997. vignetteCentreY: number;
  29998. /**
  29999. * Vignette weight or intensity of the vignette effect.
  30000. */
  30001. vignetteWeight: number;
  30002. /**
  30003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30004. * if vignetteEnabled is set to true.
  30005. */
  30006. vignetteColor: Color4;
  30007. /**
  30008. * Camera field of view used by the Vignette effect.
  30009. */
  30010. vignetteCameraFov: number;
  30011. private _vignetteBlendMode;
  30012. /**
  30013. * Gets the vignette blend mode allowing different kind of effect.
  30014. */
  30015. /**
  30016. * Sets the vignette blend mode allowing different kind of effect.
  30017. */
  30018. vignetteBlendMode: number;
  30019. private _vignetteEnabled;
  30020. /**
  30021. * Gets wether the vignette effect is enabled.
  30022. */
  30023. /**
  30024. * Sets wether the vignette effect is enabled.
  30025. */
  30026. vignetteEnabled: boolean;
  30027. private _applyByPostProcess;
  30028. /**
  30029. * Gets wether the image processing is applied through a post process or not.
  30030. */
  30031. /**
  30032. * Sets wether the image processing is applied through a post process or not.
  30033. */
  30034. applyByPostProcess: boolean;
  30035. private _isEnabled;
  30036. /**
  30037. * Gets wether the image processing is enabled or not.
  30038. */
  30039. /**
  30040. * Sets wether the image processing is enabled or not.
  30041. */
  30042. isEnabled: boolean;
  30043. /**
  30044. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30045. */
  30046. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30047. /**
  30048. * Method called each time the image processing information changes requires to recompile the effect.
  30049. */
  30050. protected _updateParameters(): void;
  30051. /**
  30052. * Gets the current class name.
  30053. * @return "ImageProcessingConfiguration"
  30054. */
  30055. getClassName(): string;
  30056. /**
  30057. * Prepare the list of uniforms associated with the Image Processing effects.
  30058. * @param uniforms The list of uniforms used in the effect
  30059. * @param defines the list of defines currently in use
  30060. */
  30061. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30062. /**
  30063. * Prepare the list of samplers associated with the Image Processing effects.
  30064. * @param samplersList The list of uniforms used in the effect
  30065. * @param defines the list of defines currently in use
  30066. */
  30067. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30068. /**
  30069. * Prepare the list of defines associated to the shader.
  30070. * @param defines the list of defines to complete
  30071. * @param forPostProcess Define if we are currently in post process mode or not
  30072. */
  30073. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30074. /**
  30075. * Returns true if all the image processing information are ready.
  30076. * @returns True if ready, otherwise, false
  30077. */
  30078. isReady(): boolean;
  30079. /**
  30080. * Binds the image processing to the shader.
  30081. * @param effect The effect to bind to
  30082. * @param aspectRatio Define the current aspect ratio of the effect
  30083. */
  30084. bind(effect: Effect, aspectRatio?: number): void;
  30085. /**
  30086. * Clones the current image processing instance.
  30087. * @return The cloned image processing
  30088. */
  30089. clone(): ImageProcessingConfiguration;
  30090. /**
  30091. * Serializes the current image processing instance to a json representation.
  30092. * @return a JSON representation
  30093. */
  30094. serialize(): any;
  30095. /**
  30096. * Parses the image processing from a json representation.
  30097. * @param source the JSON source to parse
  30098. * @return The parsed image processing
  30099. */
  30100. static Parse(source: any): ImageProcessingConfiguration;
  30101. private static _VIGNETTEMODE_MULTIPLY;
  30102. private static _VIGNETTEMODE_OPAQUE;
  30103. /**
  30104. * Used to apply the vignette as a mix with the pixel color.
  30105. */
  30106. static readonly VIGNETTEMODE_MULTIPLY: number;
  30107. /**
  30108. * Used to apply the vignette as a replacement of the pixel color.
  30109. */
  30110. static readonly VIGNETTEMODE_OPAQUE: number;
  30111. }
  30112. }
  30113. declare module "babylonjs/Materials/fresnelParameters" {
  30114. import { Color3 } from "babylonjs/Maths/math";
  30115. /**
  30116. * This represents all the required information to add a fresnel effect on a material:
  30117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30118. */
  30119. export class FresnelParameters {
  30120. private _isEnabled;
  30121. /**
  30122. * Define if the fresnel effect is enable or not.
  30123. */
  30124. isEnabled: boolean;
  30125. /**
  30126. * Define the color used on edges (grazing angle)
  30127. */
  30128. leftColor: Color3;
  30129. /**
  30130. * Define the color used on center
  30131. */
  30132. rightColor: Color3;
  30133. /**
  30134. * Define bias applied to computed fresnel term
  30135. */
  30136. bias: number;
  30137. /**
  30138. * Defined the power exponent applied to fresnel term
  30139. */
  30140. power: number;
  30141. /**
  30142. * Clones the current fresnel and its valuues
  30143. * @returns a clone fresnel configuration
  30144. */
  30145. clone(): FresnelParameters;
  30146. /**
  30147. * Serializes the current fresnel parameters to a JSON representation.
  30148. * @return the JSON serialization
  30149. */
  30150. serialize(): any;
  30151. /**
  30152. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30153. * @param parsedFresnelParameters Define the JSON representation
  30154. * @returns the parsed parameters
  30155. */
  30156. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30157. }
  30158. }
  30159. declare module "babylonjs/Misc/decorators" {
  30160. import { Nullable } from "babylonjs/types";
  30161. import { Scene } from "babylonjs/scene";
  30162. import { IAnimatable } from "babylonjs/Misc/tools";
  30163. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30164. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30171. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30172. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30173. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30174. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30175. /**
  30176. * Decorator used to define property that can be serialized as reference to a camera
  30177. * @param sourceName defines the name of the property to decorate
  30178. */
  30179. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30180. /**
  30181. * Class used to help serialization objects
  30182. */
  30183. export class SerializationHelper {
  30184. /** hidden */
  30185. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30186. /** hidden */
  30187. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30188. /** hidden */
  30189. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30190. /** hidden */
  30191. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30192. /**
  30193. * Appends the serialized animations from the source animations
  30194. * @param source Source containing the animations
  30195. * @param destination Target to store the animations
  30196. */
  30197. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30198. /**
  30199. * Static function used to serialized a specific entity
  30200. * @param entity defines the entity to serialize
  30201. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30202. * @returns a JSON compatible object representing the serialization of the entity
  30203. */
  30204. static Serialize<T>(entity: T, serializationObject?: any): any;
  30205. /**
  30206. * Creates a new entity from a serialization data object
  30207. * @param creationFunction defines a function used to instanciated the new entity
  30208. * @param source defines the source serialization data
  30209. * @param scene defines the hosting scene
  30210. * @param rootUrl defines the root url for resources
  30211. * @returns a new entity
  30212. */
  30213. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30214. /**
  30215. * Clones an object
  30216. * @param creationFunction defines the function used to instanciate the new object
  30217. * @param source defines the source object
  30218. * @returns the cloned object
  30219. */
  30220. static Clone<T>(creationFunction: () => T, source: T): T;
  30221. /**
  30222. * Instanciates a new object based on a source one (some data will be shared between both object)
  30223. * @param creationFunction defines the function used to instanciate the new object
  30224. * @param source defines the source object
  30225. * @returns the new object
  30226. */
  30227. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30228. }
  30229. }
  30230. declare module "babylonjs/Cameras/camera" {
  30231. import { SmartArray } from "babylonjs/Misc/smartArray";
  30232. import { Observable } from "babylonjs/Misc/observable";
  30233. import { Nullable } from "babylonjs/types";
  30234. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30235. import { Scene } from "babylonjs/scene";
  30236. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30237. import { Node } from "babylonjs/node";
  30238. import { Mesh } from "babylonjs/Meshes/mesh";
  30239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30240. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30244. import { Ray } from "babylonjs/Culling/ray";
  30245. /**
  30246. * This is the base class of all the camera used in the application.
  30247. * @see http://doc.babylonjs.com/features/cameras
  30248. */
  30249. export class Camera extends Node {
  30250. /** @hidden */
  30251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30252. /**
  30253. * This is the default projection mode used by the cameras.
  30254. * It helps recreating a feeling of perspective and better appreciate depth.
  30255. * This is the best way to simulate real life cameras.
  30256. */
  30257. static readonly PERSPECTIVE_CAMERA: number;
  30258. /**
  30259. * This helps creating camera with an orthographic mode.
  30260. * 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.
  30261. */
  30262. static readonly ORTHOGRAPHIC_CAMERA: number;
  30263. /**
  30264. * This is the default FOV mode for perspective cameras.
  30265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30266. */
  30267. static readonly FOVMODE_VERTICAL_FIXED: number;
  30268. /**
  30269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30270. */
  30271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30272. /**
  30273. * This specifies ther is no need for a camera rig.
  30274. * Basically only one eye is rendered corresponding to the camera.
  30275. */
  30276. static readonly RIG_MODE_NONE: number;
  30277. /**
  30278. * Simulates a camera Rig with one blue eye and one red eye.
  30279. * This can be use with 3d blue and red glasses.
  30280. */
  30281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30282. /**
  30283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30284. */
  30285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30286. /**
  30287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30288. */
  30289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30290. /**
  30291. * Defines that both eyes of the camera will be rendered over under each other.
  30292. */
  30293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30294. /**
  30295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30296. */
  30297. static readonly RIG_MODE_VR: number;
  30298. /**
  30299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30300. */
  30301. static readonly RIG_MODE_WEBVR: number;
  30302. /**
  30303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30304. */
  30305. static readonly RIG_MODE_CUSTOM: number;
  30306. /**
  30307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30308. */
  30309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30310. /**
  30311. * @hidden
  30312. * Might be removed once multiview will be a thing
  30313. */
  30314. static UseAlternateWebVRRendering: boolean;
  30315. /**
  30316. * Define the input manager associated with the camera.
  30317. */
  30318. inputs: CameraInputsManager<Camera>;
  30319. /** @hidden */
  30320. _position: Vector3;
  30321. /**
  30322. * Define the current local position of the camera in the scene
  30323. */
  30324. position: Vector3;
  30325. /**
  30326. * The vector the camera should consider as up.
  30327. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30328. */
  30329. upVector: Vector3;
  30330. /**
  30331. * Define the current limit on the left side for an orthographic camera
  30332. * In scene unit
  30333. */
  30334. orthoLeft: Nullable<number>;
  30335. /**
  30336. * Define the current limit on the right side for an orthographic camera
  30337. * In scene unit
  30338. */
  30339. orthoRight: Nullable<number>;
  30340. /**
  30341. * Define the current limit on the bottom side for an orthographic camera
  30342. * In scene unit
  30343. */
  30344. orthoBottom: Nullable<number>;
  30345. /**
  30346. * Define the current limit on the top side for an orthographic camera
  30347. * In scene unit
  30348. */
  30349. orthoTop: Nullable<number>;
  30350. /**
  30351. * Field Of View is set in Radians. (default is 0.8)
  30352. */
  30353. fov: number;
  30354. /**
  30355. * Define the minimum distance the camera can see from.
  30356. * This is important to note that the depth buffer are not infinite and the closer it starts
  30357. * the more your scene might encounter depth fighting issue.
  30358. */
  30359. minZ: number;
  30360. /**
  30361. * Define the maximum distance the camera can see to.
  30362. * This is important to note that the depth buffer are not infinite and the further it end
  30363. * the more your scene might encounter depth fighting issue.
  30364. */
  30365. maxZ: number;
  30366. /**
  30367. * Define the default inertia of the camera.
  30368. * This helps giving a smooth feeling to the camera movement.
  30369. */
  30370. inertia: number;
  30371. /**
  30372. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30373. */
  30374. mode: number;
  30375. /**
  30376. * Define wether the camera is intermediate.
  30377. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30378. */
  30379. isIntermediate: boolean;
  30380. /**
  30381. * Define the viewport of the camera.
  30382. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30383. */
  30384. viewport: Viewport;
  30385. /**
  30386. * Restricts the camera to viewing objects with the same layerMask.
  30387. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30388. */
  30389. layerMask: number;
  30390. /**
  30391. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30392. */
  30393. fovMode: number;
  30394. /**
  30395. * Rig mode of the camera.
  30396. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30397. * This is normally controlled byt the camera themselves as internal use.
  30398. */
  30399. cameraRigMode: number;
  30400. /**
  30401. * Defines the distance between both "eyes" in case of a RIG
  30402. */
  30403. interaxialDistance: number;
  30404. /**
  30405. * Defines if stereoscopic rendering is done side by side or over under.
  30406. */
  30407. isStereoscopicSideBySide: boolean;
  30408. /**
  30409. * 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
  30410. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30411. * else in the scene.
  30412. */
  30413. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30414. /**
  30415. * When set, the camera will render to this render target instead of the default canvas
  30416. */
  30417. outputRenderTarget: Nullable<RenderTargetTexture>;
  30418. /**
  30419. * Observable triggered when the camera view matrix has changed.
  30420. */
  30421. onViewMatrixChangedObservable: Observable<Camera>;
  30422. /**
  30423. * Observable triggered when the camera Projection matrix has changed.
  30424. */
  30425. onProjectionMatrixChangedObservable: Observable<Camera>;
  30426. /**
  30427. * Observable triggered when the inputs have been processed.
  30428. */
  30429. onAfterCheckInputsObservable: Observable<Camera>;
  30430. /**
  30431. * Observable triggered when reset has been called and applied to the camera.
  30432. */
  30433. onRestoreStateObservable: Observable<Camera>;
  30434. /** @hidden */
  30435. _cameraRigParams: any;
  30436. /** @hidden */
  30437. _rigCameras: Camera[];
  30438. /** @hidden */
  30439. _rigPostProcess: Nullable<PostProcess>;
  30440. protected _webvrViewMatrix: Matrix;
  30441. /** @hidden */
  30442. _skipRendering: boolean;
  30443. /** @hidden */
  30444. _alternateCamera: Camera;
  30445. /** @hidden */
  30446. _projectionMatrix: Matrix;
  30447. /** @hidden */
  30448. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30449. /** @hidden */
  30450. _activeMeshes: SmartArray<AbstractMesh>;
  30451. protected _globalPosition: Vector3;
  30452. /** hidden */
  30453. _computedViewMatrix: Matrix;
  30454. private _doNotComputeProjectionMatrix;
  30455. private _transformMatrix;
  30456. private _frustumPlanes;
  30457. private _refreshFrustumPlanes;
  30458. private _storedFov;
  30459. private _stateStored;
  30460. /**
  30461. * Instantiates a new camera object.
  30462. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30463. * @see http://doc.babylonjs.com/features/cameras
  30464. * @param name Defines the name of the camera in the scene
  30465. * @param position Defines the position of the camera
  30466. * @param scene Defines the scene the camera belongs too
  30467. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30468. */
  30469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30470. /**
  30471. * Store current camera state (fov, position, etc..)
  30472. * @returns the camera
  30473. */
  30474. storeState(): Camera;
  30475. /**
  30476. * Restores the camera state values if it has been stored. You must call storeState() first
  30477. */
  30478. protected _restoreStateValues(): boolean;
  30479. /**
  30480. * Restored camera state. You must call storeState() first.
  30481. * @returns true if restored and false otherwise
  30482. */
  30483. restoreState(): boolean;
  30484. /**
  30485. * Gets the class name of the camera.
  30486. * @returns the class name
  30487. */
  30488. getClassName(): string;
  30489. /** @hidden */
  30490. readonly _isCamera: boolean;
  30491. /**
  30492. * Gets a string representation of the camera useful for debug purpose.
  30493. * @param fullDetails Defines that a more verboe level of logging is required
  30494. * @returns the string representation
  30495. */
  30496. toString(fullDetails?: boolean): string;
  30497. /**
  30498. * Gets the current world space position of the camera.
  30499. */
  30500. readonly globalPosition: Vector3;
  30501. /**
  30502. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30503. * @returns the active meshe list
  30504. */
  30505. getActiveMeshes(): SmartArray<AbstractMesh>;
  30506. /**
  30507. * Check wether a mesh is part of the current active mesh list of the camera
  30508. * @param mesh Defines the mesh to check
  30509. * @returns true if active, false otherwise
  30510. */
  30511. isActiveMesh(mesh: Mesh): boolean;
  30512. /**
  30513. * Is this camera ready to be used/rendered
  30514. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30515. * @return true if the camera is ready
  30516. */
  30517. isReady(completeCheck?: boolean): boolean;
  30518. /** @hidden */
  30519. _initCache(): void;
  30520. /** @hidden */
  30521. _updateCache(ignoreParentClass?: boolean): void;
  30522. /** @hidden */
  30523. _isSynchronized(): boolean;
  30524. /** @hidden */
  30525. _isSynchronizedViewMatrix(): boolean;
  30526. /** @hidden */
  30527. _isSynchronizedProjectionMatrix(): boolean;
  30528. /**
  30529. * Attach the input controls to a specific dom element to get the input from.
  30530. * @param element Defines the element the controls should be listened from
  30531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30532. */
  30533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30534. /**
  30535. * Detach the current controls from the specified dom element.
  30536. * @param element Defines the element to stop listening the inputs from
  30537. */
  30538. detachControl(element: HTMLElement): void;
  30539. /**
  30540. * Update the camera state according to the different inputs gathered during the frame.
  30541. */
  30542. update(): void;
  30543. /** @hidden */
  30544. _checkInputs(): void;
  30545. /** @hidden */
  30546. readonly rigCameras: Camera[];
  30547. /**
  30548. * Gets the post process used by the rig cameras
  30549. */
  30550. readonly rigPostProcess: Nullable<PostProcess>;
  30551. /**
  30552. * Internal, gets the first post proces.
  30553. * @returns the first post process to be run on this camera.
  30554. */
  30555. _getFirstPostProcess(): Nullable<PostProcess>;
  30556. private _cascadePostProcessesToRigCams;
  30557. /**
  30558. * Attach a post process to the camera.
  30559. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30560. * @param postProcess The post process to attach to the camera
  30561. * @param insertAt The position of the post process in case several of them are in use in the scene
  30562. * @returns the position the post process has been inserted at
  30563. */
  30564. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30565. /**
  30566. * Detach a post process to the camera.
  30567. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30568. * @param postProcess The post process to detach from the camera
  30569. */
  30570. detachPostProcess(postProcess: PostProcess): void;
  30571. /**
  30572. * Gets the current world matrix of the camera
  30573. */
  30574. getWorldMatrix(): Matrix;
  30575. /** @hidden */
  30576. _getViewMatrix(): Matrix;
  30577. /**
  30578. * Gets the current view matrix of the camera.
  30579. * @param force forces the camera to recompute the matrix without looking at the cached state
  30580. * @returns the view matrix
  30581. */
  30582. getViewMatrix(force?: boolean): Matrix;
  30583. /**
  30584. * Freeze the projection matrix.
  30585. * It will prevent the cache check of the camera projection compute and can speed up perf
  30586. * if no parameter of the camera are meant to change
  30587. * @param projection Defines manually a projection if necessary
  30588. */
  30589. freezeProjectionMatrix(projection?: Matrix): void;
  30590. /**
  30591. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30592. */
  30593. unfreezeProjectionMatrix(): void;
  30594. /**
  30595. * Gets the current projection matrix of the camera.
  30596. * @param force forces the camera to recompute the matrix without looking at the cached state
  30597. * @returns the projection matrix
  30598. */
  30599. getProjectionMatrix(force?: boolean): Matrix;
  30600. /**
  30601. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30602. * @returns a Matrix
  30603. */
  30604. getTransformationMatrix(): Matrix;
  30605. private _updateFrustumPlanes;
  30606. /**
  30607. * Checks if a cullable object (mesh...) is in the camera frustum
  30608. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30609. * @param target The object to check
  30610. * @returns true if the object is in frustum otherwise false
  30611. */
  30612. isInFrustum(target: ICullable): boolean;
  30613. /**
  30614. * Checks if a cullable object (mesh...) is in the camera frustum
  30615. * Unlike isInFrustum this cheks the full bounding box
  30616. * @param target The object to check
  30617. * @returns true if the object is in frustum otherwise false
  30618. */
  30619. isCompletelyInFrustum(target: ICullable): boolean;
  30620. /**
  30621. * Gets a ray in the forward direction from the camera.
  30622. * @param length Defines the length of the ray to create
  30623. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30624. * @param origin Defines the start point of the ray which defaults to the camera position
  30625. * @returns the forward ray
  30626. */
  30627. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30628. /**
  30629. * Releases resources associated with this node.
  30630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30632. */
  30633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30634. /** @hidden */
  30635. _isLeftCamera: boolean;
  30636. /**
  30637. * Gets the left camera of a rig setup in case of Rigged Camera
  30638. */
  30639. readonly isLeftCamera: boolean;
  30640. /** @hidden */
  30641. _isRightCamera: boolean;
  30642. /**
  30643. * Gets the right camera of a rig setup in case of Rigged Camera
  30644. */
  30645. readonly isRightCamera: boolean;
  30646. /**
  30647. * Gets the left camera of a rig setup in case of Rigged Camera
  30648. */
  30649. readonly leftCamera: Nullable<FreeCamera>;
  30650. /**
  30651. * Gets the right camera of a rig setup in case of Rigged Camera
  30652. */
  30653. readonly rightCamera: Nullable<FreeCamera>;
  30654. /**
  30655. * Gets the left camera target of a rig setup in case of Rigged Camera
  30656. * @returns the target position
  30657. */
  30658. getLeftTarget(): Nullable<Vector3>;
  30659. /**
  30660. * Gets the right camera target of a rig setup in case of Rigged Camera
  30661. * @returns the target position
  30662. */
  30663. getRightTarget(): Nullable<Vector3>;
  30664. /**
  30665. * @hidden
  30666. */
  30667. setCameraRigMode(mode: number, rigParams: any): void;
  30668. /** @hidden */
  30669. static _setStereoscopicRigMode(camera: Camera): void;
  30670. /** @hidden */
  30671. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30672. /** @hidden */
  30673. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30674. /** @hidden */
  30675. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30676. /** @hidden */
  30677. _getVRProjectionMatrix(): Matrix;
  30678. protected _updateCameraRotationMatrix(): void;
  30679. protected _updateWebVRCameraRotationMatrix(): void;
  30680. /**
  30681. * This function MUST be overwritten by the different WebVR cameras available.
  30682. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30683. * @hidden
  30684. */
  30685. _getWebVRProjectionMatrix(): Matrix;
  30686. /**
  30687. * This function MUST be overwritten by the different WebVR cameras available.
  30688. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30689. * @hidden
  30690. */
  30691. _getWebVRViewMatrix(): Matrix;
  30692. /** @hidden */
  30693. setCameraRigParameter(name: string, value: any): void;
  30694. /**
  30695. * needs to be overridden by children so sub has required properties to be copied
  30696. * @hidden
  30697. */
  30698. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30699. /**
  30700. * May need to be overridden by children
  30701. * @hidden
  30702. */
  30703. _updateRigCameras(): void;
  30704. /** @hidden */
  30705. _setupInputs(): void;
  30706. /**
  30707. * Serialiaze the camera setup to a json represention
  30708. * @returns the JSON representation
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Clones the current camera.
  30713. * @param name The cloned camera name
  30714. * @returns the cloned camera
  30715. */
  30716. clone(name: string): Camera;
  30717. /**
  30718. * Gets the direction of the camera relative to a given local axis.
  30719. * @param localAxis Defines the reference axis to provide a relative direction.
  30720. * @return the direction
  30721. */
  30722. getDirection(localAxis: Vector3): Vector3;
  30723. /**
  30724. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30725. * @param localAxis Defines the reference axis to provide a relative direction.
  30726. * @param result Defines the vector to store the result in
  30727. */
  30728. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30729. /**
  30730. * Gets a camera constructor for a given camera type
  30731. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30732. * @param name The name of the camera the result will be able to instantiate
  30733. * @param scene The scene the result will construct the camera in
  30734. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30735. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30736. * @returns a factory method to construc the camera
  30737. */
  30738. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30739. /**
  30740. * Compute the world matrix of the camera.
  30741. * @returns the camera workd matrix
  30742. */
  30743. computeWorldMatrix(): Matrix;
  30744. /**
  30745. * Parse a JSON and creates the camera from the parsed information
  30746. * @param parsedCamera The JSON to parse
  30747. * @param scene The scene to instantiate the camera in
  30748. * @returns the newly constructed camera
  30749. */
  30750. static Parse(parsedCamera: any, scene: Scene): Camera;
  30751. }
  30752. }
  30753. declare module "babylonjs/Misc/tools" {
  30754. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30755. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30756. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30757. import { Observable } from "babylonjs/Misc/observable";
  30758. import { DomManagement } from "babylonjs/Misc/domManagement";
  30759. import { WebRequest } from "babylonjs/Misc/webRequest";
  30760. import { Camera } from "babylonjs/Cameras/camera";
  30761. import { Engine } from "babylonjs/Engines/engine";
  30762. import { Animation } from "babylonjs/Animations/animation";
  30763. /**
  30764. * Interface for any object that can request an animation frame
  30765. */
  30766. export interface ICustomAnimationFrameRequester {
  30767. /**
  30768. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30769. */
  30770. renderFunction?: Function;
  30771. /**
  30772. * Called to request the next frame to render to
  30773. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30774. */
  30775. requestAnimationFrame: Function;
  30776. /**
  30777. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30778. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30779. */
  30780. requestID?: number;
  30781. }
  30782. /**
  30783. * Interface containing an array of animations
  30784. */
  30785. export interface IAnimatable {
  30786. /**
  30787. * Array of animations
  30788. */
  30789. animations: Array<Animation>;
  30790. }
  30791. /** Interface used by value gradients (color, factor, ...) */
  30792. export interface IValueGradient {
  30793. /**
  30794. * Gets or sets the gradient value (between 0 and 1)
  30795. */
  30796. gradient: number;
  30797. }
  30798. /** Class used to store color4 gradient */
  30799. export class ColorGradient implements IValueGradient {
  30800. /**
  30801. * Gets or sets the gradient value (between 0 and 1)
  30802. */
  30803. gradient: number;
  30804. /**
  30805. * Gets or sets first associated color
  30806. */
  30807. color1: Color4;
  30808. /**
  30809. * Gets or sets second associated color
  30810. */
  30811. color2?: Color4;
  30812. /**
  30813. * Will get a color picked randomly between color1 and color2.
  30814. * If color2 is undefined then color1 will be used
  30815. * @param result defines the target Color4 to store the result in
  30816. */
  30817. getColorToRef(result: Color4): void;
  30818. }
  30819. /** Class used to store color 3 gradient */
  30820. export class Color3Gradient implements IValueGradient {
  30821. /**
  30822. * Gets or sets the gradient value (between 0 and 1)
  30823. */
  30824. gradient: number;
  30825. /**
  30826. * Gets or sets the associated color
  30827. */
  30828. color: Color3;
  30829. }
  30830. /** Class used to store factor gradient */
  30831. export class FactorGradient implements IValueGradient {
  30832. /**
  30833. * Gets or sets the gradient value (between 0 and 1)
  30834. */
  30835. gradient: number;
  30836. /**
  30837. * Gets or sets first associated factor
  30838. */
  30839. factor1: number;
  30840. /**
  30841. * Gets or sets second associated factor
  30842. */
  30843. factor2?: number;
  30844. /**
  30845. * Will get a number picked randomly between factor1 and factor2.
  30846. * If factor2 is undefined then factor1 will be used
  30847. * @returns the picked number
  30848. */
  30849. getFactor(): number;
  30850. }
  30851. /**
  30852. * @ignore
  30853. * Application error to support additional information when loading a file
  30854. */
  30855. export class LoadFileError extends Error {
  30856. /** defines the optional web request */
  30857. request?: WebRequest | undefined;
  30858. private static _setPrototypeOf;
  30859. /**
  30860. * Creates a new LoadFileError
  30861. * @param message defines the message of the error
  30862. * @param request defines the optional web request
  30863. */
  30864. constructor(message: string,
  30865. /** defines the optional web request */
  30866. request?: WebRequest | undefined);
  30867. }
  30868. /**
  30869. * Class used to define a retry strategy when error happens while loading assets
  30870. */
  30871. export class RetryStrategy {
  30872. /**
  30873. * Function used to defines an exponential back off strategy
  30874. * @param maxRetries defines the maximum number of retries (3 by default)
  30875. * @param baseInterval defines the interval between retries
  30876. * @returns the strategy function to use
  30877. */
  30878. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30879. }
  30880. /**
  30881. * File request interface
  30882. */
  30883. export interface IFileRequest {
  30884. /**
  30885. * Raised when the request is complete (success or error).
  30886. */
  30887. onCompleteObservable: Observable<IFileRequest>;
  30888. /**
  30889. * Aborts the request for a file.
  30890. */
  30891. abort: () => void;
  30892. }
  30893. /**
  30894. * Class containing a set of static utilities functions
  30895. */
  30896. export class Tools {
  30897. /**
  30898. * Gets or sets the base URL to use to load assets
  30899. */
  30900. static BaseUrl: string;
  30901. /**
  30902. * Enable/Disable Custom HTTP Request Headers globally.
  30903. * default = false
  30904. * @see CustomRequestHeaders
  30905. */
  30906. static UseCustomRequestHeaders: boolean;
  30907. /**
  30908. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30909. * i.e. when loading files, where the server/service expects an Authorization header
  30910. */
  30911. static CustomRequestHeaders: {
  30912. [key: string]: string;
  30913. };
  30914. /**
  30915. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30916. */
  30917. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30918. /**
  30919. * Default behaviour for cors in the application.
  30920. * It can be a string if the expected behavior is identical in the entire app.
  30921. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30922. */
  30923. static CorsBehavior: string | ((url: string | string[]) => string);
  30924. /**
  30925. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30926. * @ignorenaming
  30927. */
  30928. static UseFallbackTexture: boolean;
  30929. /**
  30930. * Use this object to register external classes like custom textures or material
  30931. * to allow the laoders to instantiate them
  30932. */
  30933. static RegisteredExternalClasses: {
  30934. [key: string]: Object;
  30935. };
  30936. /**
  30937. * Texture content used if a texture cannot loaded
  30938. * @ignorenaming
  30939. */
  30940. static fallbackTexture: string;
  30941. /**
  30942. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30943. * @param u defines the coordinate on X axis
  30944. * @param v defines the coordinate on Y axis
  30945. * @param width defines the width of the source data
  30946. * @param height defines the height of the source data
  30947. * @param pixels defines the source byte array
  30948. * @param color defines the output color
  30949. */
  30950. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30951. /**
  30952. * Interpolates between a and b via alpha
  30953. * @param a The lower value (returned when alpha = 0)
  30954. * @param b The upper value (returned when alpha = 1)
  30955. * @param alpha The interpolation-factor
  30956. * @return The mixed value
  30957. */
  30958. static Mix(a: number, b: number, alpha: number): number;
  30959. /**
  30960. * Tries to instantiate a new object from a given class name
  30961. * @param className defines the class name to instantiate
  30962. * @returns the new object or null if the system was not able to do the instantiation
  30963. */
  30964. static Instantiate(className: string): any;
  30965. /**
  30966. * Provides a slice function that will work even on IE
  30967. * @param data defines the array to slice
  30968. * @param start defines the start of the data (optional)
  30969. * @param end defines the end of the data (optional)
  30970. * @returns the new sliced array
  30971. */
  30972. static Slice<T>(data: T, start?: number, end?: number): T;
  30973. /**
  30974. * Polyfill for setImmediate
  30975. * @param action defines the action to execute after the current execution block
  30976. */
  30977. static SetImmediate(action: () => void): void;
  30978. /**
  30979. * Function indicating if a number is an exponent of 2
  30980. * @param value defines the value to test
  30981. * @returns true if the value is an exponent of 2
  30982. */
  30983. static IsExponentOfTwo(value: number): boolean;
  30984. private static _tmpFloatArray;
  30985. /**
  30986. * Returns the nearest 32-bit single precision float representation of a Number
  30987. * @param value A Number. If the parameter is of a different type, it will get converted
  30988. * to a number or to NaN if it cannot be converted
  30989. * @returns number
  30990. */
  30991. static FloatRound(value: number): number;
  30992. /**
  30993. * Find the next highest power of two.
  30994. * @param x Number to start search from.
  30995. * @return Next highest power of two.
  30996. */
  30997. static CeilingPOT(x: number): number;
  30998. /**
  30999. * Find the next lowest power of two.
  31000. * @param x Number to start search from.
  31001. * @return Next lowest power of two.
  31002. */
  31003. static FloorPOT(x: number): number;
  31004. /**
  31005. * Find the nearest power of two.
  31006. * @param x Number to start search from.
  31007. * @return Next nearest power of two.
  31008. */
  31009. static NearestPOT(x: number): number;
  31010. /**
  31011. * Get the closest exponent of two
  31012. * @param value defines the value to approximate
  31013. * @param max defines the maximum value to return
  31014. * @param mode defines how to define the closest value
  31015. * @returns closest exponent of two of the given value
  31016. */
  31017. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31018. /**
  31019. * Extracts the filename from a path
  31020. * @param path defines the path to use
  31021. * @returns the filename
  31022. */
  31023. static GetFilename(path: string): string;
  31024. /**
  31025. * Extracts the "folder" part of a path (everything before the filename).
  31026. * @param uri The URI to extract the info from
  31027. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31028. * @returns The "folder" part of the path
  31029. */
  31030. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31031. /**
  31032. * Extracts text content from a DOM element hierarchy
  31033. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31034. */
  31035. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31036. /**
  31037. * Convert an angle in radians to degrees
  31038. * @param angle defines the angle to convert
  31039. * @returns the angle in degrees
  31040. */
  31041. static ToDegrees(angle: number): number;
  31042. /**
  31043. * Convert an angle in degrees to radians
  31044. * @param angle defines the angle to convert
  31045. * @returns the angle in radians
  31046. */
  31047. static ToRadians(angle: number): number;
  31048. /**
  31049. * Encode a buffer to a base64 string
  31050. * @param buffer defines the buffer to encode
  31051. * @returns the encoded string
  31052. */
  31053. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31054. /**
  31055. * Extracts minimum and maximum values from a list of indexed positions
  31056. * @param positions defines the positions to use
  31057. * @param indices defines the indices to the positions
  31058. * @param indexStart defines the start index
  31059. * @param indexCount defines the end index
  31060. * @param bias defines bias value to add to the result
  31061. * @return minimum and maximum values
  31062. */
  31063. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31064. minimum: Vector3;
  31065. maximum: Vector3;
  31066. };
  31067. /**
  31068. * Extracts minimum and maximum values from a list of positions
  31069. * @param positions defines the positions to use
  31070. * @param start defines the start index in the positions array
  31071. * @param count defines the number of positions to handle
  31072. * @param bias defines bias value to add to the result
  31073. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31074. * @return minimum and maximum values
  31075. */
  31076. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31077. minimum: Vector3;
  31078. maximum: Vector3;
  31079. };
  31080. /**
  31081. * Returns an array if obj is not an array
  31082. * @param obj defines the object to evaluate as an array
  31083. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31084. * @returns either obj directly if obj is an array or a new array containing obj
  31085. */
  31086. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31087. /**
  31088. * Gets the pointer prefix to use
  31089. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31090. */
  31091. static GetPointerPrefix(): string;
  31092. /**
  31093. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31094. * @param func - the function to be called
  31095. * @param requester - the object that will request the next frame. Falls back to window.
  31096. * @returns frame number
  31097. */
  31098. static QueueNewFrame(func: () => void, requester?: any): number;
  31099. /**
  31100. * Ask the browser to promote the current element to fullscreen rendering mode
  31101. * @param element defines the DOM element to promote
  31102. */
  31103. static RequestFullscreen(element: HTMLElement): void;
  31104. /**
  31105. * Asks the browser to exit fullscreen mode
  31106. */
  31107. static ExitFullscreen(): void;
  31108. /**
  31109. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31110. * @param url define the url we are trying
  31111. * @param element define the dom element where to configure the cors policy
  31112. */
  31113. static SetCorsBehavior(url: string | string[], element: {
  31114. crossOrigin: string | null;
  31115. }): void;
  31116. /**
  31117. * Removes unwanted characters from an url
  31118. * @param url defines the url to clean
  31119. * @returns the cleaned url
  31120. */
  31121. static CleanUrl(url: string): string;
  31122. /**
  31123. * Gets or sets a function used to pre-process url before using them to load assets
  31124. */
  31125. static PreprocessUrl: (url: string) => string;
  31126. /**
  31127. * Loads an image as an HTMLImageElement.
  31128. * @param input url string, ArrayBuffer, or Blob to load
  31129. * @param onLoad callback called when the image successfully loads
  31130. * @param onError callback called when the image fails to load
  31131. * @param offlineProvider offline provider for caching
  31132. * @returns the HTMLImageElement of the loaded image
  31133. */
  31134. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31135. /**
  31136. * Loads a file
  31137. * @param url url string, ArrayBuffer, or Blob to load
  31138. * @param onSuccess callback called when the file successfully loads
  31139. * @param onProgress callback called while file is loading (if the server supports this mode)
  31140. * @param offlineProvider defines the offline provider for caching
  31141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31142. * @param onError callback called when the file fails to load
  31143. * @returns a file request object
  31144. */
  31145. 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;
  31146. /**
  31147. * Load a script (identified by an url). When the url returns, the
  31148. * content of this file is added into a new script element, attached to the DOM (body element)
  31149. * @param scriptUrl defines the url of the script to laod
  31150. * @param onSuccess defines the callback called when the script is loaded
  31151. * @param onError defines the callback to call if an error occurs
  31152. */
  31153. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31154. /**
  31155. * Loads a file from a blob
  31156. * @param fileToLoad defines the blob to use
  31157. * @param callback defines the callback to call when data is loaded
  31158. * @param progressCallback defines the callback to call during loading process
  31159. * @returns a file request object
  31160. */
  31161. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31162. /**
  31163. * Loads a file
  31164. * @param fileToLoad defines the file to load
  31165. * @param callback defines the callback to call when data is loaded
  31166. * @param progressCallBack defines the callback to call during loading process
  31167. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31168. * @returns a file request object
  31169. */
  31170. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31171. /**
  31172. * Creates a data url from a given string content
  31173. * @param content defines the content to convert
  31174. * @returns the new data url link
  31175. */
  31176. static FileAsURL(content: string): string;
  31177. /**
  31178. * Format the given number to a specific decimal format
  31179. * @param value defines the number to format
  31180. * @param decimals defines the number of decimals to use
  31181. * @returns the formatted string
  31182. */
  31183. static Format(value: number, decimals?: number): string;
  31184. /**
  31185. * Checks if a given vector is inside a specific range
  31186. * @param v defines the vector to test
  31187. * @param min defines the minimum range
  31188. * @param max defines the maximum range
  31189. */
  31190. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31191. /**
  31192. * Tries to copy an object by duplicating every property
  31193. * @param source defines the source object
  31194. * @param destination defines the target object
  31195. * @param doNotCopyList defines a list of properties to avoid
  31196. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31197. */
  31198. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31199. /**
  31200. * Gets a boolean indicating if the given object has no own property
  31201. * @param obj defines the object to test
  31202. * @returns true if object has no own property
  31203. */
  31204. static IsEmpty(obj: any): boolean;
  31205. /**
  31206. * Function used to register events at window level
  31207. * @param events defines the events to register
  31208. */
  31209. static RegisterTopRootEvents(events: {
  31210. name: string;
  31211. handler: Nullable<(e: FocusEvent) => any>;
  31212. }[]): void;
  31213. /**
  31214. * Function used to unregister events from window level
  31215. * @param events defines the events to unregister
  31216. */
  31217. static UnregisterTopRootEvents(events: {
  31218. name: string;
  31219. handler: Nullable<(e: FocusEvent) => any>;
  31220. }[]): void;
  31221. /**
  31222. * @ignore
  31223. */
  31224. static _ScreenshotCanvas: HTMLCanvasElement;
  31225. /**
  31226. * Dumps the current bound framebuffer
  31227. * @param width defines the rendering width
  31228. * @param height defines the rendering height
  31229. * @param engine defines the hosting engine
  31230. * @param successCallback defines the callback triggered once the data are available
  31231. * @param mimeType defines the mime type of the result
  31232. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31233. */
  31234. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31235. /**
  31236. * Converts the canvas data to blob.
  31237. * This acts as a polyfill for browsers not supporting the to blob function.
  31238. * @param canvas Defines the canvas to extract the data from
  31239. * @param successCallback Defines the callback triggered once the data are available
  31240. * @param mimeType Defines the mime type of the result
  31241. */
  31242. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31243. /**
  31244. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31245. * @param successCallback defines the callback triggered once the data are available
  31246. * @param mimeType defines the mime type of the result
  31247. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31248. */
  31249. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31250. /**
  31251. * Downloads a blob in the browser
  31252. * @param blob defines the blob to download
  31253. * @param fileName defines the name of the downloaded file
  31254. */
  31255. static Download(blob: Blob, fileName: string): void;
  31256. /**
  31257. * Captures a screenshot of the current rendering
  31258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31259. * @param engine defines the rendering engine
  31260. * @param camera defines the source camera
  31261. * @param size This parameter can be set to a single number or to an object with the
  31262. * following (optional) properties: precision, width, height. If a single number is passed,
  31263. * it will be used for both width and height. If an object is passed, the screenshot size
  31264. * will be derived from the parameters. The precision property is a multiplier allowing
  31265. * rendering at a higher or lower resolution
  31266. * @param successCallback defines the callback receives a single parameter which contains the
  31267. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31268. * src parameter of an <img> to display it
  31269. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31270. * Check your browser for supported MIME types
  31271. */
  31272. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31273. /**
  31274. * Generates an image screenshot from the specified camera.
  31275. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31276. * @param engine The engine to use for rendering
  31277. * @param camera The camera to use for rendering
  31278. * @param size This parameter can be set to a single number or to an object with the
  31279. * following (optional) properties: precision, width, height. If a single number is passed,
  31280. * it will be used for both width and height. If an object is passed, the screenshot size
  31281. * will be derived from the parameters. The precision property is a multiplier allowing
  31282. * rendering at a higher or lower resolution
  31283. * @param successCallback The callback receives a single parameter which contains the
  31284. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31285. * src parameter of an <img> to display it
  31286. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31287. * Check your browser for supported MIME types
  31288. * @param samples Texture samples (default: 1)
  31289. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31290. * @param fileName A name for for the downloaded file.
  31291. */
  31292. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31293. /**
  31294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31295. * Be aware Math.random() could cause collisions, but:
  31296. * "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"
  31297. * @returns a pseudo random id
  31298. */
  31299. static RandomId(): string;
  31300. /**
  31301. * Test if the given uri is a base64 string
  31302. * @param uri The uri to test
  31303. * @return True if the uri is a base64 string or false otherwise
  31304. */
  31305. static IsBase64(uri: string): boolean;
  31306. /**
  31307. * Decode the given base64 uri.
  31308. * @param uri The uri to decode
  31309. * @return The decoded base64 data.
  31310. */
  31311. static DecodeBase64(uri: string): ArrayBuffer;
  31312. /**
  31313. * No log
  31314. */
  31315. static readonly NoneLogLevel: number;
  31316. /**
  31317. * Only message logs
  31318. */
  31319. static readonly MessageLogLevel: number;
  31320. /**
  31321. * Only warning logs
  31322. */
  31323. static readonly WarningLogLevel: number;
  31324. /**
  31325. * Only error logs
  31326. */
  31327. static readonly ErrorLogLevel: number;
  31328. /**
  31329. * All logs
  31330. */
  31331. static readonly AllLogLevel: number;
  31332. /**
  31333. * Gets a value indicating the number of loading errors
  31334. * @ignorenaming
  31335. */
  31336. static readonly errorsCount: number;
  31337. /**
  31338. * Callback called when a new log is added
  31339. */
  31340. static OnNewCacheEntry: (entry: string) => void;
  31341. /**
  31342. * Log a message to the console
  31343. * @param message defines the message to log
  31344. */
  31345. static Log(message: string): void;
  31346. /**
  31347. * Write a warning message to the console
  31348. * @param message defines the message to log
  31349. */
  31350. static Warn(message: string): void;
  31351. /**
  31352. * Write an error message to the console
  31353. * @param message defines the message to log
  31354. */
  31355. static Error(message: string): void;
  31356. /**
  31357. * Gets current log cache (list of logs)
  31358. */
  31359. static readonly LogCache: string;
  31360. /**
  31361. * Clears the log cache
  31362. */
  31363. static ClearLogCache(): void;
  31364. /**
  31365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31366. */
  31367. static LogLevels: number;
  31368. /**
  31369. * Checks if the loaded document was accessed via `file:`-Protocol.
  31370. * @returns boolean
  31371. */
  31372. static IsFileURL(): boolean;
  31373. /**
  31374. * Checks if the window object exists
  31375. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31376. */
  31377. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31378. /**
  31379. * No performance log
  31380. */
  31381. static readonly PerformanceNoneLogLevel: number;
  31382. /**
  31383. * Use user marks to log performance
  31384. */
  31385. static readonly PerformanceUserMarkLogLevel: number;
  31386. /**
  31387. * Log performance to the console
  31388. */
  31389. static readonly PerformanceConsoleLogLevel: number;
  31390. private static _performance;
  31391. /**
  31392. * Sets the current performance log level
  31393. */
  31394. static PerformanceLogLevel: number;
  31395. private static _StartPerformanceCounterDisabled;
  31396. private static _EndPerformanceCounterDisabled;
  31397. private static _StartUserMark;
  31398. private static _EndUserMark;
  31399. private static _StartPerformanceConsole;
  31400. private static _EndPerformanceConsole;
  31401. /**
  31402. * Starts a performance counter
  31403. */
  31404. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31405. /**
  31406. * Ends a specific performance coutner
  31407. */
  31408. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31409. /**
  31410. * Gets either window.performance.now() if supported or Date.now() else
  31411. */
  31412. static readonly Now: number;
  31413. /**
  31414. * This method will return the name of the class used to create the instance of the given object.
  31415. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31416. * @param object the object to get the class name from
  31417. * @param isType defines if the object is actually a type
  31418. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31419. */
  31420. static GetClassName(object: any, isType?: boolean): string;
  31421. /**
  31422. * Gets the first element of an array satisfying a given predicate
  31423. * @param array defines the array to browse
  31424. * @param predicate defines the predicate to use
  31425. * @returns null if not found or the element
  31426. */
  31427. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31428. /**
  31429. * This method will return the name of the full name of the class, including its owning module (if any).
  31430. * 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).
  31431. * @param object the object to get the class name from
  31432. * @param isType defines if the object is actually a type
  31433. * @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.
  31434. * @ignorenaming
  31435. */
  31436. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31437. /**
  31438. * Returns a promise that resolves after the given amount of time.
  31439. * @param delay Number of milliseconds to delay
  31440. * @returns Promise that resolves after the given amount of time
  31441. */
  31442. static DelayAsync(delay: number): Promise<void>;
  31443. /**
  31444. * Gets the current gradient from an array of IValueGradient
  31445. * @param ratio defines the current ratio to get
  31446. * @param gradients defines the array of IValueGradient
  31447. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31448. */
  31449. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31450. }
  31451. /**
  31452. * This class is used to track a performance counter which is number based.
  31453. * The user has access to many properties which give statistics of different nature.
  31454. *
  31455. * The implementer can track two kinds of Performance Counter: time and count.
  31456. * 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.
  31457. * 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.
  31458. */
  31459. export class PerfCounter {
  31460. /**
  31461. * Gets or sets a global boolean to turn on and off all the counters
  31462. */
  31463. static Enabled: boolean;
  31464. /**
  31465. * Returns the smallest value ever
  31466. */
  31467. readonly min: number;
  31468. /**
  31469. * Returns the biggest value ever
  31470. */
  31471. readonly max: number;
  31472. /**
  31473. * Returns the average value since the performance counter is running
  31474. */
  31475. readonly average: number;
  31476. /**
  31477. * Returns the average value of the last second the counter was monitored
  31478. */
  31479. readonly lastSecAverage: number;
  31480. /**
  31481. * Returns the current value
  31482. */
  31483. readonly current: number;
  31484. /**
  31485. * Gets the accumulated total
  31486. */
  31487. readonly total: number;
  31488. /**
  31489. * Gets the total value count
  31490. */
  31491. readonly count: number;
  31492. /**
  31493. * Creates a new counter
  31494. */
  31495. constructor();
  31496. /**
  31497. * Call this method to start monitoring a new frame.
  31498. * 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.
  31499. */
  31500. fetchNewFrame(): void;
  31501. /**
  31502. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31503. * @param newCount the count value to add to the monitored count
  31504. * @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.
  31505. */
  31506. addCount(newCount: number, fetchResult: boolean): void;
  31507. /**
  31508. * Start monitoring this performance counter
  31509. */
  31510. beginMonitoring(): void;
  31511. /**
  31512. * Compute the time lapsed since the previous beginMonitoring() call.
  31513. * @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
  31514. */
  31515. endMonitoring(newFrame?: boolean): void;
  31516. private _fetchResult;
  31517. private _startMonitoringTime;
  31518. private _min;
  31519. private _max;
  31520. private _average;
  31521. private _current;
  31522. private _totalValueCount;
  31523. private _totalAccumulated;
  31524. private _lastSecAverage;
  31525. private _lastSecAccumulated;
  31526. private _lastSecTime;
  31527. private _lastSecValueCount;
  31528. }
  31529. /**
  31530. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31531. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31532. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31533. * @param name The name of the class, case should be preserved
  31534. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31535. */
  31536. export function className(name: string, module?: string): (target: Object) => void;
  31537. /**
  31538. * An implementation of a loop for asynchronous functions.
  31539. */
  31540. export class AsyncLoop {
  31541. /**
  31542. * Defines the number of iterations for the loop
  31543. */
  31544. iterations: number;
  31545. /**
  31546. * Defines the current index of the loop.
  31547. */
  31548. index: number;
  31549. private _done;
  31550. private _fn;
  31551. private _successCallback;
  31552. /**
  31553. * Constructor.
  31554. * @param iterations the number of iterations.
  31555. * @param func the function to run each iteration
  31556. * @param successCallback the callback that will be called upon succesful execution
  31557. * @param offset starting offset.
  31558. */
  31559. constructor(
  31560. /**
  31561. * Defines the number of iterations for the loop
  31562. */
  31563. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31564. /**
  31565. * Execute the next iteration. Must be called after the last iteration was finished.
  31566. */
  31567. executeNext(): void;
  31568. /**
  31569. * Break the loop and run the success callback.
  31570. */
  31571. breakLoop(): void;
  31572. /**
  31573. * Create and run an async loop.
  31574. * @param iterations the number of iterations.
  31575. * @param fn the function to run each iteration
  31576. * @param successCallback the callback that will be called upon succesful execution
  31577. * @param offset starting offset.
  31578. * @returns the created async loop object
  31579. */
  31580. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31581. /**
  31582. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31583. * @param iterations total number of iterations
  31584. * @param syncedIterations number of synchronous iterations in each async iteration.
  31585. * @param fn the function to call each iteration.
  31586. * @param callback a success call back that will be called when iterating stops.
  31587. * @param breakFunction a break condition (optional)
  31588. * @param timeout timeout settings for the setTimeout function. default - 0.
  31589. * @returns the created async loop object
  31590. */
  31591. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31592. }
  31593. }
  31594. declare module "babylonjs/Collisions/collisionCoordinator" {
  31595. import { Nullable } from "babylonjs/types";
  31596. import { Scene } from "babylonjs/scene";
  31597. import { Vector3 } from "babylonjs/Maths/math";
  31598. import { Collider } from "babylonjs/Collisions/collider";
  31599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31600. /** @hidden */
  31601. export interface ICollisionCoordinator {
  31602. createCollider(): Collider;
  31603. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31604. init(scene: Scene): void;
  31605. }
  31606. /** @hidden */
  31607. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31608. private _scene;
  31609. private _scaledPosition;
  31610. private _scaledVelocity;
  31611. private _finalPosition;
  31612. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31613. createCollider(): Collider;
  31614. init(scene: Scene): void;
  31615. private _collideWithWorld;
  31616. }
  31617. }
  31618. declare module "babylonjs/Animations/animationGroup" {
  31619. import { Animatable } from "babylonjs/Animations/animatable";
  31620. import { Animation } from "babylonjs/Animations/animation";
  31621. import { Scene, IDisposable } from "babylonjs/scene";
  31622. import { Observable } from "babylonjs/Misc/observable";
  31623. import { Nullable } from "babylonjs/types";
  31624. /**
  31625. * This class defines the direct association between an animation and a target
  31626. */
  31627. export class TargetedAnimation {
  31628. /**
  31629. * Animation to perform
  31630. */
  31631. animation: Animation;
  31632. /**
  31633. * Target to animate
  31634. */
  31635. target: any;
  31636. }
  31637. /**
  31638. * Use this class to create coordinated animations on multiple targets
  31639. */
  31640. export class AnimationGroup implements IDisposable {
  31641. /** The name of the animation group */
  31642. name: string;
  31643. private _scene;
  31644. private _targetedAnimations;
  31645. private _animatables;
  31646. private _from;
  31647. private _to;
  31648. private _isStarted;
  31649. private _isPaused;
  31650. private _speedRatio;
  31651. /**
  31652. * Gets or sets the unique id of the node
  31653. */
  31654. uniqueId: number;
  31655. /**
  31656. * This observable will notify when one animation have ended
  31657. */
  31658. onAnimationEndObservable: Observable<TargetedAnimation>;
  31659. /**
  31660. * Observer raised when one animation loops
  31661. */
  31662. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31663. /**
  31664. * This observable will notify when all animations have ended.
  31665. */
  31666. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31667. /**
  31668. * This observable will notify when all animations have paused.
  31669. */
  31670. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31671. /**
  31672. * This observable will notify when all animations are playing.
  31673. */
  31674. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31675. /**
  31676. * Gets the first frame
  31677. */
  31678. readonly from: number;
  31679. /**
  31680. * Gets the last frame
  31681. */
  31682. readonly to: number;
  31683. /**
  31684. * Define if the animations are started
  31685. */
  31686. readonly isStarted: boolean;
  31687. /**
  31688. * Gets a value indicating that the current group is playing
  31689. */
  31690. readonly isPlaying: boolean;
  31691. /**
  31692. * Gets or sets the speed ratio to use for all animations
  31693. */
  31694. /**
  31695. * Gets or sets the speed ratio to use for all animations
  31696. */
  31697. speedRatio: number;
  31698. /**
  31699. * Gets the targeted animations for this animation group
  31700. */
  31701. readonly targetedAnimations: Array<TargetedAnimation>;
  31702. /**
  31703. * returning the list of animatables controlled by this animation group.
  31704. */
  31705. readonly animatables: Array<Animatable>;
  31706. /**
  31707. * Instantiates a new Animation Group.
  31708. * This helps managing several animations at once.
  31709. * @see http://doc.babylonjs.com/how_to/group
  31710. * @param name Defines the name of the group
  31711. * @param scene Defines the scene the group belongs to
  31712. */
  31713. constructor(
  31714. /** The name of the animation group */
  31715. name: string, scene?: Nullable<Scene>);
  31716. /**
  31717. * Add an animation (with its target) in the group
  31718. * @param animation defines the animation we want to add
  31719. * @param target defines the target of the animation
  31720. * @returns the TargetedAnimation object
  31721. */
  31722. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31723. /**
  31724. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31725. * It can add constant keys at begin or end
  31726. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31727. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31728. * @returns the animation group
  31729. */
  31730. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31731. /**
  31732. * Start all animations on given targets
  31733. * @param loop defines if animations must loop
  31734. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31735. * @param from defines the from key (optional)
  31736. * @param to defines the to key (optional)
  31737. * @returns the current animation group
  31738. */
  31739. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31740. /**
  31741. * Pause all animations
  31742. * @returns the animation group
  31743. */
  31744. pause(): AnimationGroup;
  31745. /**
  31746. * Play all animations to initial state
  31747. * This function will start() the animations if they were not started or will restart() them if they were paused
  31748. * @param loop defines if animations must loop
  31749. * @returns the animation group
  31750. */
  31751. play(loop?: boolean): AnimationGroup;
  31752. /**
  31753. * Reset all animations to initial state
  31754. * @returns the animation group
  31755. */
  31756. reset(): AnimationGroup;
  31757. /**
  31758. * Restart animations from key 0
  31759. * @returns the animation group
  31760. */
  31761. restart(): AnimationGroup;
  31762. /**
  31763. * Stop all animations
  31764. * @returns the animation group
  31765. */
  31766. stop(): AnimationGroup;
  31767. /**
  31768. * Set animation weight for all animatables
  31769. * @param weight defines the weight to use
  31770. * @return the animationGroup
  31771. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31772. */
  31773. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31774. /**
  31775. * Synchronize and normalize all animatables with a source animatable
  31776. * @param root defines the root animatable to synchronize with
  31777. * @return the animationGroup
  31778. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31779. */
  31780. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31781. /**
  31782. * Goes to a specific frame in this animation group
  31783. * @param frame the frame number to go to
  31784. * @return the animationGroup
  31785. */
  31786. goToFrame(frame: number): AnimationGroup;
  31787. /**
  31788. * Dispose all associated resources
  31789. */
  31790. dispose(): void;
  31791. private _checkAnimationGroupEnded;
  31792. /**
  31793. * Clone the current animation group and returns a copy
  31794. * @param newName defines the name of the new group
  31795. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31796. * @returns the new aniamtion group
  31797. */
  31798. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31799. /**
  31800. * Returns a new AnimationGroup object parsed from the source provided.
  31801. * @param parsedAnimationGroup defines the source
  31802. * @param scene defines the scene that will receive the animationGroup
  31803. * @returns a new AnimationGroup
  31804. */
  31805. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31806. /**
  31807. * Returns the string "AnimationGroup"
  31808. * @returns "AnimationGroup"
  31809. */
  31810. getClassName(): string;
  31811. /**
  31812. * Creates a detailled string about the object
  31813. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31814. * @returns a string representing the object
  31815. */
  31816. toString(fullDetails?: boolean): string;
  31817. }
  31818. }
  31819. declare module "babylonjs/scene" {
  31820. import { Nullable } from "babylonjs/types";
  31821. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31822. import { Observable } from "babylonjs/Misc/observable";
  31823. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31824. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31825. import { Geometry } from "babylonjs/Meshes/geometry";
  31826. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31827. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31829. import { Mesh } from "babylonjs/Meshes/mesh";
  31830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31831. import { Bone } from "babylonjs/Bones/bone";
  31832. import { Skeleton } from "babylonjs/Bones/skeleton";
  31833. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31834. import { Camera } from "babylonjs/Cameras/camera";
  31835. import { AbstractScene } from "babylonjs/abstractScene";
  31836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31838. import { Material } from "babylonjs/Materials/material";
  31839. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31840. import { Effect } from "babylonjs/Materials/effect";
  31841. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31842. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31843. import { Light } from "babylonjs/Lights/light";
  31844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31845. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31846. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31847. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31849. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31851. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31852. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31853. import { Engine } from "babylonjs/Engines/engine";
  31854. import { Node } from "babylonjs/node";
  31855. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31856. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31857. import { WebRequest } from "babylonjs/Misc/webRequest";
  31858. import { Ray } from "babylonjs/Culling/ray";
  31859. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31860. import { Animation } from "babylonjs/Animations/animation";
  31861. import { Animatable } from "babylonjs/Animations/animatable";
  31862. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31863. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31864. import { Collider } from "babylonjs/Collisions/collider";
  31865. /**
  31866. * Define an interface for all classes that will hold resources
  31867. */
  31868. export interface IDisposable {
  31869. /**
  31870. * Releases all held resources
  31871. */
  31872. dispose(): void;
  31873. }
  31874. /** Interface defining initialization parameters for Scene class */
  31875. export interface SceneOptions {
  31876. /**
  31877. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31878. * It will improve performance when the number of geometries becomes important.
  31879. */
  31880. useGeometryUniqueIdsMap?: boolean;
  31881. /**
  31882. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31883. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31884. */
  31885. useMaterialMeshMap?: boolean;
  31886. /**
  31887. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31888. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31889. */
  31890. useClonedMeshhMap?: boolean;
  31891. }
  31892. /**
  31893. * Represents a scene to be rendered by the engine.
  31894. * @see http://doc.babylonjs.com/features/scene
  31895. */
  31896. export class Scene extends AbstractScene implements IAnimatable {
  31897. private static _uniqueIdCounter;
  31898. /** The fog is deactivated */
  31899. static readonly FOGMODE_NONE: number;
  31900. /** The fog density is following an exponential function */
  31901. static readonly FOGMODE_EXP: number;
  31902. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31903. static readonly FOGMODE_EXP2: number;
  31904. /** The fog density is following a linear function. */
  31905. static readonly FOGMODE_LINEAR: number;
  31906. /**
  31907. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31909. */
  31910. static MinDeltaTime: number;
  31911. /**
  31912. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31914. */
  31915. static MaxDeltaTime: number;
  31916. /**
  31917. * Factory used to create the default material.
  31918. * @param name The name of the material to create
  31919. * @param scene The scene to create the material for
  31920. * @returns The default material
  31921. */
  31922. static DefaultMaterialFactory(scene: Scene): Material;
  31923. /**
  31924. * Factory used to create the a collision coordinator.
  31925. * @returns The collision coordinator
  31926. */
  31927. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31928. /** @hidden */
  31929. readonly _isScene: boolean;
  31930. /**
  31931. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31932. */
  31933. autoClear: boolean;
  31934. /**
  31935. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31936. */
  31937. autoClearDepthAndStencil: boolean;
  31938. /**
  31939. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31940. */
  31941. clearColor: Color4;
  31942. /**
  31943. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31944. */
  31945. ambientColor: Color3;
  31946. /** @hidden */
  31947. _environmentBRDFTexture: BaseTexture;
  31948. /** @hidden */
  31949. protected _environmentTexture: Nullable<BaseTexture>;
  31950. /**
  31951. * Texture used in all pbr material as the reflection texture.
  31952. * As in the majority of the scene they are the same (exception for multi room and so on),
  31953. * this is easier to reference from here than from all the materials.
  31954. */
  31955. /**
  31956. * Texture used in all pbr material as the reflection texture.
  31957. * As in the majority of the scene they are the same (exception for multi room and so on),
  31958. * this is easier to set here than in all the materials.
  31959. */
  31960. environmentTexture: Nullable<BaseTexture>;
  31961. /** @hidden */
  31962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31963. /**
  31964. * Default image processing configuration used either in the rendering
  31965. * Forward main pass or through the imageProcessingPostProcess if present.
  31966. * As in the majority of the scene they are the same (exception for multi camera),
  31967. * this is easier to reference from here than from all the materials and post process.
  31968. *
  31969. * No setter as we it is a shared configuration, you can set the values instead.
  31970. */
  31971. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31972. private _forceWireframe;
  31973. /**
  31974. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31975. */
  31976. forceWireframe: boolean;
  31977. private _forcePointsCloud;
  31978. /**
  31979. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31980. */
  31981. forcePointsCloud: boolean;
  31982. /**
  31983. * Gets or sets the active clipplane 1
  31984. */
  31985. clipPlane: Nullable<Plane>;
  31986. /**
  31987. * Gets or sets the active clipplane 2
  31988. */
  31989. clipPlane2: Nullable<Plane>;
  31990. /**
  31991. * Gets or sets the active clipplane 3
  31992. */
  31993. clipPlane3: Nullable<Plane>;
  31994. /**
  31995. * Gets or sets the active clipplane 4
  31996. */
  31997. clipPlane4: Nullable<Plane>;
  31998. /**
  31999. * Gets or sets a boolean indicating if animations are enabled
  32000. */
  32001. animationsEnabled: boolean;
  32002. private _animationPropertiesOverride;
  32003. /**
  32004. * Gets or sets the animation properties override
  32005. */
  32006. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32007. /**
  32008. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32009. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32010. */
  32011. useConstantAnimationDeltaTime: boolean;
  32012. /**
  32013. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32014. * Please note that it requires to run a ray cast through the scene on every frame
  32015. */
  32016. constantlyUpdateMeshUnderPointer: boolean;
  32017. /**
  32018. * Defines the HTML cursor to use when hovering over interactive elements
  32019. */
  32020. hoverCursor: string;
  32021. /**
  32022. * Defines the HTML default cursor to use (empty by default)
  32023. */
  32024. defaultCursor: string;
  32025. /**
  32026. * This is used to call preventDefault() on pointer down
  32027. * in order to block unwanted artifacts like system double clicks
  32028. */
  32029. preventDefaultOnPointerDown: boolean;
  32030. /**
  32031. * This is used to call preventDefault() on pointer up
  32032. * in order to block unwanted artifacts like system double clicks
  32033. */
  32034. preventDefaultOnPointerUp: boolean;
  32035. /**
  32036. * Gets or sets user defined metadata
  32037. */
  32038. metadata: any;
  32039. /**
  32040. * For internal use only. Please do not use.
  32041. */
  32042. reservedDataStore: any;
  32043. /**
  32044. * Gets the name of the plugin used to load this scene (null by default)
  32045. */
  32046. loadingPluginName: string;
  32047. /**
  32048. * Use this array to add regular expressions used to disable offline support for specific urls
  32049. */
  32050. disableOfflineSupportExceptionRules: RegExp[];
  32051. /**
  32052. * An event triggered when the scene is disposed.
  32053. */
  32054. onDisposeObservable: Observable<Scene>;
  32055. private _onDisposeObserver;
  32056. /** Sets a function to be executed when this scene is disposed. */
  32057. onDispose: () => void;
  32058. /**
  32059. * An event triggered before rendering the scene (right after animations and physics)
  32060. */
  32061. onBeforeRenderObservable: Observable<Scene>;
  32062. private _onBeforeRenderObserver;
  32063. /** Sets a function to be executed before rendering this scene */
  32064. beforeRender: Nullable<() => void>;
  32065. /**
  32066. * An event triggered after rendering the scene
  32067. */
  32068. onAfterRenderObservable: Observable<Scene>;
  32069. private _onAfterRenderObserver;
  32070. /** Sets a function to be executed after rendering this scene */
  32071. afterRender: Nullable<() => void>;
  32072. /**
  32073. * An event triggered before animating the scene
  32074. */
  32075. onBeforeAnimationsObservable: Observable<Scene>;
  32076. /**
  32077. * An event triggered after animations processing
  32078. */
  32079. onAfterAnimationsObservable: Observable<Scene>;
  32080. /**
  32081. * An event triggered before draw calls are ready to be sent
  32082. */
  32083. onBeforeDrawPhaseObservable: Observable<Scene>;
  32084. /**
  32085. * An event triggered after draw calls have been sent
  32086. */
  32087. onAfterDrawPhaseObservable: Observable<Scene>;
  32088. /**
  32089. * An event triggered when the scene is ready
  32090. */
  32091. onReadyObservable: Observable<Scene>;
  32092. /**
  32093. * An event triggered before rendering a camera
  32094. */
  32095. onBeforeCameraRenderObservable: Observable<Camera>;
  32096. private _onBeforeCameraRenderObserver;
  32097. /** Sets a function to be executed before rendering a camera*/
  32098. beforeCameraRender: () => void;
  32099. /**
  32100. * An event triggered after rendering a camera
  32101. */
  32102. onAfterCameraRenderObservable: Observable<Camera>;
  32103. private _onAfterCameraRenderObserver;
  32104. /** Sets a function to be executed after rendering a camera*/
  32105. afterCameraRender: () => void;
  32106. /**
  32107. * An event triggered when active meshes evaluation is about to start
  32108. */
  32109. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32110. /**
  32111. * An event triggered when active meshes evaluation is done
  32112. */
  32113. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32114. /**
  32115. * An event triggered when particles rendering is about to start
  32116. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32117. */
  32118. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32119. /**
  32120. * An event triggered when particles rendering is done
  32121. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32122. */
  32123. onAfterParticlesRenderingObservable: Observable<Scene>;
  32124. /**
  32125. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32126. */
  32127. onDataLoadedObservable: Observable<Scene>;
  32128. /**
  32129. * An event triggered when a camera is created
  32130. */
  32131. onNewCameraAddedObservable: Observable<Camera>;
  32132. /**
  32133. * An event triggered when a camera is removed
  32134. */
  32135. onCameraRemovedObservable: Observable<Camera>;
  32136. /**
  32137. * An event triggered when a light is created
  32138. */
  32139. onNewLightAddedObservable: Observable<Light>;
  32140. /**
  32141. * An event triggered when a light is removed
  32142. */
  32143. onLightRemovedObservable: Observable<Light>;
  32144. /**
  32145. * An event triggered when a geometry is created
  32146. */
  32147. onNewGeometryAddedObservable: Observable<Geometry>;
  32148. /**
  32149. * An event triggered when a geometry is removed
  32150. */
  32151. onGeometryRemovedObservable: Observable<Geometry>;
  32152. /**
  32153. * An event triggered when a transform node is created
  32154. */
  32155. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32156. /**
  32157. * An event triggered when a transform node is removed
  32158. */
  32159. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32160. /**
  32161. * An event triggered when a mesh is created
  32162. */
  32163. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32164. /**
  32165. * An event triggered when a mesh is removed
  32166. */
  32167. onMeshRemovedObservable: Observable<AbstractMesh>;
  32168. /**
  32169. * An event triggered when a skeleton is created
  32170. */
  32171. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32172. /**
  32173. * An event triggered when a skeleton is removed
  32174. */
  32175. onSkeletonRemovedObservable: Observable<Skeleton>;
  32176. /**
  32177. * An event triggered when a material is created
  32178. */
  32179. onNewMaterialAddedObservable: Observable<Material>;
  32180. /**
  32181. * An event triggered when a material is removed
  32182. */
  32183. onMaterialRemovedObservable: Observable<Material>;
  32184. /**
  32185. * An event triggered when a texture is created
  32186. */
  32187. onNewTextureAddedObservable: Observable<BaseTexture>;
  32188. /**
  32189. * An event triggered when a texture is removed
  32190. */
  32191. onTextureRemovedObservable: Observable<BaseTexture>;
  32192. /**
  32193. * An event triggered when render targets are about to be rendered
  32194. * Can happen multiple times per frame.
  32195. */
  32196. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32197. /**
  32198. * An event triggered when render targets were rendered.
  32199. * Can happen multiple times per frame.
  32200. */
  32201. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32202. /**
  32203. * An event triggered before calculating deterministic simulation step
  32204. */
  32205. onBeforeStepObservable: Observable<Scene>;
  32206. /**
  32207. * An event triggered after calculating deterministic simulation step
  32208. */
  32209. onAfterStepObservable: Observable<Scene>;
  32210. /**
  32211. * An event triggered when the activeCamera property is updated
  32212. */
  32213. onActiveCameraChanged: Observable<Scene>;
  32214. /**
  32215. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32216. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32217. * 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)
  32218. */
  32219. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32220. /**
  32221. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32222. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32223. * 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)
  32224. */
  32225. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32226. /**
  32227. * This Observable will when a mesh has been imported into the scene.
  32228. */
  32229. onMeshImportedObservable: Observable<AbstractMesh>;
  32230. /**
  32231. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32232. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32233. */
  32234. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32235. /** @hidden */
  32236. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32237. /**
  32238. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32239. */
  32240. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32241. /**
  32242. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32243. */
  32244. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32245. /**
  32246. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32247. */
  32248. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32249. private _onPointerMove;
  32250. private _onPointerDown;
  32251. private _onPointerUp;
  32252. /** Callback called when a pointer move is detected */
  32253. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32254. /** Callback called when a pointer down is detected */
  32255. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32256. /** Callback called when a pointer up is detected */
  32257. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32258. /** Callback called when a pointer pick is detected */
  32259. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32260. /**
  32261. * 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).
  32262. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32263. */
  32264. onPrePointerObservable: Observable<PointerInfoPre>;
  32265. /**
  32266. * Observable event triggered each time an input event is received from the rendering canvas
  32267. */
  32268. onPointerObservable: Observable<PointerInfo>;
  32269. /**
  32270. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32271. */
  32272. readonly unTranslatedPointer: Vector2;
  32273. /** The distance in pixel that you have to move to prevent some events */
  32274. static DragMovementThreshold: number;
  32275. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32276. static LongPressDelay: number;
  32277. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32278. static DoubleClickDelay: number;
  32279. /** If you need to check double click without raising a single click at first click, enable this flag */
  32280. static ExclusiveDoubleClickMode: boolean;
  32281. private _initClickEvent;
  32282. private _initActionManager;
  32283. private _delayedSimpleClick;
  32284. private _delayedSimpleClickTimeout;
  32285. private _previousDelayedSimpleClickTimeout;
  32286. private _meshPickProceed;
  32287. private _previousButtonPressed;
  32288. private _currentPickResult;
  32289. private _previousPickResult;
  32290. private _totalPointersPressed;
  32291. private _doubleClickOccured;
  32292. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32293. cameraToUseForPointers: Nullable<Camera>;
  32294. private _pointerX;
  32295. private _pointerY;
  32296. private _unTranslatedPointerX;
  32297. private _unTranslatedPointerY;
  32298. private _startingPointerPosition;
  32299. private _previousStartingPointerPosition;
  32300. private _startingPointerTime;
  32301. private _previousStartingPointerTime;
  32302. private _pointerCaptures;
  32303. private _timeAccumulator;
  32304. private _currentStepId;
  32305. private _currentInternalStep;
  32306. /** @hidden */
  32307. _mirroredCameraPosition: Nullable<Vector3>;
  32308. /**
  32309. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32310. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32311. */
  32312. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32313. /**
  32314. * Observable event triggered each time an keyboard event is received from the hosting window
  32315. */
  32316. onKeyboardObservable: Observable<KeyboardInfo>;
  32317. private _onKeyDown;
  32318. private _onKeyUp;
  32319. private _onCanvasFocusObserver;
  32320. private _onCanvasBlurObserver;
  32321. private _useRightHandedSystem;
  32322. /**
  32323. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32324. */
  32325. useRightHandedSystem: boolean;
  32326. /**
  32327. * Sets the step Id used by deterministic lock step
  32328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32329. * @param newStepId defines the step Id
  32330. */
  32331. setStepId(newStepId: number): void;
  32332. /**
  32333. * Gets the step Id used by deterministic lock step
  32334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32335. * @returns the step Id
  32336. */
  32337. getStepId(): number;
  32338. /**
  32339. * Gets the internal step used by deterministic lock step
  32340. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32341. * @returns the internal step
  32342. */
  32343. getInternalStep(): number;
  32344. private _fogEnabled;
  32345. /**
  32346. * Gets or sets a boolean indicating if fog is enabled on this scene
  32347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32348. * (Default is true)
  32349. */
  32350. fogEnabled: boolean;
  32351. private _fogMode;
  32352. /**
  32353. * Gets or sets the fog mode to use
  32354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32355. * | mode | value |
  32356. * | --- | --- |
  32357. * | FOGMODE_NONE | 0 |
  32358. * | FOGMODE_EXP | 1 |
  32359. * | FOGMODE_EXP2 | 2 |
  32360. * | FOGMODE_LINEAR | 3 |
  32361. */
  32362. fogMode: number;
  32363. /**
  32364. * Gets or sets the fog color to use
  32365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32366. * (Default is Color3(0.2, 0.2, 0.3))
  32367. */
  32368. fogColor: Color3;
  32369. /**
  32370. * Gets or sets the fog density to use
  32371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32372. * (Default is 0.1)
  32373. */
  32374. fogDensity: number;
  32375. /**
  32376. * Gets or sets the fog start distance to use
  32377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32378. * (Default is 0)
  32379. */
  32380. fogStart: number;
  32381. /**
  32382. * Gets or sets the fog end distance to use
  32383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32384. * (Default is 1000)
  32385. */
  32386. fogEnd: number;
  32387. private _shadowsEnabled;
  32388. /**
  32389. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32390. */
  32391. shadowsEnabled: boolean;
  32392. private _lightsEnabled;
  32393. /**
  32394. * Gets or sets a boolean indicating if lights are enabled on this scene
  32395. */
  32396. lightsEnabled: boolean;
  32397. /** All of the active cameras added to this scene. */
  32398. activeCameras: Camera[];
  32399. private _activeCamera;
  32400. /** Gets or sets the current active camera */
  32401. activeCamera: Nullable<Camera>;
  32402. private _defaultMaterial;
  32403. /** The default material used on meshes when no material is affected */
  32404. /** The default material used on meshes when no material is affected */
  32405. defaultMaterial: Material;
  32406. private _texturesEnabled;
  32407. /**
  32408. * Gets or sets a boolean indicating if textures are enabled on this scene
  32409. */
  32410. texturesEnabled: boolean;
  32411. /**
  32412. * Gets or sets a boolean indicating if particles are enabled on this scene
  32413. */
  32414. particlesEnabled: boolean;
  32415. /**
  32416. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32417. */
  32418. spritesEnabled: boolean;
  32419. private _skeletonsEnabled;
  32420. /**
  32421. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32422. */
  32423. skeletonsEnabled: boolean;
  32424. /**
  32425. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32426. */
  32427. lensFlaresEnabled: boolean;
  32428. /**
  32429. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32431. */
  32432. collisionsEnabled: boolean;
  32433. private _collisionCoordinator;
  32434. /** @hidden */
  32435. readonly collisionCoordinator: ICollisionCoordinator;
  32436. /**
  32437. * Defines the gravity applied to this scene (used only for collisions)
  32438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32439. */
  32440. gravity: Vector3;
  32441. /**
  32442. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32443. */
  32444. postProcessesEnabled: boolean;
  32445. /**
  32446. * The list of postprocesses added to the scene
  32447. */
  32448. postProcesses: PostProcess[];
  32449. /**
  32450. * Gets the current postprocess manager
  32451. */
  32452. postProcessManager: PostProcessManager;
  32453. /**
  32454. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32455. */
  32456. renderTargetsEnabled: boolean;
  32457. /**
  32458. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32459. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32460. */
  32461. dumpNextRenderTargets: boolean;
  32462. /**
  32463. * The list of user defined render targets added to the scene
  32464. */
  32465. customRenderTargets: RenderTargetTexture[];
  32466. /**
  32467. * Defines if texture loading must be delayed
  32468. * If true, textures will only be loaded when they need to be rendered
  32469. */
  32470. useDelayedTextureLoading: boolean;
  32471. /**
  32472. * Gets the list of meshes imported to the scene through SceneLoader
  32473. */
  32474. importedMeshesFiles: String[];
  32475. /**
  32476. * Gets or sets a boolean indicating if probes are enabled on this scene
  32477. */
  32478. probesEnabled: boolean;
  32479. /**
  32480. * Gets or sets the current offline provider to use to store scene data
  32481. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32482. */
  32483. offlineProvider: IOfflineProvider;
  32484. /**
  32485. * Gets or sets the action manager associated with the scene
  32486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32487. */
  32488. actionManager: AbstractActionManager;
  32489. private _meshesForIntersections;
  32490. /**
  32491. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32492. */
  32493. proceduralTexturesEnabled: boolean;
  32494. private _engine;
  32495. private _totalVertices;
  32496. /** @hidden */
  32497. _activeIndices: PerfCounter;
  32498. /** @hidden */
  32499. _activeParticles: PerfCounter;
  32500. /** @hidden */
  32501. _activeBones: PerfCounter;
  32502. private _animationRatio;
  32503. /** @hidden */
  32504. _animationTimeLast: number;
  32505. /** @hidden */
  32506. _animationTime: number;
  32507. /**
  32508. * Gets or sets a general scale for animation speed
  32509. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32510. */
  32511. animationTimeScale: number;
  32512. /** @hidden */
  32513. _cachedMaterial: Nullable<Material>;
  32514. /** @hidden */
  32515. _cachedEffect: Nullable<Effect>;
  32516. /** @hidden */
  32517. _cachedVisibility: Nullable<number>;
  32518. private _renderId;
  32519. private _frameId;
  32520. private _executeWhenReadyTimeoutId;
  32521. private _intermediateRendering;
  32522. private _viewUpdateFlag;
  32523. private _projectionUpdateFlag;
  32524. private _alternateViewUpdateFlag;
  32525. private _alternateProjectionUpdateFlag;
  32526. /** @hidden */
  32527. _toBeDisposed: Nullable<IDisposable>[];
  32528. private _activeRequests;
  32529. /** @hidden */
  32530. _pendingData: any[];
  32531. private _isDisposed;
  32532. /**
  32533. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32534. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32535. */
  32536. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32537. private _activeMeshes;
  32538. private _processedMaterials;
  32539. private _renderTargets;
  32540. /** @hidden */
  32541. _activeParticleSystems: SmartArray<IParticleSystem>;
  32542. private _activeSkeletons;
  32543. private _softwareSkinnedMeshes;
  32544. private _renderingManager;
  32545. /** @hidden */
  32546. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32547. private _transformMatrix;
  32548. private _sceneUbo;
  32549. private _alternateSceneUbo;
  32550. private _viewMatrix;
  32551. private _projectionMatrix;
  32552. private _alternateViewMatrix;
  32553. private _alternateProjectionMatrix;
  32554. private _alternateTransformMatrix;
  32555. private _useAlternateCameraConfiguration;
  32556. private _alternateRendering;
  32557. private _wheelEventName;
  32558. /** @hidden */
  32559. _forcedViewPosition: Nullable<Vector3>;
  32560. /** @hidden */
  32561. readonly _isAlternateRenderingEnabled: boolean;
  32562. private _frustumPlanes;
  32563. /**
  32564. * Gets the list of frustum planes (built from the active camera)
  32565. */
  32566. readonly frustumPlanes: Plane[];
  32567. /**
  32568. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32569. * This is useful if there are more lights that the maximum simulteanous authorized
  32570. */
  32571. requireLightSorting: boolean;
  32572. /** @hidden */
  32573. readonly useMaterialMeshMap: boolean;
  32574. /** @hidden */
  32575. readonly useClonedMeshhMap: boolean;
  32576. private _pointerOverMesh;
  32577. private _pickedDownMesh;
  32578. private _pickedUpMesh;
  32579. private _externalData;
  32580. private _uid;
  32581. /**
  32582. * @hidden
  32583. * Backing store of defined scene components.
  32584. */
  32585. _components: ISceneComponent[];
  32586. /**
  32587. * @hidden
  32588. * Backing store of defined scene components.
  32589. */
  32590. _serializableComponents: ISceneSerializableComponent[];
  32591. /**
  32592. * List of components to register on the next registration step.
  32593. */
  32594. private _transientComponents;
  32595. /**
  32596. * Registers the transient components if needed.
  32597. */
  32598. private _registerTransientComponents;
  32599. /**
  32600. * @hidden
  32601. * Add a component to the scene.
  32602. * Note that the ccomponent could be registered on th next frame if this is called after
  32603. * the register component stage.
  32604. * @param component Defines the component to add to the scene
  32605. */
  32606. _addComponent(component: ISceneComponent): void;
  32607. /**
  32608. * @hidden
  32609. * Gets a component from the scene.
  32610. * @param name defines the name of the component to retrieve
  32611. * @returns the component or null if not present
  32612. */
  32613. _getComponent(name: string): Nullable<ISceneComponent>;
  32614. /**
  32615. * @hidden
  32616. * Defines the actions happening before camera updates.
  32617. */
  32618. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32619. /**
  32620. * @hidden
  32621. * Defines the actions happening before clear the canvas.
  32622. */
  32623. _beforeClearStage: Stage<SimpleStageAction>;
  32624. /**
  32625. * @hidden
  32626. * Defines the actions when collecting render targets for the frame.
  32627. */
  32628. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32629. /**
  32630. * @hidden
  32631. * Defines the actions happening for one camera in the frame.
  32632. */
  32633. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32634. /**
  32635. * @hidden
  32636. * Defines the actions happening during the per mesh ready checks.
  32637. */
  32638. _isReadyForMeshStage: Stage<MeshStageAction>;
  32639. /**
  32640. * @hidden
  32641. * Defines the actions happening before evaluate active mesh checks.
  32642. */
  32643. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32644. /**
  32645. * @hidden
  32646. * Defines the actions happening during the evaluate sub mesh checks.
  32647. */
  32648. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32649. /**
  32650. * @hidden
  32651. * Defines the actions happening during the active mesh stage.
  32652. */
  32653. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32654. /**
  32655. * @hidden
  32656. * Defines the actions happening during the per camera render target step.
  32657. */
  32658. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32659. /**
  32660. * @hidden
  32661. * Defines the actions happening just before the active camera is drawing.
  32662. */
  32663. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32664. /**
  32665. * @hidden
  32666. * Defines the actions happening just before a render target is drawing.
  32667. */
  32668. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32669. /**
  32670. * @hidden
  32671. * Defines the actions happening just before a rendering group is drawing.
  32672. */
  32673. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32674. /**
  32675. * @hidden
  32676. * Defines the actions happening just before a mesh is drawing.
  32677. */
  32678. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32679. /**
  32680. * @hidden
  32681. * Defines the actions happening just after a mesh has been drawn.
  32682. */
  32683. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32684. /**
  32685. * @hidden
  32686. * Defines the actions happening just after a rendering group has been drawn.
  32687. */
  32688. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32689. /**
  32690. * @hidden
  32691. * Defines the actions happening just after the active camera has been drawn.
  32692. */
  32693. _afterCameraDrawStage: Stage<CameraStageAction>;
  32694. /**
  32695. * @hidden
  32696. * Defines the actions happening just after a render target has been drawn.
  32697. */
  32698. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32699. /**
  32700. * @hidden
  32701. * Defines the actions happening just after rendering all cameras and computing intersections.
  32702. */
  32703. _afterRenderStage: Stage<SimpleStageAction>;
  32704. /**
  32705. * @hidden
  32706. * Defines the actions happening when a pointer move event happens.
  32707. */
  32708. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32709. /**
  32710. * @hidden
  32711. * Defines the actions happening when a pointer down event happens.
  32712. */
  32713. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32714. /**
  32715. * @hidden
  32716. * Defines the actions happening when a pointer up event happens.
  32717. */
  32718. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32719. /**
  32720. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32721. */
  32722. private geometriesByUniqueId;
  32723. /**
  32724. * Creates a new Scene
  32725. * @param engine defines the engine to use to render this scene
  32726. * @param options defines the scene options
  32727. */
  32728. constructor(engine: Engine, options?: SceneOptions);
  32729. private _defaultMeshCandidates;
  32730. /**
  32731. * @hidden
  32732. */
  32733. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32734. private _defaultSubMeshCandidates;
  32735. /**
  32736. * @hidden
  32737. */
  32738. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32739. /**
  32740. * Sets the default candidate providers for the scene.
  32741. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32742. * and getCollidingSubMeshCandidates to their default function
  32743. */
  32744. setDefaultCandidateProviders(): void;
  32745. /**
  32746. * Gets the mesh that is currently under the pointer
  32747. */
  32748. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32749. /**
  32750. * Gets or sets the current on-screen X position of the pointer
  32751. */
  32752. pointerX: number;
  32753. /**
  32754. * Gets or sets the current on-screen Y position of the pointer
  32755. */
  32756. pointerY: number;
  32757. /**
  32758. * Gets the cached material (ie. the latest rendered one)
  32759. * @returns the cached material
  32760. */
  32761. getCachedMaterial(): Nullable<Material>;
  32762. /**
  32763. * Gets the cached effect (ie. the latest rendered one)
  32764. * @returns the cached effect
  32765. */
  32766. getCachedEffect(): Nullable<Effect>;
  32767. /**
  32768. * Gets the cached visibility state (ie. the latest rendered one)
  32769. * @returns the cached visibility state
  32770. */
  32771. getCachedVisibility(): Nullable<number>;
  32772. /**
  32773. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32774. * @param material defines the current material
  32775. * @param effect defines the current effect
  32776. * @param visibility defines the current visibility state
  32777. * @returns true if one parameter is not cached
  32778. */
  32779. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32780. /**
  32781. * Gets the engine associated with the scene
  32782. * @returns an Engine
  32783. */
  32784. getEngine(): Engine;
  32785. /**
  32786. * Gets the total number of vertices rendered per frame
  32787. * @returns the total number of vertices rendered per frame
  32788. */
  32789. getTotalVertices(): number;
  32790. /**
  32791. * Gets the performance counter for total vertices
  32792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32793. */
  32794. readonly totalVerticesPerfCounter: PerfCounter;
  32795. /**
  32796. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32797. * @returns the total number of active indices rendered per frame
  32798. */
  32799. getActiveIndices(): number;
  32800. /**
  32801. * Gets the performance counter for active indices
  32802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32803. */
  32804. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32805. /**
  32806. * Gets the total number of active particles rendered per frame
  32807. * @returns the total number of active particles rendered per frame
  32808. */
  32809. getActiveParticles(): number;
  32810. /**
  32811. * Gets the performance counter for active particles
  32812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32813. */
  32814. readonly activeParticlesPerfCounter: PerfCounter;
  32815. /**
  32816. * Gets the total number of active bones rendered per frame
  32817. * @returns the total number of active bones rendered per frame
  32818. */
  32819. getActiveBones(): number;
  32820. /**
  32821. * Gets the performance counter for active bones
  32822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32823. */
  32824. readonly activeBonesPerfCounter: PerfCounter;
  32825. /**
  32826. * Gets the array of active meshes
  32827. * @returns an array of AbstractMesh
  32828. */
  32829. getActiveMeshes(): SmartArray<AbstractMesh>;
  32830. /**
  32831. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32832. * @returns a number
  32833. */
  32834. getAnimationRatio(): number;
  32835. /**
  32836. * Gets an unique Id for the current render phase
  32837. * @returns a number
  32838. */
  32839. getRenderId(): number;
  32840. /**
  32841. * Gets an unique Id for the current frame
  32842. * @returns a number
  32843. */
  32844. getFrameId(): number;
  32845. /** Call this function if you want to manually increment the render Id*/
  32846. incrementRenderId(): void;
  32847. private _updatePointerPosition;
  32848. private _createUbo;
  32849. private _createAlternateUbo;
  32850. private _setRayOnPointerInfo;
  32851. /**
  32852. * Use this method to simulate a pointer move on a mesh
  32853. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32854. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32855. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32856. * @returns the current scene
  32857. */
  32858. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32859. private _processPointerMove;
  32860. private _checkPrePointerObservable;
  32861. /**
  32862. * Use this method to simulate a pointer down on a mesh
  32863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32866. * @returns the current scene
  32867. */
  32868. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32869. private _processPointerDown;
  32870. /**
  32871. * Use this method to simulate a pointer up on a mesh
  32872. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32873. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32874. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32875. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32876. * @returns the current scene
  32877. */
  32878. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32879. private _processPointerUp;
  32880. /**
  32881. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32882. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32883. * @returns true if the pointer was captured
  32884. */
  32885. isPointerCaptured(pointerId?: number): boolean;
  32886. /** @hidden */
  32887. _isPointerSwiping(): boolean;
  32888. /**
  32889. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32890. * @param attachUp defines if you want to attach events to pointerup
  32891. * @param attachDown defines if you want to attach events to pointerdown
  32892. * @param attachMove defines if you want to attach events to pointermove
  32893. */
  32894. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32895. /** Detaches all event handlers*/
  32896. detachControl(): void;
  32897. /**
  32898. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32899. * Delay loaded resources are not taking in account
  32900. * @return true if all required resources are ready
  32901. */
  32902. isReady(): boolean;
  32903. /** Resets all cached information relative to material (including effect and visibility) */
  32904. resetCachedMaterial(): void;
  32905. /**
  32906. * Registers a function to be called before every frame render
  32907. * @param func defines the function to register
  32908. */
  32909. registerBeforeRender(func: () => void): void;
  32910. /**
  32911. * Unregisters a function called before every frame render
  32912. * @param func defines the function to unregister
  32913. */
  32914. unregisterBeforeRender(func: () => void): void;
  32915. /**
  32916. * Registers a function to be called after every frame render
  32917. * @param func defines the function to register
  32918. */
  32919. registerAfterRender(func: () => void): void;
  32920. /**
  32921. * Unregisters a function called after every frame render
  32922. * @param func defines the function to unregister
  32923. */
  32924. unregisterAfterRender(func: () => void): void;
  32925. private _executeOnceBeforeRender;
  32926. /**
  32927. * The provided function will run before render once and will be disposed afterwards.
  32928. * A timeout delay can be provided so that the function will be executed in N ms.
  32929. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32930. * @param func The function to be executed.
  32931. * @param timeout optional delay in ms
  32932. */
  32933. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32934. /** @hidden */
  32935. _addPendingData(data: any): void;
  32936. /** @hidden */
  32937. _removePendingData(data: any): void;
  32938. /**
  32939. * Returns the number of items waiting to be loaded
  32940. * @returns the number of items waiting to be loaded
  32941. */
  32942. getWaitingItemsCount(): number;
  32943. /**
  32944. * Returns a boolean indicating if the scene is still loading data
  32945. */
  32946. readonly isLoading: boolean;
  32947. /**
  32948. * Registers a function to be executed when the scene is ready
  32949. * @param {Function} func - the function to be executed
  32950. */
  32951. executeWhenReady(func: () => void): void;
  32952. /**
  32953. * Returns a promise that resolves when the scene is ready
  32954. * @returns A promise that resolves when the scene is ready
  32955. */
  32956. whenReadyAsync(): Promise<void>;
  32957. /** @hidden */
  32958. _checkIsReady(): void;
  32959. /**
  32960. * Gets all animatable attached to the scene
  32961. */
  32962. readonly animatables: Animatable[];
  32963. /**
  32964. * Resets the last animation time frame.
  32965. * Useful to override when animations start running when loading a scene for the first time.
  32966. */
  32967. resetLastAnimationTimeFrame(): void;
  32968. /** @hidden */
  32969. _switchToAlternateCameraConfiguration(active: boolean): void;
  32970. /**
  32971. * Gets the current view matrix
  32972. * @returns a Matrix
  32973. */
  32974. getViewMatrix(): Matrix;
  32975. /**
  32976. * Gets the current projection matrix
  32977. * @returns a Matrix
  32978. */
  32979. getProjectionMatrix(): Matrix;
  32980. /**
  32981. * Gets the current transform matrix
  32982. * @returns a Matrix made of View * Projection
  32983. */
  32984. getTransformMatrix(): Matrix;
  32985. /**
  32986. * Sets the current transform matrix
  32987. * @param view defines the View matrix to use
  32988. * @param projection defines the Projection matrix to use
  32989. */
  32990. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32991. /** @hidden */
  32992. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32993. /**
  32994. * Gets the uniform buffer used to store scene data
  32995. * @returns a UniformBuffer
  32996. */
  32997. getSceneUniformBuffer(): UniformBuffer;
  32998. /**
  32999. * Gets an unique (relatively to the current scene) Id
  33000. * @returns an unique number for the scene
  33001. */
  33002. getUniqueId(): number;
  33003. /**
  33004. * Add a mesh to the list of scene's meshes
  33005. * @param newMesh defines the mesh to add
  33006. * @param recursive if all child meshes should also be added to the scene
  33007. */
  33008. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33009. /**
  33010. * Remove a mesh for the list of scene's meshes
  33011. * @param toRemove defines the mesh to remove
  33012. * @param recursive if all child meshes should also be removed from the scene
  33013. * @returns the index where the mesh was in the mesh list
  33014. */
  33015. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33016. /**
  33017. * Add a transform node to the list of scene's transform nodes
  33018. * @param newTransformNode defines the transform node to add
  33019. */
  33020. addTransformNode(newTransformNode: TransformNode): void;
  33021. /**
  33022. * Remove a transform node for the list of scene's transform nodes
  33023. * @param toRemove defines the transform node to remove
  33024. * @returns the index where the transform node was in the transform node list
  33025. */
  33026. removeTransformNode(toRemove: TransformNode): number;
  33027. /**
  33028. * Remove a skeleton for the list of scene's skeletons
  33029. * @param toRemove defines the skeleton to remove
  33030. * @returns the index where the skeleton was in the skeleton list
  33031. */
  33032. removeSkeleton(toRemove: Skeleton): number;
  33033. /**
  33034. * Remove a morph target for the list of scene's morph targets
  33035. * @param toRemove defines the morph target to remove
  33036. * @returns the index where the morph target was in the morph target list
  33037. */
  33038. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33039. /**
  33040. * Remove a light for the list of scene's lights
  33041. * @param toRemove defines the light to remove
  33042. * @returns the index where the light was in the light list
  33043. */
  33044. removeLight(toRemove: Light): number;
  33045. /**
  33046. * Remove a camera for the list of scene's cameras
  33047. * @param toRemove defines the camera to remove
  33048. * @returns the index where the camera was in the camera list
  33049. */
  33050. removeCamera(toRemove: Camera): number;
  33051. /**
  33052. * Remove a particle system for the list of scene's particle systems
  33053. * @param toRemove defines the particle system to remove
  33054. * @returns the index where the particle system was in the particle system list
  33055. */
  33056. removeParticleSystem(toRemove: IParticleSystem): number;
  33057. /**
  33058. * Remove a animation for the list of scene's animations
  33059. * @param toRemove defines the animation to remove
  33060. * @returns the index where the animation was in the animation list
  33061. */
  33062. removeAnimation(toRemove: Animation): number;
  33063. /**
  33064. * Removes the given animation group from this scene.
  33065. * @param toRemove The animation group to remove
  33066. * @returns The index of the removed animation group
  33067. */
  33068. removeAnimationGroup(toRemove: AnimationGroup): number;
  33069. /**
  33070. * Removes the given multi-material from this scene.
  33071. * @param toRemove The multi-material to remove
  33072. * @returns The index of the removed multi-material
  33073. */
  33074. removeMultiMaterial(toRemove: MultiMaterial): number;
  33075. /**
  33076. * Removes the given material from this scene.
  33077. * @param toRemove The material to remove
  33078. * @returns The index of the removed material
  33079. */
  33080. removeMaterial(toRemove: Material): number;
  33081. /**
  33082. * Removes the given action manager from this scene.
  33083. * @param toRemove The action manager to remove
  33084. * @returns The index of the removed action manager
  33085. */
  33086. removeActionManager(toRemove: AbstractActionManager): number;
  33087. /**
  33088. * Removes the given texture from this scene.
  33089. * @param toRemove The texture to remove
  33090. * @returns The index of the removed texture
  33091. */
  33092. removeTexture(toRemove: BaseTexture): number;
  33093. /**
  33094. * Adds the given light to this scene
  33095. * @param newLight The light to add
  33096. */
  33097. addLight(newLight: Light): void;
  33098. /**
  33099. * Sorts the list list based on light priorities
  33100. */
  33101. sortLightsByPriority(): void;
  33102. /**
  33103. * Adds the given camera to this scene
  33104. * @param newCamera The camera to add
  33105. */
  33106. addCamera(newCamera: Camera): void;
  33107. /**
  33108. * Adds the given skeleton to this scene
  33109. * @param newSkeleton The skeleton to add
  33110. */
  33111. addSkeleton(newSkeleton: Skeleton): void;
  33112. /**
  33113. * Adds the given particle system to this scene
  33114. * @param newParticleSystem The particle system to add
  33115. */
  33116. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33117. /**
  33118. * Adds the given animation to this scene
  33119. * @param newAnimation The animation to add
  33120. */
  33121. addAnimation(newAnimation: Animation): void;
  33122. /**
  33123. * Adds the given animation group to this scene.
  33124. * @param newAnimationGroup The animation group to add
  33125. */
  33126. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33127. /**
  33128. * Adds the given multi-material to this scene
  33129. * @param newMultiMaterial The multi-material to add
  33130. */
  33131. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33132. /**
  33133. * Adds the given material to this scene
  33134. * @param newMaterial The material to add
  33135. */
  33136. addMaterial(newMaterial: Material): void;
  33137. /**
  33138. * Adds the given morph target to this scene
  33139. * @param newMorphTargetManager The morph target to add
  33140. */
  33141. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33142. /**
  33143. * Adds the given geometry to this scene
  33144. * @param newGeometry The geometry to add
  33145. */
  33146. addGeometry(newGeometry: Geometry): void;
  33147. /**
  33148. * Adds the given action manager to this scene
  33149. * @param newActionManager The action manager to add
  33150. */
  33151. addActionManager(newActionManager: AbstractActionManager): void;
  33152. /**
  33153. * Adds the given texture to this scene.
  33154. * @param newTexture The texture to add
  33155. */
  33156. addTexture(newTexture: BaseTexture): void;
  33157. /**
  33158. * Switch active camera
  33159. * @param newCamera defines the new active camera
  33160. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33161. */
  33162. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33163. /**
  33164. * sets the active camera of the scene using its ID
  33165. * @param id defines the camera's ID
  33166. * @return the new active camera or null if none found.
  33167. */
  33168. setActiveCameraByID(id: string): Nullable<Camera>;
  33169. /**
  33170. * sets the active camera of the scene using its name
  33171. * @param name defines the camera's name
  33172. * @returns the new active camera or null if none found.
  33173. */
  33174. setActiveCameraByName(name: string): Nullable<Camera>;
  33175. /**
  33176. * get an animation group using its name
  33177. * @param name defines the material's name
  33178. * @return the animation group or null if none found.
  33179. */
  33180. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33181. /**
  33182. * get a material using its id
  33183. * @param id defines the material's ID
  33184. * @return the material or null if none found.
  33185. */
  33186. getMaterialByID(id: string): Nullable<Material>;
  33187. /**
  33188. * Gets a material using its name
  33189. * @param name defines the material's name
  33190. * @return the material or null if none found.
  33191. */
  33192. getMaterialByName(name: string): Nullable<Material>;
  33193. /**
  33194. * Gets a camera using its id
  33195. * @param id defines the id to look for
  33196. * @returns the camera or null if not found
  33197. */
  33198. getCameraByID(id: string): Nullable<Camera>;
  33199. /**
  33200. * Gets a camera using its unique id
  33201. * @param uniqueId defines the unique id to look for
  33202. * @returns the camera or null if not found
  33203. */
  33204. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33205. /**
  33206. * Gets a camera using its name
  33207. * @param name defines the camera's name
  33208. * @return the camera or null if none found.
  33209. */
  33210. getCameraByName(name: string): Nullable<Camera>;
  33211. /**
  33212. * Gets a bone using its id
  33213. * @param id defines the bone's id
  33214. * @return the bone or null if not found
  33215. */
  33216. getBoneByID(id: string): Nullable<Bone>;
  33217. /**
  33218. * Gets a bone using its id
  33219. * @param name defines the bone's name
  33220. * @return the bone or null if not found
  33221. */
  33222. getBoneByName(name: string): Nullable<Bone>;
  33223. /**
  33224. * Gets a light node using its name
  33225. * @param name defines the the light's name
  33226. * @return the light or null if none found.
  33227. */
  33228. getLightByName(name: string): Nullable<Light>;
  33229. /**
  33230. * Gets a light node using its id
  33231. * @param id defines the light's id
  33232. * @return the light or null if none found.
  33233. */
  33234. getLightByID(id: string): Nullable<Light>;
  33235. /**
  33236. * Gets a light node using its scene-generated unique ID
  33237. * @param uniqueId defines the light's unique id
  33238. * @return the light or null if none found.
  33239. */
  33240. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33241. /**
  33242. * Gets a particle system by id
  33243. * @param id defines the particle system id
  33244. * @return the corresponding system or null if none found
  33245. */
  33246. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33247. /**
  33248. * Gets a geometry using its ID
  33249. * @param id defines the geometry's id
  33250. * @return the geometry or null if none found.
  33251. */
  33252. getGeometryByID(id: string): Nullable<Geometry>;
  33253. private _getGeometryByUniqueID;
  33254. /**
  33255. * Add a new geometry to this scene
  33256. * @param geometry defines the geometry to be added to the scene.
  33257. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33258. * @return a boolean defining if the geometry was added or not
  33259. */
  33260. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33261. /**
  33262. * Removes an existing geometry
  33263. * @param geometry defines the geometry to be removed from the scene
  33264. * @return a boolean defining if the geometry was removed or not
  33265. */
  33266. removeGeometry(geometry: Geometry): boolean;
  33267. /**
  33268. * Gets the list of geometries attached to the scene
  33269. * @returns an array of Geometry
  33270. */
  33271. getGeometries(): Geometry[];
  33272. /**
  33273. * Gets the first added mesh found of a given ID
  33274. * @param id defines the id to search for
  33275. * @return the mesh found or null if not found at all
  33276. */
  33277. getMeshByID(id: string): Nullable<AbstractMesh>;
  33278. /**
  33279. * Gets a list of meshes using their id
  33280. * @param id defines the id to search for
  33281. * @returns a list of meshes
  33282. */
  33283. getMeshesByID(id: string): Array<AbstractMesh>;
  33284. /**
  33285. * Gets the first added transform node found of a given ID
  33286. * @param id defines the id to search for
  33287. * @return the found transform node or null if not found at all.
  33288. */
  33289. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33290. /**
  33291. * Gets a list of transform nodes using their id
  33292. * @param id defines the id to search for
  33293. * @returns a list of transform nodes
  33294. */
  33295. getTransformNodesByID(id: string): Array<TransformNode>;
  33296. /**
  33297. * Gets a mesh with its auto-generated unique id
  33298. * @param uniqueId defines the unique id to search for
  33299. * @return the found mesh or null if not found at all.
  33300. */
  33301. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33302. /**
  33303. * Gets a the last added mesh using a given id
  33304. * @param id defines the id to search for
  33305. * @return the found mesh or null if not found at all.
  33306. */
  33307. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33308. /**
  33309. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33310. * @param id defines the id to search for
  33311. * @return the found node or null if not found at all
  33312. */
  33313. getLastEntryByID(id: string): Nullable<Node>;
  33314. /**
  33315. * Gets a node (Mesh, Camera, Light) using a given id
  33316. * @param id defines the id to search for
  33317. * @return the found node or null if not found at all
  33318. */
  33319. getNodeByID(id: string): Nullable<Node>;
  33320. /**
  33321. * Gets a node (Mesh, Camera, Light) using a given name
  33322. * @param name defines the name to search for
  33323. * @return the found node or null if not found at all.
  33324. */
  33325. getNodeByName(name: string): Nullable<Node>;
  33326. /**
  33327. * Gets a mesh using a given name
  33328. * @param name defines the name to search for
  33329. * @return the found mesh or null if not found at all.
  33330. */
  33331. getMeshByName(name: string): Nullable<AbstractMesh>;
  33332. /**
  33333. * Gets a transform node using a given name
  33334. * @param name defines the name to search for
  33335. * @return the found transform node or null if not found at all.
  33336. */
  33337. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33338. /**
  33339. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33340. * @param id defines the id to search for
  33341. * @return the found skeleton or null if not found at all.
  33342. */
  33343. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33344. /**
  33345. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33346. * @param id defines the id to search for
  33347. * @return the found skeleton or null if not found at all.
  33348. */
  33349. getSkeletonById(id: string): Nullable<Skeleton>;
  33350. /**
  33351. * Gets a skeleton using a given name
  33352. * @param name defines the name to search for
  33353. * @return the found skeleton or null if not found at all.
  33354. */
  33355. getSkeletonByName(name: string): Nullable<Skeleton>;
  33356. /**
  33357. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33358. * @param id defines the id to search for
  33359. * @return the found morph target manager or null if not found at all.
  33360. */
  33361. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33362. /**
  33363. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33364. * @param id defines the id to search for
  33365. * @return the found morph target or null if not found at all.
  33366. */
  33367. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33368. /**
  33369. * Gets a boolean indicating if the given mesh is active
  33370. * @param mesh defines the mesh to look for
  33371. * @returns true if the mesh is in the active list
  33372. */
  33373. isActiveMesh(mesh: AbstractMesh): boolean;
  33374. /**
  33375. * Return a unique id as a string which can serve as an identifier for the scene
  33376. */
  33377. readonly uid: string;
  33378. /**
  33379. * Add an externaly attached data from its key.
  33380. * This method call will fail and return false, if such key already exists.
  33381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33382. * @param key the unique key that identifies the data
  33383. * @param data the data object to associate to the key for this Engine instance
  33384. * @return true if no such key were already present and the data was added successfully, false otherwise
  33385. */
  33386. addExternalData<T>(key: string, data: T): boolean;
  33387. /**
  33388. * Get an externaly attached data from its key
  33389. * @param key the unique key that identifies the data
  33390. * @return the associated data, if present (can be null), or undefined if not present
  33391. */
  33392. getExternalData<T>(key: string): Nullable<T>;
  33393. /**
  33394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33395. * @param key the unique key that identifies the data
  33396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33397. * @return the associated data, can be null if the factory returned null.
  33398. */
  33399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33400. /**
  33401. * Remove an externaly attached data from the Engine instance
  33402. * @param key the unique key that identifies the data
  33403. * @return true if the data was successfully removed, false if it doesn't exist
  33404. */
  33405. removeExternalData(key: string): boolean;
  33406. private _evaluateSubMesh;
  33407. /**
  33408. * Clear the processed materials smart array preventing retention point in material dispose.
  33409. */
  33410. freeProcessedMaterials(): void;
  33411. private _preventFreeActiveMeshesAndRenderingGroups;
  33412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33414. * when disposing several meshes in a row or a hierarchy of meshes.
  33415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33416. */
  33417. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33418. /**
  33419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33420. */
  33421. freeActiveMeshes(): void;
  33422. /**
  33423. * Clear the info related to rendering groups preventing retention points during dispose.
  33424. */
  33425. freeRenderingGroups(): void;
  33426. /** @hidden */
  33427. _isInIntermediateRendering(): boolean;
  33428. /**
  33429. * Lambda returning the list of potentially active meshes.
  33430. */
  33431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33432. /**
  33433. * Lambda returning the list of potentially active sub meshes.
  33434. */
  33435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33436. /**
  33437. * Lambda returning the list of potentially intersecting sub meshes.
  33438. */
  33439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33440. /**
  33441. * Lambda returning the list of potentially colliding sub meshes.
  33442. */
  33443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33444. private _activeMeshesFrozen;
  33445. /**
  33446. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33447. * @returns the current scene
  33448. */
  33449. freezeActiveMeshes(): Scene;
  33450. /**
  33451. * Use this function to restart evaluating active meshes on every frame
  33452. * @returns the current scene
  33453. */
  33454. unfreezeActiveMeshes(): Scene;
  33455. private _evaluateActiveMeshes;
  33456. private _activeMesh;
  33457. /**
  33458. * Update the transform matrix to update from the current active camera
  33459. * @param force defines a boolean used to force the update even if cache is up to date
  33460. */
  33461. updateTransformMatrix(force?: boolean): void;
  33462. /**
  33463. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33464. * @param alternateCamera defines the camera to use
  33465. */
  33466. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33467. /** @hidden */
  33468. _allowPostProcessClearColor: boolean;
  33469. private _renderForCamera;
  33470. private _processSubCameras;
  33471. private _checkIntersections;
  33472. /** @hidden */
  33473. _advancePhysicsEngineStep(step: number): void;
  33474. /**
  33475. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33476. */
  33477. getDeterministicFrameTime: () => number;
  33478. /** @hidden */
  33479. _animate(): void;
  33480. /**
  33481. * Render the scene
  33482. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33483. */
  33484. render(updateCameras?: boolean): void;
  33485. /**
  33486. * Freeze all materials
  33487. * A frozen material will not be updatable but should be faster to render
  33488. */
  33489. freezeMaterials(): void;
  33490. /**
  33491. * Unfreeze all materials
  33492. * A frozen material will not be updatable but should be faster to render
  33493. */
  33494. unfreezeMaterials(): void;
  33495. /**
  33496. * Releases all held ressources
  33497. */
  33498. dispose(): void;
  33499. /**
  33500. * Gets if the scene is already disposed
  33501. */
  33502. readonly isDisposed: boolean;
  33503. /**
  33504. * Call this function to reduce memory footprint of the scene.
  33505. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33506. */
  33507. clearCachedVertexData(): void;
  33508. /**
  33509. * This function will remove the local cached buffer data from texture.
  33510. * It will save memory but will prevent the texture from being rebuilt
  33511. */
  33512. cleanCachedTextureBuffer(): void;
  33513. /**
  33514. * Get the world extend vectors with an optional filter
  33515. *
  33516. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33517. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33518. */
  33519. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33520. min: Vector3;
  33521. max: Vector3;
  33522. };
  33523. /**
  33524. * Creates a ray that can be used to pick in the scene
  33525. * @param x defines the x coordinate of the origin (on-screen)
  33526. * @param y defines the y coordinate of the origin (on-screen)
  33527. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33528. * @param camera defines the camera to use for the picking
  33529. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33530. * @returns a Ray
  33531. */
  33532. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33533. /**
  33534. * Creates a ray that can be used to pick in the scene
  33535. * @param x defines the x coordinate of the origin (on-screen)
  33536. * @param y defines the y coordinate of the origin (on-screen)
  33537. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33538. * @param result defines the ray where to store the picking ray
  33539. * @param camera defines the camera to use for the picking
  33540. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33541. * @returns the current scene
  33542. */
  33543. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33544. /**
  33545. * Creates a ray that can be used to pick in the scene
  33546. * @param x defines the x coordinate of the origin (on-screen)
  33547. * @param y defines the y coordinate of the origin (on-screen)
  33548. * @param camera defines the camera to use for the picking
  33549. * @returns a Ray
  33550. */
  33551. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33552. /**
  33553. * Creates a ray that can be used to pick in the scene
  33554. * @param x defines the x coordinate of the origin (on-screen)
  33555. * @param y defines the y coordinate of the origin (on-screen)
  33556. * @param result defines the ray where to store the picking ray
  33557. * @param camera defines the camera to use for the picking
  33558. * @returns the current scene
  33559. */
  33560. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33561. /** Launch a ray to try to pick a mesh in the scene
  33562. * @param x position on screen
  33563. * @param y position on screen
  33564. * @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
  33565. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33566. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33568. * @returns a PickingInfo
  33569. */
  33570. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33571. /** Use the given ray to pick a mesh in the scene
  33572. * @param ray The ray to use to pick meshes
  33573. * @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
  33574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33575. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33576. * @returns a PickingInfo
  33577. */
  33578. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33579. /**
  33580. * Launch a ray to try to pick a mesh in the scene
  33581. * @param x X position on screen
  33582. * @param y Y position on screen
  33583. * @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
  33584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33586. * @returns an array of PickingInfo
  33587. */
  33588. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33589. /**
  33590. * Launch a ray to try to pick a mesh in the scene
  33591. * @param ray Ray to use
  33592. * @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
  33593. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33594. * @returns an array of PickingInfo
  33595. */
  33596. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33597. /**
  33598. * Force the value of meshUnderPointer
  33599. * @param mesh defines the mesh to use
  33600. */
  33601. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33602. /**
  33603. * Gets the mesh under the pointer
  33604. * @returns a Mesh or null if no mesh is under the pointer
  33605. */
  33606. getPointerOverMesh(): Nullable<AbstractMesh>;
  33607. /** @hidden */
  33608. _rebuildGeometries(): void;
  33609. /** @hidden */
  33610. _rebuildTextures(): void;
  33611. private _getByTags;
  33612. /**
  33613. * Get a list of meshes by tags
  33614. * @param tagsQuery defines the tags query to use
  33615. * @param forEach defines a predicate used to filter results
  33616. * @returns an array of Mesh
  33617. */
  33618. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33619. /**
  33620. * Get a list of cameras by tags
  33621. * @param tagsQuery defines the tags query to use
  33622. * @param forEach defines a predicate used to filter results
  33623. * @returns an array of Camera
  33624. */
  33625. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33626. /**
  33627. * Get a list of lights by tags
  33628. * @param tagsQuery defines the tags query to use
  33629. * @param forEach defines a predicate used to filter results
  33630. * @returns an array of Light
  33631. */
  33632. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33633. /**
  33634. * Get a list of materials by tags
  33635. * @param tagsQuery defines the tags query to use
  33636. * @param forEach defines a predicate used to filter results
  33637. * @returns an array of Material
  33638. */
  33639. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33640. /**
  33641. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33642. * This allowed control for front to back rendering or reversly depending of the special needs.
  33643. *
  33644. * @param renderingGroupId The rendering group id corresponding to its index
  33645. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33646. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33647. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33648. */
  33649. 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;
  33650. /**
  33651. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33652. *
  33653. * @param renderingGroupId The rendering group id corresponding to its index
  33654. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33655. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33656. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33657. */
  33658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33659. /**
  33660. * Gets the current auto clear configuration for one rendering group of the rendering
  33661. * manager.
  33662. * @param index the rendering group index to get the information for
  33663. * @returns The auto clear setup for the requested rendering group
  33664. */
  33665. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33666. private _blockMaterialDirtyMechanism;
  33667. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33668. blockMaterialDirtyMechanism: boolean;
  33669. /**
  33670. * Will flag all materials as dirty to trigger new shader compilation
  33671. * @param flag defines the flag used to specify which material part must be marked as dirty
  33672. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33673. */
  33674. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33675. /** @hidden */
  33676. _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;
  33677. /** @hidden */
  33678. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33679. }
  33680. }
  33681. declare module "babylonjs/assetContainer" {
  33682. import { AbstractScene } from "babylonjs/abstractScene";
  33683. import { Scene } from "babylonjs/scene";
  33684. import { Mesh } from "babylonjs/Meshes/mesh";
  33685. /**
  33686. * Set of assets to keep when moving a scene into an asset container.
  33687. */
  33688. export class KeepAssets extends AbstractScene {
  33689. }
  33690. /**
  33691. * Container with a set of assets that can be added or removed from a scene.
  33692. */
  33693. export class AssetContainer extends AbstractScene {
  33694. /**
  33695. * The scene the AssetContainer belongs to.
  33696. */
  33697. scene: Scene;
  33698. /**
  33699. * Instantiates an AssetContainer.
  33700. * @param scene The scene the AssetContainer belongs to.
  33701. */
  33702. constructor(scene: Scene);
  33703. /**
  33704. * Adds all the assets from the container to the scene.
  33705. */
  33706. addAllToScene(): void;
  33707. /**
  33708. * Removes all the assets in the container from the scene
  33709. */
  33710. removeAllFromScene(): void;
  33711. /**
  33712. * Disposes all the assets in the container
  33713. */
  33714. dispose(): void;
  33715. private _moveAssets;
  33716. /**
  33717. * Removes all the assets contained in the scene and adds them to the container.
  33718. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33719. */
  33720. moveAllFromScene(keepAssets?: KeepAssets): void;
  33721. /**
  33722. * 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.
  33723. * @returns the root mesh
  33724. */
  33725. createRootMesh(): Mesh;
  33726. }
  33727. }
  33728. declare module "babylonjs/abstractScene" {
  33729. import { Scene } from "babylonjs/scene";
  33730. import { Nullable } from "babylonjs/types";
  33731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33733. import { Geometry } from "babylonjs/Meshes/geometry";
  33734. import { Skeleton } from "babylonjs/Bones/skeleton";
  33735. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33736. import { AssetContainer } from "babylonjs/assetContainer";
  33737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33738. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33740. import { Material } from "babylonjs/Materials/material";
  33741. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33742. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33743. import { Camera } from "babylonjs/Cameras/camera";
  33744. import { Light } from "babylonjs/Lights/light";
  33745. import { Node } from "babylonjs/node";
  33746. import { Animation } from "babylonjs/Animations/animation";
  33747. /**
  33748. * Defines how the parser contract is defined.
  33749. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33750. */
  33751. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33752. /**
  33753. * Defines how the individual parser contract is defined.
  33754. * These parser can parse an individual asset
  33755. */
  33756. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33757. /**
  33758. * Base class of the scene acting as a container for the different elements composing a scene.
  33759. * This class is dynamically extended by the different components of the scene increasing
  33760. * flexibility and reducing coupling
  33761. */
  33762. export abstract class AbstractScene {
  33763. /**
  33764. * Stores the list of available parsers in the application.
  33765. */
  33766. private static _BabylonFileParsers;
  33767. /**
  33768. * Stores the list of available individual parsers in the application.
  33769. */
  33770. private static _IndividualBabylonFileParsers;
  33771. /**
  33772. * Adds a parser in the list of available ones
  33773. * @param name Defines the name of the parser
  33774. * @param parser Defines the parser to add
  33775. */
  33776. static AddParser(name: string, parser: BabylonFileParser): void;
  33777. /**
  33778. * Gets a general parser from the list of avaialble ones
  33779. * @param name Defines the name of the parser
  33780. * @returns the requested parser or null
  33781. */
  33782. static GetParser(name: string): Nullable<BabylonFileParser>;
  33783. /**
  33784. * Adds n individual parser in the list of available ones
  33785. * @param name Defines the name of the parser
  33786. * @param parser Defines the parser to add
  33787. */
  33788. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33789. /**
  33790. * Gets an individual parser from the list of avaialble ones
  33791. * @param name Defines the name of the parser
  33792. * @returns the requested parser or null
  33793. */
  33794. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33795. /**
  33796. * Parser json data and populate both a scene and its associated container object
  33797. * @param jsonData Defines the data to parse
  33798. * @param scene Defines the scene to parse the data for
  33799. * @param container Defines the container attached to the parsing sequence
  33800. * @param rootUrl Defines the root url of the data
  33801. */
  33802. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33803. /**
  33804. * Gets the list of root nodes (ie. nodes with no parent)
  33805. */
  33806. rootNodes: Node[];
  33807. /** All of the cameras added to this scene
  33808. * @see http://doc.babylonjs.com/babylon101/cameras
  33809. */
  33810. cameras: Camera[];
  33811. /**
  33812. * All of the lights added to this scene
  33813. * @see http://doc.babylonjs.com/babylon101/lights
  33814. */
  33815. lights: Light[];
  33816. /**
  33817. * All of the (abstract) meshes added to this scene
  33818. */
  33819. meshes: AbstractMesh[];
  33820. /**
  33821. * The list of skeletons added to the scene
  33822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33823. */
  33824. skeletons: Skeleton[];
  33825. /**
  33826. * All of the particle systems added to this scene
  33827. * @see http://doc.babylonjs.com/babylon101/particles
  33828. */
  33829. particleSystems: IParticleSystem[];
  33830. /**
  33831. * Gets a list of Animations associated with the scene
  33832. */
  33833. animations: Animation[];
  33834. /**
  33835. * All of the animation groups added to this scene
  33836. * @see http://doc.babylonjs.com/how_to/group
  33837. */
  33838. animationGroups: AnimationGroup[];
  33839. /**
  33840. * All of the multi-materials added to this scene
  33841. * @see http://doc.babylonjs.com/how_to/multi_materials
  33842. */
  33843. multiMaterials: MultiMaterial[];
  33844. /**
  33845. * All of the materials added to this scene
  33846. * In the context of a Scene, it is not supposed to be modified manually.
  33847. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33848. * Note also that the order of the Material wihin the array is not significant and might change.
  33849. * @see http://doc.babylonjs.com/babylon101/materials
  33850. */
  33851. materials: Material[];
  33852. /**
  33853. * The list of morph target managers added to the scene
  33854. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33855. */
  33856. morphTargetManagers: MorphTargetManager[];
  33857. /**
  33858. * The list of geometries used in the scene.
  33859. */
  33860. geometries: Geometry[];
  33861. /**
  33862. * All of the tranform nodes added to this scene
  33863. * In the context of a Scene, it is not supposed to be modified manually.
  33864. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33865. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33866. * @see http://doc.babylonjs.com/how_to/transformnode
  33867. */
  33868. transformNodes: TransformNode[];
  33869. /**
  33870. * ActionManagers available on the scene.
  33871. */
  33872. actionManagers: AbstractActionManager[];
  33873. /**
  33874. * Textures to keep.
  33875. */
  33876. textures: BaseTexture[];
  33877. }
  33878. }
  33879. declare module "babylonjs/Audio/sound" {
  33880. import { Observable } from "babylonjs/Misc/observable";
  33881. import { Vector3 } from "babylonjs/Maths/math";
  33882. import { Nullable } from "babylonjs/types";
  33883. import { Scene } from "babylonjs/scene";
  33884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33885. /**
  33886. * Defines a sound that can be played in the application.
  33887. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33889. */
  33890. export class Sound {
  33891. /**
  33892. * The name of the sound in the scene.
  33893. */
  33894. name: string;
  33895. /**
  33896. * Does the sound autoplay once loaded.
  33897. */
  33898. autoplay: boolean;
  33899. /**
  33900. * Does the sound loop after it finishes playing once.
  33901. */
  33902. loop: boolean;
  33903. /**
  33904. * Does the sound use a custom attenuation curve to simulate the falloff
  33905. * happening when the source gets further away from the camera.
  33906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33907. */
  33908. useCustomAttenuation: boolean;
  33909. /**
  33910. * The sound track id this sound belongs to.
  33911. */
  33912. soundTrackId: number;
  33913. /**
  33914. * Is this sound currently played.
  33915. */
  33916. isPlaying: boolean;
  33917. /**
  33918. * Is this sound currently paused.
  33919. */
  33920. isPaused: boolean;
  33921. /**
  33922. * Does this sound enables spatial sound.
  33923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33924. */
  33925. spatialSound: boolean;
  33926. /**
  33927. * Define the reference distance the sound should be heard perfectly.
  33928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33929. */
  33930. refDistance: number;
  33931. /**
  33932. * Define the roll off factor of spatial sounds.
  33933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33934. */
  33935. rolloffFactor: number;
  33936. /**
  33937. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33939. */
  33940. maxDistance: number;
  33941. /**
  33942. * Define the distance attenuation model the sound will follow.
  33943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33944. */
  33945. distanceModel: string;
  33946. /**
  33947. * @hidden
  33948. * Back Compat
  33949. **/
  33950. onended: () => any;
  33951. /**
  33952. * Observable event when the current playing sound finishes.
  33953. */
  33954. onEndedObservable: Observable<Sound>;
  33955. private _panningModel;
  33956. private _playbackRate;
  33957. private _streaming;
  33958. private _startTime;
  33959. private _startOffset;
  33960. private _position;
  33961. /** @hidden */
  33962. _positionInEmitterSpace: boolean;
  33963. private _localDirection;
  33964. private _volume;
  33965. private _isReadyToPlay;
  33966. private _isDirectional;
  33967. private _readyToPlayCallback;
  33968. private _audioBuffer;
  33969. private _soundSource;
  33970. private _streamingSource;
  33971. private _soundPanner;
  33972. private _soundGain;
  33973. private _inputAudioNode;
  33974. private _outputAudioNode;
  33975. private _coneInnerAngle;
  33976. private _coneOuterAngle;
  33977. private _coneOuterGain;
  33978. private _scene;
  33979. private _connectedTransformNode;
  33980. private _customAttenuationFunction;
  33981. private _registerFunc;
  33982. private _isOutputConnected;
  33983. private _htmlAudioElement;
  33984. private _urlType;
  33985. /** @hidden */
  33986. static _SceneComponentInitialization: (scene: Scene) => void;
  33987. /**
  33988. * Create a sound and attach it to a scene
  33989. * @param name Name of your sound
  33990. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33991. * @param scene defines the scene the sound belongs to
  33992. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33993. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33994. */
  33995. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33996. /**
  33997. * Release the sound and its associated resources
  33998. */
  33999. dispose(): void;
  34000. /**
  34001. * Gets if the sounds is ready to be played or not.
  34002. * @returns true if ready, otherwise false
  34003. */
  34004. isReady(): boolean;
  34005. private _soundLoaded;
  34006. /**
  34007. * Sets the data of the sound from an audiobuffer
  34008. * @param audioBuffer The audioBuffer containing the data
  34009. */
  34010. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34011. /**
  34012. * Updates the current sounds options such as maxdistance, loop...
  34013. * @param options A JSON object containing values named as the object properties
  34014. */
  34015. updateOptions(options: any): void;
  34016. private _createSpatialParameters;
  34017. private _updateSpatialParameters;
  34018. /**
  34019. * Switch the panning model to HRTF:
  34020. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34022. */
  34023. switchPanningModelToHRTF(): void;
  34024. /**
  34025. * Switch the panning model to Equal Power:
  34026. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34028. */
  34029. switchPanningModelToEqualPower(): void;
  34030. private _switchPanningModel;
  34031. /**
  34032. * Connect this sound to a sound track audio node like gain...
  34033. * @param soundTrackAudioNode the sound track audio node to connect to
  34034. */
  34035. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34036. /**
  34037. * Transform this sound into a directional source
  34038. * @param coneInnerAngle Size of the inner cone in degree
  34039. * @param coneOuterAngle Size of the outer cone in degree
  34040. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34041. */
  34042. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34043. /**
  34044. * Gets or sets the inner angle for the directional cone.
  34045. */
  34046. /**
  34047. * Gets or sets the inner angle for the directional cone.
  34048. */
  34049. directionalConeInnerAngle: number;
  34050. /**
  34051. * Gets or sets the outer angle for the directional cone.
  34052. */
  34053. /**
  34054. * Gets or sets the outer angle for the directional cone.
  34055. */
  34056. directionalConeOuterAngle: number;
  34057. /**
  34058. * Sets the position of the emitter if spatial sound is enabled
  34059. * @param newPosition Defines the new posisiton
  34060. */
  34061. setPosition(newPosition: Vector3): void;
  34062. /**
  34063. * Sets the local direction of the emitter if spatial sound is enabled
  34064. * @param newLocalDirection Defines the new local direction
  34065. */
  34066. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34067. private _updateDirection;
  34068. /** @hidden */
  34069. updateDistanceFromListener(): void;
  34070. /**
  34071. * Sets a new custom attenuation function for the sound.
  34072. * @param callback Defines the function used for the attenuation
  34073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34074. */
  34075. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34076. /**
  34077. * Play the sound
  34078. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34079. * @param offset (optional) Start the sound setting it at a specific time
  34080. */
  34081. play(time?: number, offset?: number): void;
  34082. private _onended;
  34083. /**
  34084. * Stop the sound
  34085. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34086. */
  34087. stop(time?: number): void;
  34088. /**
  34089. * Put the sound in pause
  34090. */
  34091. pause(): void;
  34092. /**
  34093. * Sets a dedicated volume for this sounds
  34094. * @param newVolume Define the new volume of the sound
  34095. * @param time Define in how long the sound should be at this value
  34096. */
  34097. setVolume(newVolume: number, time?: number): void;
  34098. /**
  34099. * Set the sound play back rate
  34100. * @param newPlaybackRate Define the playback rate the sound should be played at
  34101. */
  34102. setPlaybackRate(newPlaybackRate: number): void;
  34103. /**
  34104. * Gets the volume of the sound.
  34105. * @returns the volume of the sound
  34106. */
  34107. getVolume(): number;
  34108. /**
  34109. * Attach the sound to a dedicated mesh
  34110. * @param transformNode The transform node to connect the sound with
  34111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34112. */
  34113. attachToMesh(transformNode: TransformNode): void;
  34114. /**
  34115. * Detach the sound from the previously attached mesh
  34116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34117. */
  34118. detachFromMesh(): void;
  34119. private _onRegisterAfterWorldMatrixUpdate;
  34120. /**
  34121. * Clone the current sound in the scene.
  34122. * @returns the new sound clone
  34123. */
  34124. clone(): Nullable<Sound>;
  34125. /**
  34126. * Gets the current underlying audio buffer containing the data
  34127. * @returns the audio buffer
  34128. */
  34129. getAudioBuffer(): Nullable<AudioBuffer>;
  34130. /**
  34131. * Serializes the Sound in a JSON representation
  34132. * @returns the JSON representation of the sound
  34133. */
  34134. serialize(): any;
  34135. /**
  34136. * Parse a JSON representation of a sound to innstantiate in a given scene
  34137. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34138. * @param scene Define the scene the new parsed sound should be created in
  34139. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34140. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34141. * @returns the newly parsed sound
  34142. */
  34143. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34144. }
  34145. }
  34146. declare module "babylonjs/Actions/directAudioActions" {
  34147. import { Action } from "babylonjs/Actions/action";
  34148. import { Condition } from "babylonjs/Actions/condition";
  34149. import { Sound } from "babylonjs/Audio/sound";
  34150. /**
  34151. * This defines an action helpful to play a defined sound on a triggered action.
  34152. */
  34153. export class PlaySoundAction extends Action {
  34154. private _sound;
  34155. /**
  34156. * Instantiate the action
  34157. * @param triggerOptions defines the trigger options
  34158. * @param sound defines the sound to play
  34159. * @param condition defines the trigger related conditions
  34160. */
  34161. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34162. /** @hidden */
  34163. _prepare(): void;
  34164. /**
  34165. * Execute the action and play the sound.
  34166. */
  34167. execute(): void;
  34168. /**
  34169. * Serializes the actions and its related information.
  34170. * @param parent defines the object to serialize in
  34171. * @returns the serialized object
  34172. */
  34173. serialize(parent: any): any;
  34174. }
  34175. /**
  34176. * This defines an action helpful to stop a defined sound on a triggered action.
  34177. */
  34178. export class StopSoundAction extends Action {
  34179. private _sound;
  34180. /**
  34181. * Instantiate the action
  34182. * @param triggerOptions defines the trigger options
  34183. * @param sound defines the sound to stop
  34184. * @param condition defines the trigger related conditions
  34185. */
  34186. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34187. /** @hidden */
  34188. _prepare(): void;
  34189. /**
  34190. * Execute the action and stop the sound.
  34191. */
  34192. execute(): void;
  34193. /**
  34194. * Serializes the actions and its related information.
  34195. * @param parent defines the object to serialize in
  34196. * @returns the serialized object
  34197. */
  34198. serialize(parent: any): any;
  34199. }
  34200. }
  34201. declare module "babylonjs/Actions/interpolateValueAction" {
  34202. import { Action } from "babylonjs/Actions/action";
  34203. import { Condition } from "babylonjs/Actions/condition";
  34204. import { Observable } from "babylonjs/Misc/observable";
  34205. /**
  34206. * This defines an action responsible to change the value of a property
  34207. * by interpolating between its current value and the newly set one once triggered.
  34208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34209. */
  34210. export class InterpolateValueAction extends Action {
  34211. /**
  34212. * Defines the path of the property where the value should be interpolated
  34213. */
  34214. propertyPath: string;
  34215. /**
  34216. * Defines the target value at the end of the interpolation.
  34217. */
  34218. value: any;
  34219. /**
  34220. * Defines the time it will take for the property to interpolate to the value.
  34221. */
  34222. duration: number;
  34223. /**
  34224. * Defines if the other scene animations should be stopped when the action has been triggered
  34225. */
  34226. stopOtherAnimations?: boolean;
  34227. /**
  34228. * Defines a callback raised once the interpolation animation has been done.
  34229. */
  34230. onInterpolationDone?: () => void;
  34231. /**
  34232. * Observable triggered once the interpolation animation has been done.
  34233. */
  34234. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34235. private _target;
  34236. private _effectiveTarget;
  34237. private _property;
  34238. /**
  34239. * Instantiate the action
  34240. * @param triggerOptions defines the trigger options
  34241. * @param target defines the object containing the value to interpolate
  34242. * @param propertyPath defines the path to the property in the target object
  34243. * @param value defines the target value at the end of the interpolation
  34244. * @param duration deines the time it will take for the property to interpolate to the value.
  34245. * @param condition defines the trigger related conditions
  34246. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34247. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34248. */
  34249. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34250. /** @hidden */
  34251. _prepare(): void;
  34252. /**
  34253. * Execute the action starts the value interpolation.
  34254. */
  34255. execute(): void;
  34256. /**
  34257. * Serializes the actions and its related information.
  34258. * @param parent defines the object to serialize in
  34259. * @returns the serialized object
  34260. */
  34261. serialize(parent: any): any;
  34262. }
  34263. }
  34264. declare module "babylonjs/Actions/index" {
  34265. export * from "babylonjs/Actions/action";
  34266. export * from "babylonjs/Actions/actionEvent";
  34267. export * from "babylonjs/Actions/actionManager";
  34268. export * from "babylonjs/Actions/condition";
  34269. export * from "babylonjs/Actions/directActions";
  34270. export * from "babylonjs/Actions/directAudioActions";
  34271. export * from "babylonjs/Actions/interpolateValueAction";
  34272. }
  34273. declare module "babylonjs/Animations/index" {
  34274. export * from "babylonjs/Animations/animatable";
  34275. export * from "babylonjs/Animations/animation";
  34276. export * from "babylonjs/Animations/animationGroup";
  34277. export * from "babylonjs/Animations/animationPropertiesOverride";
  34278. export * from "babylonjs/Animations/easing";
  34279. export * from "babylonjs/Animations/runtimeAnimation";
  34280. export * from "babylonjs/Animations/animationEvent";
  34281. export * from "babylonjs/Animations/animationGroup";
  34282. export * from "babylonjs/Animations/animationKey";
  34283. export * from "babylonjs/Animations/animationRange";
  34284. }
  34285. declare module "babylonjs/Audio/soundTrack" {
  34286. import { Sound } from "babylonjs/Audio/sound";
  34287. import { Analyser } from "babylonjs/Audio/analyser";
  34288. import { Scene } from "babylonjs/scene";
  34289. /**
  34290. * Options allowed during the creation of a sound track.
  34291. */
  34292. export interface ISoundTrackOptions {
  34293. /**
  34294. * The volume the sound track should take during creation
  34295. */
  34296. volume?: number;
  34297. /**
  34298. * Define if the sound track is the main sound track of the scene
  34299. */
  34300. mainTrack?: boolean;
  34301. }
  34302. /**
  34303. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34304. * It will be also used in a future release to apply effects on a specific track.
  34305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34306. */
  34307. export class SoundTrack {
  34308. /**
  34309. * The unique identifier of the sound track in the scene.
  34310. */
  34311. id: number;
  34312. /**
  34313. * The list of sounds included in the sound track.
  34314. */
  34315. soundCollection: Array<Sound>;
  34316. private _outputAudioNode;
  34317. private _scene;
  34318. private _isMainTrack;
  34319. private _connectedAnalyser;
  34320. private _options;
  34321. private _isInitialized;
  34322. /**
  34323. * Creates a new sound track.
  34324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34325. * @param scene Define the scene the sound track belongs to
  34326. * @param options
  34327. */
  34328. constructor(scene: Scene, options?: ISoundTrackOptions);
  34329. private _initializeSoundTrackAudioGraph;
  34330. /**
  34331. * Release the sound track and its associated resources
  34332. */
  34333. dispose(): void;
  34334. /**
  34335. * Adds a sound to this sound track
  34336. * @param sound define the cound to add
  34337. * @ignoreNaming
  34338. */
  34339. AddSound(sound: Sound): void;
  34340. /**
  34341. * Removes a sound to this sound track
  34342. * @param sound define the cound to remove
  34343. * @ignoreNaming
  34344. */
  34345. RemoveSound(sound: Sound): void;
  34346. /**
  34347. * Set a global volume for the full sound track.
  34348. * @param newVolume Define the new volume of the sound track
  34349. */
  34350. setVolume(newVolume: number): void;
  34351. /**
  34352. * Switch the panning model to HRTF:
  34353. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34355. */
  34356. switchPanningModelToHRTF(): void;
  34357. /**
  34358. * Switch the panning model to Equal Power:
  34359. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34361. */
  34362. switchPanningModelToEqualPower(): void;
  34363. /**
  34364. * Connect the sound track to an audio analyser allowing some amazing
  34365. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34367. * @param analyser The analyser to connect to the engine
  34368. */
  34369. connectToAnalyser(analyser: Analyser): void;
  34370. }
  34371. }
  34372. declare module "babylonjs/Audio/audioSceneComponent" {
  34373. import { Sound } from "babylonjs/Audio/sound";
  34374. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34375. import { Nullable } from "babylonjs/types";
  34376. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34377. import { Scene } from "babylonjs/scene";
  34378. import { AbstractScene } from "babylonjs/abstractScene";
  34379. module "babylonjs/abstractScene" {
  34380. interface AbstractScene {
  34381. /**
  34382. * The list of sounds used in the scene.
  34383. */
  34384. sounds: Nullable<Array<Sound>>;
  34385. }
  34386. }
  34387. module "babylonjs/scene" {
  34388. interface Scene {
  34389. /**
  34390. * @hidden
  34391. * Backing field
  34392. */
  34393. _mainSoundTrack: SoundTrack;
  34394. /**
  34395. * The main sound track played by the scene.
  34396. * It cotains your primary collection of sounds.
  34397. */
  34398. mainSoundTrack: SoundTrack;
  34399. /**
  34400. * The list of sound tracks added to the scene
  34401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34402. */
  34403. soundTracks: Nullable<Array<SoundTrack>>;
  34404. /**
  34405. * Gets a sound using a given name
  34406. * @param name defines the name to search for
  34407. * @return the found sound or null if not found at all.
  34408. */
  34409. getSoundByName(name: string): Nullable<Sound>;
  34410. /**
  34411. * Gets or sets if audio support is enabled
  34412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34413. */
  34414. audioEnabled: boolean;
  34415. /**
  34416. * Gets or sets if audio will be output to headphones
  34417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34418. */
  34419. headphone: boolean;
  34420. }
  34421. }
  34422. /**
  34423. * Defines the sound scene component responsible to manage any sounds
  34424. * in a given scene.
  34425. */
  34426. export class AudioSceneComponent implements ISceneSerializableComponent {
  34427. /**
  34428. * The component name helpfull to identify the component in the list of scene components.
  34429. */
  34430. readonly name: string;
  34431. /**
  34432. * The scene the component belongs to.
  34433. */
  34434. scene: Scene;
  34435. private _audioEnabled;
  34436. /**
  34437. * Gets whether audio is enabled or not.
  34438. * Please use related enable/disable method to switch state.
  34439. */
  34440. readonly audioEnabled: boolean;
  34441. private _headphone;
  34442. /**
  34443. * Gets whether audio is outputing to headphone or not.
  34444. * Please use the according Switch methods to change output.
  34445. */
  34446. readonly headphone: boolean;
  34447. /**
  34448. * Creates a new instance of the component for the given scene
  34449. * @param scene Defines the scene to register the component in
  34450. */
  34451. constructor(scene: Scene);
  34452. /**
  34453. * Registers the component in a given scene
  34454. */
  34455. register(): void;
  34456. /**
  34457. * Rebuilds the elements related to this component in case of
  34458. * context lost for instance.
  34459. */
  34460. rebuild(): void;
  34461. /**
  34462. * Serializes the component data to the specified json object
  34463. * @param serializationObject The object to serialize to
  34464. */
  34465. serialize(serializationObject: any): void;
  34466. /**
  34467. * Adds all the element from the container to the scene
  34468. * @param container the container holding the elements
  34469. */
  34470. addFromContainer(container: AbstractScene): void;
  34471. /**
  34472. * Removes all the elements in the container from the scene
  34473. * @param container contains the elements to remove
  34474. */
  34475. removeFromContainer(container: AbstractScene): void;
  34476. /**
  34477. * Disposes the component and the associated ressources.
  34478. */
  34479. dispose(): void;
  34480. /**
  34481. * Disables audio in the associated scene.
  34482. */
  34483. disableAudio(): void;
  34484. /**
  34485. * Enables audio in the associated scene.
  34486. */
  34487. enableAudio(): void;
  34488. /**
  34489. * Switch audio to headphone output.
  34490. */
  34491. switchAudioModeForHeadphones(): void;
  34492. /**
  34493. * Switch audio to normal speakers.
  34494. */
  34495. switchAudioModeForNormalSpeakers(): void;
  34496. private _afterRender;
  34497. }
  34498. }
  34499. declare module "babylonjs/Audio/weightedsound" {
  34500. import { Sound } from "babylonjs/Audio/sound";
  34501. /**
  34502. * Wraps one or more Sound objects and selects one with random weight for playback.
  34503. */
  34504. export class WeightedSound {
  34505. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34506. loop: boolean;
  34507. private _coneInnerAngle;
  34508. private _coneOuterAngle;
  34509. private _volume;
  34510. /** A Sound is currently playing. */
  34511. isPlaying: boolean;
  34512. /** A Sound is currently paused. */
  34513. isPaused: boolean;
  34514. private _sounds;
  34515. private _weights;
  34516. private _currentIndex?;
  34517. /**
  34518. * Creates a new WeightedSound from the list of sounds given.
  34519. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34520. * @param sounds Array of Sounds that will be selected from.
  34521. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34522. */
  34523. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34524. /**
  34525. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34526. */
  34527. /**
  34528. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34529. */
  34530. directionalConeInnerAngle: number;
  34531. /**
  34532. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34533. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34534. */
  34535. /**
  34536. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34537. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34538. */
  34539. directionalConeOuterAngle: number;
  34540. /**
  34541. * Playback volume.
  34542. */
  34543. /**
  34544. * Playback volume.
  34545. */
  34546. volume: number;
  34547. private _onended;
  34548. /**
  34549. * Suspend playback
  34550. */
  34551. pause(): void;
  34552. /**
  34553. * Stop playback
  34554. */
  34555. stop(): void;
  34556. /**
  34557. * Start playback.
  34558. * @param startOffset Position the clip head at a specific time in seconds.
  34559. */
  34560. play(startOffset?: number): void;
  34561. }
  34562. }
  34563. declare module "babylonjs/Audio/index" {
  34564. export * from "babylonjs/Audio/analyser";
  34565. export * from "babylonjs/Audio/audioEngine";
  34566. export * from "babylonjs/Audio/audioSceneComponent";
  34567. export * from "babylonjs/Audio/sound";
  34568. export * from "babylonjs/Audio/soundTrack";
  34569. export * from "babylonjs/Audio/weightedsound";
  34570. }
  34571. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34572. import { Behavior } from "babylonjs/Behaviors/behavior";
  34573. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34574. import { BackEase } from "babylonjs/Animations/easing";
  34575. /**
  34576. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34578. */
  34579. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34580. /**
  34581. * Gets the name of the behavior.
  34582. */
  34583. readonly name: string;
  34584. /**
  34585. * The easing function used by animations
  34586. */
  34587. static EasingFunction: BackEase;
  34588. /**
  34589. * The easing mode used by animations
  34590. */
  34591. static EasingMode: number;
  34592. /**
  34593. * The duration of the animation, in milliseconds
  34594. */
  34595. transitionDuration: number;
  34596. /**
  34597. * Length of the distance animated by the transition when lower radius is reached
  34598. */
  34599. lowerRadiusTransitionRange: number;
  34600. /**
  34601. * Length of the distance animated by the transition when upper radius is reached
  34602. */
  34603. upperRadiusTransitionRange: number;
  34604. private _autoTransitionRange;
  34605. /**
  34606. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34607. */
  34608. /**
  34609. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34610. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34611. */
  34612. autoTransitionRange: boolean;
  34613. private _attachedCamera;
  34614. private _onAfterCheckInputsObserver;
  34615. private _onMeshTargetChangedObserver;
  34616. /**
  34617. * Initializes the behavior.
  34618. */
  34619. init(): void;
  34620. /**
  34621. * Attaches the behavior to its arc rotate camera.
  34622. * @param camera Defines the camera to attach the behavior to
  34623. */
  34624. attach(camera: ArcRotateCamera): void;
  34625. /**
  34626. * Detaches the behavior from its current arc rotate camera.
  34627. */
  34628. detach(): void;
  34629. private _radiusIsAnimating;
  34630. private _radiusBounceTransition;
  34631. private _animatables;
  34632. private _cachedWheelPrecision;
  34633. /**
  34634. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34635. * @param radiusLimit The limit to check against.
  34636. * @return Bool to indicate if at limit.
  34637. */
  34638. private _isRadiusAtLimit;
  34639. /**
  34640. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34641. * @param radiusDelta The delta by which to animate to. Can be negative.
  34642. */
  34643. private _applyBoundRadiusAnimation;
  34644. /**
  34645. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34646. */
  34647. protected _clearAnimationLocks(): void;
  34648. /**
  34649. * Stops and removes all animations that have been applied to the camera
  34650. */
  34651. stopAllAnimations(): void;
  34652. }
  34653. }
  34654. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34655. import { Behavior } from "babylonjs/Behaviors/behavior";
  34656. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34657. import { ExponentialEase } from "babylonjs/Animations/easing";
  34658. import { Nullable } from "babylonjs/types";
  34659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34660. import { Vector3 } from "babylonjs/Maths/math";
  34661. /**
  34662. * 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.
  34663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34664. */
  34665. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34666. /**
  34667. * Gets the name of the behavior.
  34668. */
  34669. readonly name: string;
  34670. private _mode;
  34671. private _radiusScale;
  34672. private _positionScale;
  34673. private _defaultElevation;
  34674. private _elevationReturnTime;
  34675. private _elevationReturnWaitTime;
  34676. private _zoomStopsAnimation;
  34677. private _framingTime;
  34678. /**
  34679. * The easing function used by animations
  34680. */
  34681. static EasingFunction: ExponentialEase;
  34682. /**
  34683. * The easing mode used by animations
  34684. */
  34685. static EasingMode: number;
  34686. /**
  34687. * Sets the current mode used by the behavior
  34688. */
  34689. /**
  34690. * Gets current mode used by the behavior.
  34691. */
  34692. mode: number;
  34693. /**
  34694. * Sets the scale applied to the radius (1 by default)
  34695. */
  34696. /**
  34697. * Gets the scale applied to the radius
  34698. */
  34699. radiusScale: number;
  34700. /**
  34701. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34702. */
  34703. /**
  34704. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34705. */
  34706. positionScale: number;
  34707. /**
  34708. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34709. * behaviour is triggered, in radians.
  34710. */
  34711. /**
  34712. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34713. * behaviour is triggered, in radians.
  34714. */
  34715. defaultElevation: number;
  34716. /**
  34717. * Sets the time (in milliseconds) taken to return to the default beta position.
  34718. * Negative value indicates camera should not return to default.
  34719. */
  34720. /**
  34721. * Gets the time (in milliseconds) taken to return to the default beta position.
  34722. * Negative value indicates camera should not return to default.
  34723. */
  34724. elevationReturnTime: number;
  34725. /**
  34726. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34727. */
  34728. /**
  34729. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34730. */
  34731. elevationReturnWaitTime: number;
  34732. /**
  34733. * Sets the flag that indicates if user zooming should stop animation.
  34734. */
  34735. /**
  34736. * Gets the flag that indicates if user zooming should stop animation.
  34737. */
  34738. zoomStopsAnimation: boolean;
  34739. /**
  34740. * Sets the transition time when framing the mesh, in milliseconds
  34741. */
  34742. /**
  34743. * Gets the transition time when framing the mesh, in milliseconds
  34744. */
  34745. framingTime: number;
  34746. /**
  34747. * Define if the behavior should automatically change the configured
  34748. * camera limits and sensibilities.
  34749. */
  34750. autoCorrectCameraLimitsAndSensibility: boolean;
  34751. private _onPrePointerObservableObserver;
  34752. private _onAfterCheckInputsObserver;
  34753. private _onMeshTargetChangedObserver;
  34754. private _attachedCamera;
  34755. private _isPointerDown;
  34756. private _lastInteractionTime;
  34757. /**
  34758. * Initializes the behavior.
  34759. */
  34760. init(): void;
  34761. /**
  34762. * Attaches the behavior to its arc rotate camera.
  34763. * @param camera Defines the camera to attach the behavior to
  34764. */
  34765. attach(camera: ArcRotateCamera): void;
  34766. /**
  34767. * Detaches the behavior from its current arc rotate camera.
  34768. */
  34769. detach(): void;
  34770. private _animatables;
  34771. private _betaIsAnimating;
  34772. private _betaTransition;
  34773. private _radiusTransition;
  34774. private _vectorTransition;
  34775. /**
  34776. * Targets the given mesh and updates zoom level accordingly.
  34777. * @param mesh The mesh to target.
  34778. * @param radius Optional. If a cached radius position already exists, overrides default.
  34779. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34782. */
  34783. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34784. /**
  34785. * Targets the given mesh with its children and updates zoom level accordingly.
  34786. * @param mesh The mesh to target.
  34787. * @param radius Optional. If a cached radius position already exists, overrides default.
  34788. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34789. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34790. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34791. */
  34792. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34793. /**
  34794. * Targets the given meshes with their children and updates zoom level accordingly.
  34795. * @param meshes The mesh to target.
  34796. * @param radius Optional. If a cached radius position already exists, overrides default.
  34797. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34798. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34799. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34800. */
  34801. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34802. /**
  34803. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34804. * @param minimumWorld Determines the smaller position of the bounding box extend
  34805. * @param maximumWorld Determines the bigger position of the bounding box extend
  34806. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34807. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34808. */
  34809. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34810. /**
  34811. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34812. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34813. * frustum width.
  34814. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34815. * to fully enclose the mesh in the viewing frustum.
  34816. */
  34817. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34818. /**
  34819. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34820. * is automatically returned to its default position (expected to be above ground plane).
  34821. */
  34822. private _maintainCameraAboveGround;
  34823. /**
  34824. * Returns the frustum slope based on the canvas ratio and camera FOV
  34825. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34826. */
  34827. private _getFrustumSlope;
  34828. /**
  34829. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34830. */
  34831. private _clearAnimationLocks;
  34832. /**
  34833. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34834. */
  34835. private _applyUserInteraction;
  34836. /**
  34837. * Stops and removes all animations that have been applied to the camera
  34838. */
  34839. stopAllAnimations(): void;
  34840. /**
  34841. * Gets a value indicating if the user is moving the camera
  34842. */
  34843. readonly isUserIsMoving: boolean;
  34844. /**
  34845. * The camera can move all the way towards the mesh.
  34846. */
  34847. static IgnoreBoundsSizeMode: number;
  34848. /**
  34849. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34850. */
  34851. static FitFrustumSidesMode: number;
  34852. }
  34853. }
  34854. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34855. import { Nullable } from "babylonjs/types";
  34856. import { Camera } from "babylonjs/Cameras/camera";
  34857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34858. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34859. /**
  34860. * Base class for Camera Pointer Inputs.
  34861. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34862. * for example usage.
  34863. */
  34864. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34865. /**
  34866. * Defines the camera the input is attached to.
  34867. */
  34868. abstract camera: Camera;
  34869. /**
  34870. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34871. */
  34872. protected _altKey: boolean;
  34873. protected _ctrlKey: boolean;
  34874. protected _metaKey: boolean;
  34875. protected _shiftKey: boolean;
  34876. /**
  34877. * Which mouse buttons were pressed at time of last mouse event.
  34878. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34879. */
  34880. protected _buttonsPressed: number;
  34881. /**
  34882. * Defines the buttons associated with the input to handle camera move.
  34883. */
  34884. buttons: number[];
  34885. /**
  34886. * Attach the input controls to a specific dom element to get the input from.
  34887. * @param element Defines the element the controls should be listened from
  34888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34889. */
  34890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34891. /**
  34892. * Detach the current controls from the specified dom element.
  34893. * @param element Defines the element to stop listening the inputs from
  34894. */
  34895. detachControl(element: Nullable<HTMLElement>): void;
  34896. /**
  34897. * Gets the class name of the current input.
  34898. * @returns the class name
  34899. */
  34900. getClassName(): string;
  34901. /**
  34902. * Get the friendly name associated with the input class.
  34903. * @returns the input friendly name
  34904. */
  34905. getSimpleName(): string;
  34906. /**
  34907. * Called on pointer POINTERDOUBLETAP event.
  34908. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34909. */
  34910. protected onDoubleTap(type: string): void;
  34911. /**
  34912. * Called on pointer POINTERMOVE event if only a single touch is active.
  34913. * Override this method to provide functionality.
  34914. */
  34915. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34916. /**
  34917. * Called on pointer POINTERMOVE event if multiple touches are active.
  34918. * Override this method to provide functionality.
  34919. */
  34920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34921. /**
  34922. * Called on JS contextmenu event.
  34923. * Override this method to provide functionality.
  34924. */
  34925. protected onContextMenu(evt: PointerEvent): void;
  34926. /**
  34927. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34928. * press.
  34929. * Override this method to provide functionality.
  34930. */
  34931. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34932. /**
  34933. * Called each time a new POINTERUP event occurs. Ie, for each button
  34934. * release.
  34935. * Override this method to provide functionality.
  34936. */
  34937. protected onButtonUp(evt: PointerEvent): void;
  34938. /**
  34939. * Called when window becomes inactive.
  34940. * Override this method to provide functionality.
  34941. */
  34942. protected onLostFocus(): void;
  34943. private _pointerInput;
  34944. private _observer;
  34945. private _onLostFocus;
  34946. }
  34947. }
  34948. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34949. import { Nullable } from "babylonjs/types";
  34950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34951. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34952. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34953. /**
  34954. * Manage the pointers inputs to control an arc rotate camera.
  34955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34956. */
  34957. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34958. /**
  34959. * Defines the camera the input is attached to.
  34960. */
  34961. camera: ArcRotateCamera;
  34962. /**
  34963. * Gets the class name of the current input.
  34964. * @returns the class name
  34965. */
  34966. getClassName(): string;
  34967. /**
  34968. * Defines the buttons associated with the input to handle camera move.
  34969. */
  34970. buttons: number[];
  34971. /**
  34972. * Defines the pointer angular sensibility along the X axis or how fast is
  34973. * the camera rotating.
  34974. */
  34975. angularSensibilityX: number;
  34976. /**
  34977. * Defines the pointer angular sensibility along the Y axis or how fast is
  34978. * the camera rotating.
  34979. */
  34980. angularSensibilityY: number;
  34981. /**
  34982. * Defines the pointer pinch precision or how fast is the camera zooming.
  34983. */
  34984. pinchPrecision: number;
  34985. /**
  34986. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34987. * from 0.
  34988. * It defines the percentage of current camera.radius to use as delta when
  34989. * pinch zoom is used.
  34990. */
  34991. pinchDeltaPercentage: number;
  34992. /**
  34993. * Defines the pointer panning sensibility or how fast is the camera moving.
  34994. */
  34995. panningSensibility: number;
  34996. /**
  34997. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34998. */
  34999. multiTouchPanning: boolean;
  35000. /**
  35001. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35002. * zoom (pinch) through multitouch.
  35003. */
  35004. multiTouchPanAndZoom: boolean;
  35005. /**
  35006. * Revers pinch action direction.
  35007. */
  35008. pinchInwards: boolean;
  35009. private _isPanClick;
  35010. private _twoFingerActivityCount;
  35011. private _isPinching;
  35012. /**
  35013. * Called on pointer POINTERMOVE event if only a single touch is active.
  35014. */
  35015. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35016. /**
  35017. * Called on pointer POINTERDOUBLETAP event.
  35018. */
  35019. protected onDoubleTap(type: string): void;
  35020. /**
  35021. * Called on pointer POINTERMOVE event if multiple touches are active.
  35022. */
  35023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35024. /**
  35025. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35026. * press.
  35027. */
  35028. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  35029. /**
  35030. * Called each time a new POINTERUP event occurs. Ie, for each button
  35031. * release.
  35032. */
  35033. protected onButtonUp(evt: PointerEvent): void;
  35034. /**
  35035. * Called when window becomes inactive.
  35036. */
  35037. protected onLostFocus(): void;
  35038. }
  35039. }
  35040. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35041. import { Nullable } from "babylonjs/types";
  35042. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35044. /**
  35045. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35047. */
  35048. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35049. /**
  35050. * Defines the camera the input is attached to.
  35051. */
  35052. camera: ArcRotateCamera;
  35053. /**
  35054. * Defines the list of key codes associated with the up action (increase alpha)
  35055. */
  35056. keysUp: number[];
  35057. /**
  35058. * Defines the list of key codes associated with the down action (decrease alpha)
  35059. */
  35060. keysDown: number[];
  35061. /**
  35062. * Defines the list of key codes associated with the left action (increase beta)
  35063. */
  35064. keysLeft: number[];
  35065. /**
  35066. * Defines the list of key codes associated with the right action (decrease beta)
  35067. */
  35068. keysRight: number[];
  35069. /**
  35070. * Defines the list of key codes associated with the reset action.
  35071. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35072. */
  35073. keysReset: number[];
  35074. /**
  35075. * Defines the panning sensibility of the inputs.
  35076. * (How fast is the camera paning)
  35077. */
  35078. panningSensibility: number;
  35079. /**
  35080. * Defines the zooming sensibility of the inputs.
  35081. * (How fast is the camera zooming)
  35082. */
  35083. zoomingSensibility: number;
  35084. /**
  35085. * Defines wether maintaining the alt key down switch the movement mode from
  35086. * orientation to zoom.
  35087. */
  35088. useAltToZoom: boolean;
  35089. /**
  35090. * Rotation speed of the camera
  35091. */
  35092. angularSpeed: number;
  35093. private _keys;
  35094. private _ctrlPressed;
  35095. private _altPressed;
  35096. private _onCanvasBlurObserver;
  35097. private _onKeyboardObserver;
  35098. private _engine;
  35099. private _scene;
  35100. /**
  35101. * Attach the input controls to a specific dom element to get the input from.
  35102. * @param element Defines the element the controls should be listened from
  35103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35104. */
  35105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35106. /**
  35107. * Detach the current controls from the specified dom element.
  35108. * @param element Defines the element to stop listening the inputs from
  35109. */
  35110. detachControl(element: Nullable<HTMLElement>): void;
  35111. /**
  35112. * Update the current camera state depending on the inputs that have been used this frame.
  35113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35114. */
  35115. checkInputs(): void;
  35116. /**
  35117. * Gets the class name of the current intput.
  35118. * @returns the class name
  35119. */
  35120. getClassName(): string;
  35121. /**
  35122. * Get the friendly name associated with the input class.
  35123. * @returns the input friendly name
  35124. */
  35125. getSimpleName(): string;
  35126. }
  35127. }
  35128. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35129. import { Nullable } from "babylonjs/types";
  35130. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35131. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35132. /**
  35133. * Manage the mouse wheel inputs to control an arc rotate camera.
  35134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35135. */
  35136. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35137. /**
  35138. * Defines the camera the input is attached to.
  35139. */
  35140. camera: ArcRotateCamera;
  35141. /**
  35142. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35143. */
  35144. wheelPrecision: number;
  35145. /**
  35146. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35147. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35148. */
  35149. wheelDeltaPercentage: number;
  35150. private _wheel;
  35151. private _observer;
  35152. /**
  35153. * Attach the input controls to a specific dom element to get the input from.
  35154. * @param element Defines the element the controls should be listened from
  35155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35156. */
  35157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35158. /**
  35159. * Detach the current controls from the specified dom element.
  35160. * @param element Defines the element to stop listening the inputs from
  35161. */
  35162. detachControl(element: Nullable<HTMLElement>): void;
  35163. /**
  35164. * Gets the class name of the current intput.
  35165. * @returns the class name
  35166. */
  35167. getClassName(): string;
  35168. /**
  35169. * Get the friendly name associated with the input class.
  35170. * @returns the input friendly name
  35171. */
  35172. getSimpleName(): string;
  35173. }
  35174. }
  35175. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35176. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35177. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35178. /**
  35179. * Default Inputs manager for the ArcRotateCamera.
  35180. * It groups all the default supported inputs for ease of use.
  35181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35182. */
  35183. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35184. /**
  35185. * Instantiates a new ArcRotateCameraInputsManager.
  35186. * @param camera Defines the camera the inputs belong to
  35187. */
  35188. constructor(camera: ArcRotateCamera);
  35189. /**
  35190. * Add mouse wheel input support to the input manager.
  35191. * @returns the current input manager
  35192. */
  35193. addMouseWheel(): ArcRotateCameraInputsManager;
  35194. /**
  35195. * Add pointers input support to the input manager.
  35196. * @returns the current input manager
  35197. */
  35198. addPointers(): ArcRotateCameraInputsManager;
  35199. /**
  35200. * Add keyboard input support to the input manager.
  35201. * @returns the current input manager
  35202. */
  35203. addKeyboard(): ArcRotateCameraInputsManager;
  35204. }
  35205. }
  35206. declare module "babylonjs/Cameras/arcRotateCamera" {
  35207. import { Observable } from "babylonjs/Misc/observable";
  35208. import { Nullable } from "babylonjs/types";
  35209. import { Scene } from "babylonjs/scene";
  35210. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35212. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35213. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35214. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35215. import { Camera } from "babylonjs/Cameras/camera";
  35216. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35217. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35218. import { Collider } from "babylonjs/Collisions/collider";
  35219. /**
  35220. * This represents an orbital type of camera.
  35221. *
  35222. * 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.
  35223. * 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.
  35224. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35225. */
  35226. export class ArcRotateCamera extends TargetCamera {
  35227. /**
  35228. * Defines the rotation angle of the camera along the longitudinal axis.
  35229. */
  35230. alpha: number;
  35231. /**
  35232. * Defines the rotation angle of the camera along the latitudinal axis.
  35233. */
  35234. beta: number;
  35235. /**
  35236. * Defines the radius of the camera from it s target point.
  35237. */
  35238. radius: number;
  35239. protected _target: Vector3;
  35240. protected _targetHost: Nullable<AbstractMesh>;
  35241. /**
  35242. * Defines the target point of the camera.
  35243. * The camera looks towards it form the radius distance.
  35244. */
  35245. target: Vector3;
  35246. /**
  35247. * Define the current local position of the camera in the scene
  35248. */
  35249. position: Vector3;
  35250. /**
  35251. * Current inertia value on the longitudinal axis.
  35252. * The bigger this number the longer it will take for the camera to stop.
  35253. */
  35254. inertialAlphaOffset: number;
  35255. /**
  35256. * Current inertia value on the latitudinal axis.
  35257. * The bigger this number the longer it will take for the camera to stop.
  35258. */
  35259. inertialBetaOffset: number;
  35260. /**
  35261. * Current inertia value on the radius axis.
  35262. * The bigger this number the longer it will take for the camera to stop.
  35263. */
  35264. inertialRadiusOffset: number;
  35265. /**
  35266. * Minimum allowed angle on the longitudinal axis.
  35267. * This can help limiting how the Camera is able to move in the scene.
  35268. */
  35269. lowerAlphaLimit: Nullable<number>;
  35270. /**
  35271. * Maximum allowed angle on the longitudinal axis.
  35272. * This can help limiting how the Camera is able to move in the scene.
  35273. */
  35274. upperAlphaLimit: Nullable<number>;
  35275. /**
  35276. * Minimum allowed angle on the latitudinal axis.
  35277. * This can help limiting how the Camera is able to move in the scene.
  35278. */
  35279. lowerBetaLimit: number;
  35280. /**
  35281. * Maximum allowed angle on the latitudinal axis.
  35282. * This can help limiting how the Camera is able to move in the scene.
  35283. */
  35284. upperBetaLimit: number;
  35285. /**
  35286. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35287. * This can help limiting how the Camera is able to move in the scene.
  35288. */
  35289. lowerRadiusLimit: Nullable<number>;
  35290. /**
  35291. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35292. * This can help limiting how the Camera is able to move in the scene.
  35293. */
  35294. upperRadiusLimit: Nullable<number>;
  35295. /**
  35296. * Defines the current inertia value used during panning of the camera along the X axis.
  35297. */
  35298. inertialPanningX: number;
  35299. /**
  35300. * Defines the current inertia value used during panning of the camera along the Y axis.
  35301. */
  35302. inertialPanningY: number;
  35303. /**
  35304. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35305. * Basically if your fingers moves away from more than this distance you will be considered
  35306. * in pinch mode.
  35307. */
  35308. pinchToPanMaxDistance: number;
  35309. /**
  35310. * Defines the maximum distance the camera can pan.
  35311. * This could help keeping the cammera always in your scene.
  35312. */
  35313. panningDistanceLimit: Nullable<number>;
  35314. /**
  35315. * Defines the target of the camera before paning.
  35316. */
  35317. panningOriginTarget: Vector3;
  35318. /**
  35319. * Defines the value of the inertia used during panning.
  35320. * 0 would mean stop inertia and one would mean no decelleration at all.
  35321. */
  35322. panningInertia: number;
  35323. /**
  35324. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35325. */
  35326. angularSensibilityX: number;
  35327. /**
  35328. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35329. */
  35330. angularSensibilityY: number;
  35331. /**
  35332. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35333. */
  35334. pinchPrecision: number;
  35335. /**
  35336. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35337. * It will be used instead of pinchDeltaPrecision if different from 0.
  35338. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35339. */
  35340. pinchDeltaPercentage: number;
  35341. /**
  35342. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35343. */
  35344. panningSensibility: number;
  35345. /**
  35346. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35347. */
  35348. keysUp: number[];
  35349. /**
  35350. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35351. */
  35352. keysDown: number[];
  35353. /**
  35354. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35355. */
  35356. keysLeft: number[];
  35357. /**
  35358. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35359. */
  35360. keysRight: number[];
  35361. /**
  35362. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35363. */
  35364. wheelPrecision: number;
  35365. /**
  35366. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35367. * It will be used instead of pinchDeltaPrecision if different from 0.
  35368. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35369. */
  35370. wheelDeltaPercentage: number;
  35371. /**
  35372. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35373. */
  35374. zoomOnFactor: number;
  35375. /**
  35376. * Defines a screen offset for the camera position.
  35377. */
  35378. targetScreenOffset: Vector2;
  35379. /**
  35380. * Allows the camera to be completely reversed.
  35381. * If false the camera can not arrive upside down.
  35382. */
  35383. allowUpsideDown: boolean;
  35384. /**
  35385. * Define if double tap/click is used to restore the previously saved state of the camera.
  35386. */
  35387. useInputToRestoreState: boolean;
  35388. /** @hidden */
  35389. _viewMatrix: Matrix;
  35390. /** @hidden */
  35391. _useCtrlForPanning: boolean;
  35392. /** @hidden */
  35393. _panningMouseButton: number;
  35394. /**
  35395. * Defines the input associated to the camera.
  35396. */
  35397. inputs: ArcRotateCameraInputsManager;
  35398. /** @hidden */
  35399. _reset: () => void;
  35400. /**
  35401. * Defines the allowed panning axis.
  35402. */
  35403. panningAxis: Vector3;
  35404. protected _localDirection: Vector3;
  35405. protected _transformedDirection: Vector3;
  35406. private _bouncingBehavior;
  35407. /**
  35408. * Gets the bouncing behavior of the camera if it has been enabled.
  35409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35410. */
  35411. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35412. /**
  35413. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35415. */
  35416. useBouncingBehavior: boolean;
  35417. private _framingBehavior;
  35418. /**
  35419. * Gets the framing behavior of the camera if it has been enabled.
  35420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35421. */
  35422. readonly framingBehavior: Nullable<FramingBehavior>;
  35423. /**
  35424. * Defines if the framing behavior of the camera is enabled on the camera.
  35425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35426. */
  35427. useFramingBehavior: boolean;
  35428. private _autoRotationBehavior;
  35429. /**
  35430. * Gets the auto rotation behavior of the camera if it has been enabled.
  35431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35432. */
  35433. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35434. /**
  35435. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35437. */
  35438. useAutoRotationBehavior: boolean;
  35439. /**
  35440. * Observable triggered when the mesh target has been changed on the camera.
  35441. */
  35442. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35443. /**
  35444. * Event raised when the camera is colliding with a mesh.
  35445. */
  35446. onCollide: (collidedMesh: AbstractMesh) => void;
  35447. /**
  35448. * Defines whether the camera should check collision with the objects oh the scene.
  35449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35450. */
  35451. checkCollisions: boolean;
  35452. /**
  35453. * Defines the collision radius of the camera.
  35454. * This simulates a sphere around the camera.
  35455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35456. */
  35457. collisionRadius: Vector3;
  35458. protected _collider: Collider;
  35459. protected _previousPosition: Vector3;
  35460. protected _collisionVelocity: Vector3;
  35461. protected _newPosition: Vector3;
  35462. protected _previousAlpha: number;
  35463. protected _previousBeta: number;
  35464. protected _previousRadius: number;
  35465. protected _collisionTriggered: boolean;
  35466. protected _targetBoundingCenter: Nullable<Vector3>;
  35467. private _computationVector;
  35468. private _tempAxisVector;
  35469. private _tempAxisRotationMatrix;
  35470. /**
  35471. * Instantiates a new ArcRotateCamera in a given scene
  35472. * @param name Defines the name of the camera
  35473. * @param alpha Defines the camera rotation along the logitudinal axis
  35474. * @param beta Defines the camera rotation along the latitudinal axis
  35475. * @param radius Defines the camera distance from its target
  35476. * @param target Defines the camera target
  35477. * @param scene Defines the scene the camera belongs to
  35478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35479. */
  35480. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35481. /** @hidden */
  35482. _initCache(): void;
  35483. /** @hidden */
  35484. _updateCache(ignoreParentClass?: boolean): void;
  35485. protected _getTargetPosition(): Vector3;
  35486. private _storedAlpha;
  35487. private _storedBeta;
  35488. private _storedRadius;
  35489. private _storedTarget;
  35490. /**
  35491. * Stores the current state of the camera (alpha, beta, radius and target)
  35492. * @returns the camera itself
  35493. */
  35494. storeState(): Camera;
  35495. /**
  35496. * @hidden
  35497. * Restored camera state. You must call storeState() first
  35498. */
  35499. _restoreStateValues(): boolean;
  35500. /** @hidden */
  35501. _isSynchronizedViewMatrix(): boolean;
  35502. /**
  35503. * Attached controls to the current camera.
  35504. * @param element Defines the element the controls should be listened from
  35505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35506. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35507. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35508. */
  35509. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35510. /**
  35511. * Detach the current controls from the camera.
  35512. * The camera will stop reacting to inputs.
  35513. * @param element Defines the element to stop listening the inputs from
  35514. */
  35515. detachControl(element: HTMLElement): void;
  35516. /** @hidden */
  35517. _checkInputs(): void;
  35518. protected _checkLimits(): void;
  35519. /**
  35520. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35521. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35522. */
  35523. rebuildAnglesAndRadius(updateView?: boolean): void;
  35524. /**
  35525. * Use a position to define the current camera related information like aplha, beta and radius
  35526. * @param position Defines the position to set the camera at
  35527. */
  35528. setPosition(position: Vector3): void;
  35529. /**
  35530. * Defines the target the camera should look at.
  35531. * This will automatically adapt alpha beta and radius to fit within the new target.
  35532. * @param target Defines the new target as a Vector or a mesh
  35533. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35534. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35535. */
  35536. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35537. /** @hidden */
  35538. _getViewMatrix(): Matrix;
  35539. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35540. /**
  35541. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35542. * @param meshes Defines the mesh to zoom on
  35543. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  35544. */
  35545. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35546. /**
  35547. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35548. * The target will be changed but the radius
  35549. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35550. * @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)
  35551. */
  35552. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35553. min: Vector3;
  35554. max: Vector3;
  35555. distance: number;
  35556. }, doNotUpdateMaxZ?: boolean): void;
  35557. /**
  35558. * @override
  35559. * Override Camera.createRigCamera
  35560. */
  35561. createRigCamera(name: string, cameraIndex: number): Camera;
  35562. /**
  35563. * @hidden
  35564. * @override
  35565. * Override Camera._updateRigCameras
  35566. */
  35567. _updateRigCameras(): void;
  35568. /**
  35569. * Destroy the camera and release the current resources hold by it.
  35570. */
  35571. dispose(): void;
  35572. /**
  35573. * Gets the current object class name.
  35574. * @return the class name
  35575. */
  35576. getClassName(): string;
  35577. }
  35578. }
  35579. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35580. import { Behavior } from "babylonjs/Behaviors/behavior";
  35581. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35582. /**
  35583. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35585. */
  35586. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35587. /**
  35588. * Gets the name of the behavior.
  35589. */
  35590. readonly name: string;
  35591. private _zoomStopsAnimation;
  35592. private _idleRotationSpeed;
  35593. private _idleRotationWaitTime;
  35594. private _idleRotationSpinupTime;
  35595. /**
  35596. * Sets the flag that indicates if user zooming should stop animation.
  35597. */
  35598. /**
  35599. * Gets the flag that indicates if user zooming should stop animation.
  35600. */
  35601. zoomStopsAnimation: boolean;
  35602. /**
  35603. * Sets the default speed at which the camera rotates around the model.
  35604. */
  35605. /**
  35606. * Gets the default speed at which the camera rotates around the model.
  35607. */
  35608. idleRotationSpeed: number;
  35609. /**
  35610. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35611. */
  35612. /**
  35613. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35614. */
  35615. idleRotationWaitTime: number;
  35616. /**
  35617. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35618. */
  35619. /**
  35620. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35621. */
  35622. idleRotationSpinupTime: number;
  35623. /**
  35624. * Gets a value indicating if the camera is currently rotating because of this behavior
  35625. */
  35626. readonly rotationInProgress: boolean;
  35627. private _onPrePointerObservableObserver;
  35628. private _onAfterCheckInputsObserver;
  35629. private _attachedCamera;
  35630. private _isPointerDown;
  35631. private _lastFrameTime;
  35632. private _lastInteractionTime;
  35633. private _cameraRotationSpeed;
  35634. /**
  35635. * Initializes the behavior.
  35636. */
  35637. init(): void;
  35638. /**
  35639. * Attaches the behavior to its arc rotate camera.
  35640. * @param camera Defines the camera to attach the behavior to
  35641. */
  35642. attach(camera: ArcRotateCamera): void;
  35643. /**
  35644. * Detaches the behavior from its current arc rotate camera.
  35645. */
  35646. detach(): void;
  35647. /**
  35648. * Returns true if user is scrolling.
  35649. * @return true if user is scrolling.
  35650. */
  35651. private _userIsZooming;
  35652. private _lastFrameRadius;
  35653. private _shouldAnimationStopForInteraction;
  35654. /**
  35655. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35656. */
  35657. private _applyUserInteraction;
  35658. private _userIsMoving;
  35659. }
  35660. }
  35661. declare module "babylonjs/Behaviors/Cameras/index" {
  35662. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35663. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35664. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35665. }
  35666. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35667. import { Mesh } from "babylonjs/Meshes/mesh";
  35668. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35669. import { Behavior } from "babylonjs/Behaviors/behavior";
  35670. /**
  35671. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35672. */
  35673. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35674. private ui;
  35675. /**
  35676. * The name of the behavior
  35677. */
  35678. name: string;
  35679. /**
  35680. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35681. */
  35682. distanceAwayFromFace: number;
  35683. /**
  35684. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35685. */
  35686. distanceAwayFromBottomOfFace: number;
  35687. private _faceVectors;
  35688. private _target;
  35689. private _scene;
  35690. private _onRenderObserver;
  35691. private _tmpMatrix;
  35692. private _tmpVector;
  35693. /**
  35694. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35695. * @param ui The transform node that should be attched to the mesh
  35696. */
  35697. constructor(ui: TransformNode);
  35698. /**
  35699. * Initializes the behavior
  35700. */
  35701. init(): void;
  35702. private _closestFace;
  35703. private _zeroVector;
  35704. private _lookAtTmpMatrix;
  35705. private _lookAtToRef;
  35706. /**
  35707. * Attaches the AttachToBoxBehavior to the passed in mesh
  35708. * @param target The mesh that the specified node will be attached to
  35709. */
  35710. attach(target: Mesh): void;
  35711. /**
  35712. * Detaches the behavior from the mesh
  35713. */
  35714. detach(): void;
  35715. }
  35716. }
  35717. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35718. import { Behavior } from "babylonjs/Behaviors/behavior";
  35719. import { Mesh } from "babylonjs/Meshes/mesh";
  35720. /**
  35721. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35722. */
  35723. export class FadeInOutBehavior implements Behavior<Mesh> {
  35724. /**
  35725. * Time in milliseconds to delay before fading in (Default: 0)
  35726. */
  35727. delay: number;
  35728. /**
  35729. * Time in milliseconds for the mesh to fade in (Default: 300)
  35730. */
  35731. fadeInTime: number;
  35732. private _millisecondsPerFrame;
  35733. private _hovered;
  35734. private _hoverValue;
  35735. private _ownerNode;
  35736. /**
  35737. * Instatiates the FadeInOutBehavior
  35738. */
  35739. constructor();
  35740. /**
  35741. * The name of the behavior
  35742. */
  35743. readonly name: string;
  35744. /**
  35745. * Initializes the behavior
  35746. */
  35747. init(): void;
  35748. /**
  35749. * Attaches the fade behavior on the passed in mesh
  35750. * @param ownerNode The mesh that will be faded in/out once attached
  35751. */
  35752. attach(ownerNode: Mesh): void;
  35753. /**
  35754. * Detaches the behavior from the mesh
  35755. */
  35756. detach(): void;
  35757. /**
  35758. * Triggers the mesh to begin fading in or out
  35759. * @param value if the object should fade in or out (true to fade in)
  35760. */
  35761. fadeIn(value: boolean): void;
  35762. private _update;
  35763. private _setAllVisibility;
  35764. }
  35765. }
  35766. declare module "babylonjs/Misc/pivotTools" {
  35767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35768. /**
  35769. * Class containing a set of static utilities functions for managing Pivots
  35770. * @hidden
  35771. */
  35772. export class PivotTools {
  35773. private static _PivotCached;
  35774. private static _OldPivotPoint;
  35775. private static _PivotTranslation;
  35776. private static _PivotTmpVector;
  35777. /** @hidden */
  35778. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35779. /** @hidden */
  35780. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35781. }
  35782. }
  35783. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35784. import { Scene } from "babylonjs/scene";
  35785. import { Vector4, Plane } from "babylonjs/Maths/math";
  35786. import { Mesh } from "babylonjs/Meshes/mesh";
  35787. /**
  35788. * Class containing static functions to help procedurally build meshes
  35789. */
  35790. export class PlaneBuilder {
  35791. /**
  35792. * Creates a plane mesh
  35793. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35794. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35795. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35799. * @param name defines the name of the mesh
  35800. * @param options defines the options used to create the mesh
  35801. * @param scene defines the hosting scene
  35802. * @returns the plane mesh
  35803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35804. */
  35805. static CreatePlane(name: string, options: {
  35806. size?: number;
  35807. width?: number;
  35808. height?: number;
  35809. sideOrientation?: number;
  35810. frontUVs?: Vector4;
  35811. backUVs?: Vector4;
  35812. updatable?: boolean;
  35813. sourcePlane?: Plane;
  35814. }, scene: Scene): Mesh;
  35815. }
  35816. }
  35817. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35818. import { Behavior } from "babylonjs/Behaviors/behavior";
  35819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35820. import { Observable } from "babylonjs/Misc/observable";
  35821. import { Vector3 } from "babylonjs/Maths/math";
  35822. import { Ray } from "babylonjs/Culling/ray";
  35823. import "babylonjs/Meshes/Builders/planeBuilder";
  35824. /**
  35825. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35826. */
  35827. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35828. private static _AnyMouseID;
  35829. private _attachedNode;
  35830. private _dragPlane;
  35831. private _scene;
  35832. private _pointerObserver;
  35833. private _beforeRenderObserver;
  35834. private static _planeScene;
  35835. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35836. /**
  35837. * 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)
  35838. */
  35839. maxDragAngle: number;
  35840. /**
  35841. * @hidden
  35842. */
  35843. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35844. /**
  35845. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35846. */
  35847. currentDraggingPointerID: number;
  35848. /**
  35849. * The last position where the pointer hit the drag plane in world space
  35850. */
  35851. lastDragPosition: Vector3;
  35852. /**
  35853. * If the behavior is currently in a dragging state
  35854. */
  35855. dragging: boolean;
  35856. /**
  35857. * 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)
  35858. */
  35859. dragDeltaRatio: number;
  35860. /**
  35861. * If the drag plane orientation should be updated during the dragging (Default: true)
  35862. */
  35863. updateDragPlane: boolean;
  35864. private _debugMode;
  35865. private _moving;
  35866. /**
  35867. * Fires each time the attached mesh is dragged with the pointer
  35868. * * delta between last drag position and current drag position in world space
  35869. * * dragDistance along the drag axis
  35870. * * dragPlaneNormal normal of the current drag plane used during the drag
  35871. * * dragPlanePoint in world space where the drag intersects the drag plane
  35872. */
  35873. onDragObservable: Observable<{
  35874. delta: Vector3;
  35875. dragPlanePoint: Vector3;
  35876. dragPlaneNormal: Vector3;
  35877. dragDistance: number;
  35878. pointerId: number;
  35879. }>;
  35880. /**
  35881. * Fires each time a drag begins (eg. mouse down on mesh)
  35882. */
  35883. onDragStartObservable: Observable<{
  35884. dragPlanePoint: Vector3;
  35885. pointerId: number;
  35886. }>;
  35887. /**
  35888. * Fires each time a drag ends (eg. mouse release after drag)
  35889. */
  35890. onDragEndObservable: Observable<{
  35891. dragPlanePoint: Vector3;
  35892. pointerId: number;
  35893. }>;
  35894. /**
  35895. * If the attached mesh should be moved when dragged
  35896. */
  35897. moveAttached: boolean;
  35898. /**
  35899. * If the drag behavior will react to drag events (Default: true)
  35900. */
  35901. enabled: boolean;
  35902. /**
  35903. * If camera controls should be detached during the drag
  35904. */
  35905. detachCameraControls: boolean;
  35906. /**
  35907. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35908. */
  35909. useObjectOrienationForDragging: boolean;
  35910. private _options;
  35911. /**
  35912. * Creates a pointer drag behavior that can be attached to a mesh
  35913. * @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)
  35914. */
  35915. constructor(options?: {
  35916. dragAxis?: Vector3;
  35917. dragPlaneNormal?: Vector3;
  35918. });
  35919. /**
  35920. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35921. */
  35922. validateDrag: (targetPosition: Vector3) => boolean;
  35923. /**
  35924. * The name of the behavior
  35925. */
  35926. readonly name: string;
  35927. /**
  35928. * Initializes the behavior
  35929. */
  35930. init(): void;
  35931. private _tmpVector;
  35932. private _alternatePickedPoint;
  35933. private _worldDragAxis;
  35934. private _targetPosition;
  35935. private _attachedElement;
  35936. /**
  35937. * Attaches the drag behavior the passed in mesh
  35938. * @param ownerNode The mesh that will be dragged around once attached
  35939. */
  35940. attach(ownerNode: AbstractMesh): void;
  35941. /**
  35942. * Force relase the drag action by code.
  35943. */
  35944. releaseDrag(): void;
  35945. private _startDragRay;
  35946. private _lastPointerRay;
  35947. /**
  35948. * Simulates the start of a pointer drag event on the behavior
  35949. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35950. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35951. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35952. */
  35953. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35954. private _startDrag;
  35955. private _dragDelta;
  35956. private _moveDrag;
  35957. private _pickWithRayOnDragPlane;
  35958. private _pointA;
  35959. private _pointB;
  35960. private _pointC;
  35961. private _lineA;
  35962. private _lineB;
  35963. private _localAxis;
  35964. private _lookAt;
  35965. private _updateDragPlanePosition;
  35966. /**
  35967. * Detaches the behavior from the mesh
  35968. */
  35969. detach(): void;
  35970. }
  35971. }
  35972. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35973. import { Mesh } from "babylonjs/Meshes/mesh";
  35974. import { Behavior } from "babylonjs/Behaviors/behavior";
  35975. /**
  35976. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35977. */
  35978. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35979. private _dragBehaviorA;
  35980. private _dragBehaviorB;
  35981. private _startDistance;
  35982. private _initialScale;
  35983. private _targetScale;
  35984. private _ownerNode;
  35985. private _sceneRenderObserver;
  35986. /**
  35987. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35988. */
  35989. constructor();
  35990. /**
  35991. * The name of the behavior
  35992. */
  35993. readonly name: string;
  35994. /**
  35995. * Initializes the behavior
  35996. */
  35997. init(): void;
  35998. private _getCurrentDistance;
  35999. /**
  36000. * Attaches the scale behavior the passed in mesh
  36001. * @param ownerNode The mesh that will be scaled around once attached
  36002. */
  36003. attach(ownerNode: Mesh): void;
  36004. /**
  36005. * Detaches the behavior from the mesh
  36006. */
  36007. detach(): void;
  36008. }
  36009. }
  36010. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36011. import { Behavior } from "babylonjs/Behaviors/behavior";
  36012. import { Mesh } from "babylonjs/Meshes/mesh";
  36013. import { Observable } from "babylonjs/Misc/observable";
  36014. /**
  36015. * 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
  36016. */
  36017. export class SixDofDragBehavior implements Behavior<Mesh> {
  36018. private static _virtualScene;
  36019. private _ownerNode;
  36020. private _sceneRenderObserver;
  36021. private _scene;
  36022. private _targetPosition;
  36023. private _virtualOriginMesh;
  36024. private _virtualDragMesh;
  36025. private _pointerObserver;
  36026. private _moving;
  36027. private _startingOrientation;
  36028. /**
  36029. * 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)
  36030. */
  36031. private zDragFactor;
  36032. /**
  36033. * If the object should rotate to face the drag origin
  36034. */
  36035. rotateDraggedObject: boolean;
  36036. /**
  36037. * If the behavior is currently in a dragging state
  36038. */
  36039. dragging: boolean;
  36040. /**
  36041. * 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)
  36042. */
  36043. dragDeltaRatio: number;
  36044. /**
  36045. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36046. */
  36047. currentDraggingPointerID: number;
  36048. /**
  36049. * If camera controls should be detached during the drag
  36050. */
  36051. detachCameraControls: boolean;
  36052. /**
  36053. * Fires each time a drag starts
  36054. */
  36055. onDragStartObservable: Observable<{}>;
  36056. /**
  36057. * Fires each time a drag ends (eg. mouse release after drag)
  36058. */
  36059. onDragEndObservable: Observable<{}>;
  36060. /**
  36061. * 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
  36062. */
  36063. constructor();
  36064. /**
  36065. * The name of the behavior
  36066. */
  36067. readonly name: string;
  36068. /**
  36069. * Initializes the behavior
  36070. */
  36071. init(): void;
  36072. /**
  36073. * Attaches the scale behavior the passed in mesh
  36074. * @param ownerNode The mesh that will be scaled around once attached
  36075. */
  36076. attach(ownerNode: Mesh): void;
  36077. /**
  36078. * Detaches the behavior from the mesh
  36079. */
  36080. detach(): void;
  36081. }
  36082. }
  36083. declare module "babylonjs/Behaviors/Meshes/index" {
  36084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36089. }
  36090. declare module "babylonjs/Behaviors/index" {
  36091. export * from "babylonjs/Behaviors/behavior";
  36092. export * from "babylonjs/Behaviors/Cameras/index";
  36093. export * from "babylonjs/Behaviors/Meshes/index";
  36094. }
  36095. declare module "babylonjs/Bones/boneIKController" {
  36096. import { Bone } from "babylonjs/Bones/bone";
  36097. import { Vector3 } from "babylonjs/Maths/math";
  36098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36099. import { Nullable } from "babylonjs/types";
  36100. /**
  36101. * Class used to apply inverse kinematics to bones
  36102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36103. */
  36104. export class BoneIKController {
  36105. private static _tmpVecs;
  36106. private static _tmpQuat;
  36107. private static _tmpMats;
  36108. /**
  36109. * Gets or sets the target mesh
  36110. */
  36111. targetMesh: AbstractMesh;
  36112. /** Gets or sets the mesh used as pole */
  36113. poleTargetMesh: AbstractMesh;
  36114. /**
  36115. * Gets or sets the bone used as pole
  36116. */
  36117. poleTargetBone: Nullable<Bone>;
  36118. /**
  36119. * Gets or sets the target position
  36120. */
  36121. targetPosition: Vector3;
  36122. /**
  36123. * Gets or sets the pole target position
  36124. */
  36125. poleTargetPosition: Vector3;
  36126. /**
  36127. * Gets or sets the pole target local offset
  36128. */
  36129. poleTargetLocalOffset: Vector3;
  36130. /**
  36131. * Gets or sets the pole angle
  36132. */
  36133. poleAngle: number;
  36134. /**
  36135. * Gets or sets the mesh associated with the controller
  36136. */
  36137. mesh: AbstractMesh;
  36138. /**
  36139. * 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)
  36140. */
  36141. slerpAmount: number;
  36142. private _bone1Quat;
  36143. private _bone1Mat;
  36144. private _bone2Ang;
  36145. private _bone1;
  36146. private _bone2;
  36147. private _bone1Length;
  36148. private _bone2Length;
  36149. private _maxAngle;
  36150. private _maxReach;
  36151. private _rightHandedSystem;
  36152. private _bendAxis;
  36153. private _slerping;
  36154. private _adjustRoll;
  36155. /**
  36156. * Gets or sets maximum allowed angle
  36157. */
  36158. maxAngle: number;
  36159. /**
  36160. * Creates a new BoneIKController
  36161. * @param mesh defines the mesh to control
  36162. * @param bone defines the bone to control
  36163. * @param options defines options to set up the controller
  36164. */
  36165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36166. targetMesh?: AbstractMesh;
  36167. poleTargetMesh?: AbstractMesh;
  36168. poleTargetBone?: Bone;
  36169. poleTargetLocalOffset?: Vector3;
  36170. poleAngle?: number;
  36171. bendAxis?: Vector3;
  36172. maxAngle?: number;
  36173. slerpAmount?: number;
  36174. });
  36175. private _setMaxAngle;
  36176. /**
  36177. * Force the controller to update the bones
  36178. */
  36179. update(): void;
  36180. }
  36181. }
  36182. declare module "babylonjs/Bones/boneLookController" {
  36183. import { Vector3, Space } from "babylonjs/Maths/math";
  36184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36185. import { Bone } from "babylonjs/Bones/bone";
  36186. /**
  36187. * Class used to make a bone look toward a point in space
  36188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36189. */
  36190. export class BoneLookController {
  36191. private static _tmpVecs;
  36192. private static _tmpQuat;
  36193. private static _tmpMats;
  36194. /**
  36195. * The target Vector3 that the bone will look at
  36196. */
  36197. target: Vector3;
  36198. /**
  36199. * The mesh that the bone is attached to
  36200. */
  36201. mesh: AbstractMesh;
  36202. /**
  36203. * The bone that will be looking to the target
  36204. */
  36205. bone: Bone;
  36206. /**
  36207. * The up axis of the coordinate system that is used when the bone is rotated
  36208. */
  36209. upAxis: Vector3;
  36210. /**
  36211. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36212. */
  36213. upAxisSpace: Space;
  36214. /**
  36215. * Used to make an adjustment to the yaw of the bone
  36216. */
  36217. adjustYaw: number;
  36218. /**
  36219. * Used to make an adjustment to the pitch of the bone
  36220. */
  36221. adjustPitch: number;
  36222. /**
  36223. * Used to make an adjustment to the roll of the bone
  36224. */
  36225. adjustRoll: number;
  36226. /**
  36227. * 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)
  36228. */
  36229. slerpAmount: number;
  36230. private _minYaw;
  36231. private _maxYaw;
  36232. private _minPitch;
  36233. private _maxPitch;
  36234. private _minYawSin;
  36235. private _minYawCos;
  36236. private _maxYawSin;
  36237. private _maxYawCos;
  36238. private _midYawConstraint;
  36239. private _minPitchTan;
  36240. private _maxPitchTan;
  36241. private _boneQuat;
  36242. private _slerping;
  36243. private _transformYawPitch;
  36244. private _transformYawPitchInv;
  36245. private _firstFrameSkipped;
  36246. private _yawRange;
  36247. private _fowardAxis;
  36248. /**
  36249. * Gets or sets the minimum yaw angle that the bone can look to
  36250. */
  36251. minYaw: number;
  36252. /**
  36253. * Gets or sets the maximum yaw angle that the bone can look to
  36254. */
  36255. maxYaw: number;
  36256. /**
  36257. * Gets or sets the minimum pitch angle that the bone can look to
  36258. */
  36259. minPitch: number;
  36260. /**
  36261. * Gets or sets the maximum pitch angle that the bone can look to
  36262. */
  36263. maxPitch: number;
  36264. /**
  36265. * Create a BoneLookController
  36266. * @param mesh the mesh that the bone belongs to
  36267. * @param bone the bone that will be looking to the target
  36268. * @param target the target Vector3 to look at
  36269. * @param options optional settings:
  36270. * * maxYaw: the maximum angle the bone will yaw to
  36271. * * minYaw: the minimum angle the bone will yaw to
  36272. * * maxPitch: the maximum angle the bone will pitch to
  36273. * * minPitch: the minimum angle the bone will yaw to
  36274. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36275. * * upAxis: the up axis of the coordinate system
  36276. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36277. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36278. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36279. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36280. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36281. * * adjustRoll: used to make an adjustment to the roll of the bone
  36282. **/
  36283. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36284. maxYaw?: number;
  36285. minYaw?: number;
  36286. maxPitch?: number;
  36287. minPitch?: number;
  36288. slerpAmount?: number;
  36289. upAxis?: Vector3;
  36290. upAxisSpace?: Space;
  36291. yawAxis?: Vector3;
  36292. pitchAxis?: Vector3;
  36293. adjustYaw?: number;
  36294. adjustPitch?: number;
  36295. adjustRoll?: number;
  36296. });
  36297. /**
  36298. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36299. */
  36300. update(): void;
  36301. private _getAngleDiff;
  36302. private _getAngleBetween;
  36303. private _isAngleBetween;
  36304. }
  36305. }
  36306. declare module "babylonjs/Bones/index" {
  36307. export * from "babylonjs/Bones/bone";
  36308. export * from "babylonjs/Bones/boneIKController";
  36309. export * from "babylonjs/Bones/boneLookController";
  36310. export * from "babylonjs/Bones/skeleton";
  36311. }
  36312. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36313. import { Nullable } from "babylonjs/types";
  36314. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36315. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36316. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36317. /**
  36318. * Manage the gamepad inputs to control an arc rotate camera.
  36319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36320. */
  36321. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36322. /**
  36323. * Defines the camera the input is attached to.
  36324. */
  36325. camera: ArcRotateCamera;
  36326. /**
  36327. * Defines the gamepad the input is gathering event from.
  36328. */
  36329. gamepad: Nullable<Gamepad>;
  36330. /**
  36331. * Defines the gamepad rotation sensiblity.
  36332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36333. */
  36334. gamepadRotationSensibility: number;
  36335. /**
  36336. * Defines the gamepad move sensiblity.
  36337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36338. */
  36339. gamepadMoveSensibility: number;
  36340. private _onGamepadConnectedObserver;
  36341. private _onGamepadDisconnectedObserver;
  36342. /**
  36343. * Attach the input controls to a specific dom element to get the input from.
  36344. * @param element Defines the element the controls should be listened from
  36345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36346. */
  36347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36348. /**
  36349. * Detach the current controls from the specified dom element.
  36350. * @param element Defines the element to stop listening the inputs from
  36351. */
  36352. detachControl(element: Nullable<HTMLElement>): void;
  36353. /**
  36354. * Update the current camera state depending on the inputs that have been used this frame.
  36355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36356. */
  36357. checkInputs(): void;
  36358. /**
  36359. * Gets the class name of the current intput.
  36360. * @returns the class name
  36361. */
  36362. getClassName(): string;
  36363. /**
  36364. * Get the friendly name associated with the input class.
  36365. * @returns the input friendly name
  36366. */
  36367. getSimpleName(): string;
  36368. }
  36369. }
  36370. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36371. import { Nullable } from "babylonjs/types";
  36372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36374. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36375. interface ArcRotateCameraInputsManager {
  36376. /**
  36377. * Add orientation input support to the input manager.
  36378. * @returns the current input manager
  36379. */
  36380. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36381. }
  36382. }
  36383. /**
  36384. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36386. */
  36387. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36388. /**
  36389. * Defines the camera the input is attached to.
  36390. */
  36391. camera: ArcRotateCamera;
  36392. /**
  36393. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36394. */
  36395. alphaCorrection: number;
  36396. /**
  36397. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36398. */
  36399. gammaCorrection: number;
  36400. private _alpha;
  36401. private _gamma;
  36402. private _dirty;
  36403. private _deviceOrientationHandler;
  36404. /**
  36405. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36406. */
  36407. constructor();
  36408. /**
  36409. * Attach the input controls to a specific dom element to get the input from.
  36410. * @param element Defines the element the controls should be listened from
  36411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36412. */
  36413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36414. /** @hidden */
  36415. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36416. /**
  36417. * Update the current camera state depending on the inputs that have been used this frame.
  36418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36419. */
  36420. checkInputs(): void;
  36421. /**
  36422. * Detach the current controls from the specified dom element.
  36423. * @param element Defines the element to stop listening the inputs from
  36424. */
  36425. detachControl(element: Nullable<HTMLElement>): void;
  36426. /**
  36427. * Gets the class name of the current intput.
  36428. * @returns the class name
  36429. */
  36430. getClassName(): string;
  36431. /**
  36432. * Get the friendly name associated with the input class.
  36433. * @returns the input friendly name
  36434. */
  36435. getSimpleName(): string;
  36436. }
  36437. }
  36438. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36439. import { Nullable } from "babylonjs/types";
  36440. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36441. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36442. /**
  36443. * Listen to mouse events to control the camera.
  36444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36445. */
  36446. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36447. /**
  36448. * Defines the camera the input is attached to.
  36449. */
  36450. camera: FlyCamera;
  36451. /**
  36452. * Defines if touch is enabled. (Default is true.)
  36453. */
  36454. touchEnabled: boolean;
  36455. /**
  36456. * Defines the buttons associated with the input to handle camera rotation.
  36457. */
  36458. buttons: number[];
  36459. /**
  36460. * Assign buttons for Yaw control.
  36461. */
  36462. buttonsYaw: number[];
  36463. /**
  36464. * Assign buttons for Pitch control.
  36465. */
  36466. buttonsPitch: number[];
  36467. /**
  36468. * Assign buttons for Roll control.
  36469. */
  36470. buttonsRoll: number[];
  36471. /**
  36472. * Detect if any button is being pressed while mouse is moved.
  36473. * -1 = Mouse locked.
  36474. * 0 = Left button.
  36475. * 1 = Middle Button.
  36476. * 2 = Right Button.
  36477. */
  36478. activeButton: number;
  36479. /**
  36480. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36481. * Higher values reduce its sensitivity.
  36482. */
  36483. angularSensibility: number;
  36484. private _mousemoveCallback;
  36485. private _observer;
  36486. private _rollObserver;
  36487. private previousPosition;
  36488. private noPreventDefault;
  36489. private element;
  36490. /**
  36491. * Listen to mouse events to control the camera.
  36492. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36494. */
  36495. constructor(touchEnabled?: boolean);
  36496. /**
  36497. * Attach the mouse control to the HTML DOM element.
  36498. * @param element Defines the element that listens to the input events.
  36499. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36500. */
  36501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36502. /**
  36503. * Detach the current controls from the specified dom element.
  36504. * @param element Defines the element to stop listening the inputs from
  36505. */
  36506. detachControl(element: Nullable<HTMLElement>): void;
  36507. /**
  36508. * Gets the class name of the current input.
  36509. * @returns the class name.
  36510. */
  36511. getClassName(): string;
  36512. /**
  36513. * Get the friendly name associated with the input class.
  36514. * @returns the input's friendly name.
  36515. */
  36516. getSimpleName(): string;
  36517. private _pointerInput;
  36518. private _onMouseMove;
  36519. /**
  36520. * Rotate camera by mouse offset.
  36521. */
  36522. private rotateCamera;
  36523. }
  36524. }
  36525. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36526. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36527. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36528. /**
  36529. * Default Inputs manager for the FlyCamera.
  36530. * It groups all the default supported inputs for ease of use.
  36531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36532. */
  36533. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36534. /**
  36535. * Instantiates a new FlyCameraInputsManager.
  36536. * @param camera Defines the camera the inputs belong to.
  36537. */
  36538. constructor(camera: FlyCamera);
  36539. /**
  36540. * Add keyboard input support to the input manager.
  36541. * @returns the new FlyCameraKeyboardMoveInput().
  36542. */
  36543. addKeyboard(): FlyCameraInputsManager;
  36544. /**
  36545. * Add mouse input support to the input manager.
  36546. * @param touchEnabled Enable touch screen support.
  36547. * @returns the new FlyCameraMouseInput().
  36548. */
  36549. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36550. }
  36551. }
  36552. declare module "babylonjs/Cameras/flyCamera" {
  36553. import { Scene } from "babylonjs/scene";
  36554. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36556. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36557. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36558. /**
  36559. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36560. * such as in a 3D Space Shooter or a Flight Simulator.
  36561. */
  36562. export class FlyCamera extends TargetCamera {
  36563. /**
  36564. * Define the collision ellipsoid of the camera.
  36565. * This is helpful for simulating a camera body, like a player's body.
  36566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36567. */
  36568. ellipsoid: Vector3;
  36569. /**
  36570. * Define an offset for the position of the ellipsoid around the camera.
  36571. * This can be helpful if the camera is attached away from the player's body center,
  36572. * such as at its head.
  36573. */
  36574. ellipsoidOffset: Vector3;
  36575. /**
  36576. * Enable or disable collisions of the camera with the rest of the scene objects.
  36577. */
  36578. checkCollisions: boolean;
  36579. /**
  36580. * Enable or disable gravity on the camera.
  36581. */
  36582. applyGravity: boolean;
  36583. /**
  36584. * Define the current direction the camera is moving to.
  36585. */
  36586. cameraDirection: Vector3;
  36587. /**
  36588. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36589. * This overrides and empties cameraRotation.
  36590. */
  36591. rotationQuaternion: Quaternion;
  36592. /**
  36593. * Track Roll to maintain the wanted Rolling when looking around.
  36594. */
  36595. _trackRoll: number;
  36596. /**
  36597. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36598. */
  36599. rollCorrect: number;
  36600. /**
  36601. * Mimic a banked turn, Rolling the camera when Yawing.
  36602. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36603. */
  36604. bankedTurn: boolean;
  36605. /**
  36606. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36607. */
  36608. bankedTurnLimit: number;
  36609. /**
  36610. * Value of 0 disables the banked Roll.
  36611. * Value of 1 is equal to the Yaw angle in radians.
  36612. */
  36613. bankedTurnMultiplier: number;
  36614. /**
  36615. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36616. */
  36617. inputs: FlyCameraInputsManager;
  36618. /**
  36619. * Gets the input sensibility for mouse input.
  36620. * Higher values reduce sensitivity.
  36621. */
  36622. /**
  36623. * Sets the input sensibility for a mouse input.
  36624. * Higher values reduce sensitivity.
  36625. */
  36626. angularSensibility: number;
  36627. /**
  36628. * Get the keys for camera movement forward.
  36629. */
  36630. /**
  36631. * Set the keys for camera movement forward.
  36632. */
  36633. keysForward: number[];
  36634. /**
  36635. * Get the keys for camera movement backward.
  36636. */
  36637. keysBackward: number[];
  36638. /**
  36639. * Get the keys for camera movement up.
  36640. */
  36641. /**
  36642. * Set the keys for camera movement up.
  36643. */
  36644. keysUp: number[];
  36645. /**
  36646. * Get the keys for camera movement down.
  36647. */
  36648. /**
  36649. * Set the keys for camera movement down.
  36650. */
  36651. keysDown: number[];
  36652. /**
  36653. * Get the keys for camera movement left.
  36654. */
  36655. /**
  36656. * Set the keys for camera movement left.
  36657. */
  36658. keysLeft: number[];
  36659. /**
  36660. * Set the keys for camera movement right.
  36661. */
  36662. /**
  36663. * Set the keys for camera movement right.
  36664. */
  36665. keysRight: number[];
  36666. /**
  36667. * Event raised when the camera collides with a mesh in the scene.
  36668. */
  36669. onCollide: (collidedMesh: AbstractMesh) => void;
  36670. private _collider;
  36671. private _needMoveForGravity;
  36672. private _oldPosition;
  36673. private _diffPosition;
  36674. private _newPosition;
  36675. /** @hidden */
  36676. _localDirection: Vector3;
  36677. /** @hidden */
  36678. _transformedDirection: Vector3;
  36679. /**
  36680. * Instantiates a FlyCamera.
  36681. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36682. * such as in a 3D Space Shooter or a Flight Simulator.
  36683. * @param name Define the name of the camera in the scene.
  36684. * @param position Define the starting position of the camera in the scene.
  36685. * @param scene Define the scene the camera belongs to.
  36686. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36687. */
  36688. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36689. /**
  36690. * Attach a control to the HTML DOM element.
  36691. * @param element Defines the element that listens to the input events.
  36692. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36693. */
  36694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36695. /**
  36696. * Detach a control from the HTML DOM element.
  36697. * The camera will stop reacting to that input.
  36698. * @param element Defines the element that listens to the input events.
  36699. */
  36700. detachControl(element: HTMLElement): void;
  36701. private _collisionMask;
  36702. /**
  36703. * Get the mask that the camera ignores in collision events.
  36704. */
  36705. /**
  36706. * Set the mask that the camera ignores in collision events.
  36707. */
  36708. collisionMask: number;
  36709. /** @hidden */
  36710. _collideWithWorld(displacement: Vector3): void;
  36711. /** @hidden */
  36712. private _onCollisionPositionChange;
  36713. /** @hidden */
  36714. _checkInputs(): void;
  36715. /** @hidden */
  36716. _decideIfNeedsToMove(): boolean;
  36717. /** @hidden */
  36718. _updatePosition(): void;
  36719. /**
  36720. * Restore the Roll to its target value at the rate specified.
  36721. * @param rate - Higher means slower restoring.
  36722. * @hidden
  36723. */
  36724. restoreRoll(rate: number): void;
  36725. /**
  36726. * Destroy the camera and release the current resources held by it.
  36727. */
  36728. dispose(): void;
  36729. /**
  36730. * Get the current object class name.
  36731. * @returns the class name.
  36732. */
  36733. getClassName(): string;
  36734. }
  36735. }
  36736. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36737. import { Nullable } from "babylonjs/types";
  36738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36739. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36740. /**
  36741. * Listen to keyboard events to control the camera.
  36742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36743. */
  36744. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36745. /**
  36746. * Defines the camera the input is attached to.
  36747. */
  36748. camera: FlyCamera;
  36749. /**
  36750. * The list of keyboard keys used to control the forward move of the camera.
  36751. */
  36752. keysForward: number[];
  36753. /**
  36754. * The list of keyboard keys used to control the backward move of the camera.
  36755. */
  36756. keysBackward: number[];
  36757. /**
  36758. * The list of keyboard keys used to control the forward move of the camera.
  36759. */
  36760. keysUp: number[];
  36761. /**
  36762. * The list of keyboard keys used to control the backward move of the camera.
  36763. */
  36764. keysDown: number[];
  36765. /**
  36766. * The list of keyboard keys used to control the right strafe move of the camera.
  36767. */
  36768. keysRight: number[];
  36769. /**
  36770. * The list of keyboard keys used to control the left strafe move of the camera.
  36771. */
  36772. keysLeft: number[];
  36773. private _keys;
  36774. private _onCanvasBlurObserver;
  36775. private _onKeyboardObserver;
  36776. private _engine;
  36777. private _scene;
  36778. /**
  36779. * Attach the input controls to a specific dom element to get the input from.
  36780. * @param element Defines the element the controls should be listened from
  36781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36782. */
  36783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36784. /**
  36785. * Detach the current controls from the specified dom element.
  36786. * @param element Defines the element to stop listening the inputs from
  36787. */
  36788. detachControl(element: Nullable<HTMLElement>): void;
  36789. /**
  36790. * Gets the class name of the current intput.
  36791. * @returns the class name
  36792. */
  36793. getClassName(): string;
  36794. /** @hidden */
  36795. _onLostFocus(e: FocusEvent): void;
  36796. /**
  36797. * Get the friendly name associated with the input class.
  36798. * @returns the input friendly name
  36799. */
  36800. getSimpleName(): string;
  36801. /**
  36802. * Update the current camera state depending on the inputs that have been used this frame.
  36803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36804. */
  36805. checkInputs(): void;
  36806. }
  36807. }
  36808. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36809. import { Nullable } from "babylonjs/types";
  36810. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36811. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36812. /**
  36813. * Manage the mouse wheel inputs to control a follow camera.
  36814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36815. */
  36816. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36817. /**
  36818. * Defines the camera the input is attached to.
  36819. */
  36820. camera: FollowCamera;
  36821. /**
  36822. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36823. */
  36824. axisControlRadius: boolean;
  36825. /**
  36826. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36827. */
  36828. axisControlHeight: boolean;
  36829. /**
  36830. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36831. */
  36832. axisControlRotation: boolean;
  36833. /**
  36834. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36835. * relation to mouseWheel events.
  36836. */
  36837. wheelPrecision: number;
  36838. /**
  36839. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36840. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36841. */
  36842. wheelDeltaPercentage: number;
  36843. private _wheel;
  36844. private _observer;
  36845. /**
  36846. * Attach the input controls to a specific dom element to get the input from.
  36847. * @param element Defines the element the controls should be listened from
  36848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36849. */
  36850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36851. /**
  36852. * Detach the current controls from the specified dom element.
  36853. * @param element Defines the element to stop listening the inputs from
  36854. */
  36855. detachControl(element: Nullable<HTMLElement>): void;
  36856. /**
  36857. * Gets the class name of the current intput.
  36858. * @returns the class name
  36859. */
  36860. getClassName(): string;
  36861. /**
  36862. * Get the friendly name associated with the input class.
  36863. * @returns the input friendly name
  36864. */
  36865. getSimpleName(): string;
  36866. }
  36867. }
  36868. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36869. import { Nullable } from "babylonjs/types";
  36870. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36871. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36872. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36873. /**
  36874. * Manage the pointers inputs to control an follow camera.
  36875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36876. */
  36877. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36878. /**
  36879. * Defines the camera the input is attached to.
  36880. */
  36881. camera: FollowCamera;
  36882. /**
  36883. * Gets the class name of the current input.
  36884. * @returns the class name
  36885. */
  36886. getClassName(): string;
  36887. /**
  36888. * Defines the pointer angular sensibility along the X axis or how fast is
  36889. * the camera rotating.
  36890. * A negative number will reverse the axis direction.
  36891. */
  36892. angularSensibilityX: number;
  36893. /**
  36894. * Defines the pointer angular sensibility along the Y axis or how fast is
  36895. * the camera rotating.
  36896. * A negative number will reverse the axis direction.
  36897. */
  36898. angularSensibilityY: number;
  36899. /**
  36900. * Defines the pointer pinch precision or how fast is the camera zooming.
  36901. * A negative number will reverse the axis direction.
  36902. */
  36903. pinchPrecision: number;
  36904. /**
  36905. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36906. * from 0.
  36907. * It defines the percentage of current camera.radius to use as delta when
  36908. * pinch zoom is used.
  36909. */
  36910. pinchDeltaPercentage: number;
  36911. /**
  36912. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36913. */
  36914. axisXControlRadius: boolean;
  36915. /**
  36916. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36917. */
  36918. axisXControlHeight: boolean;
  36919. /**
  36920. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36921. */
  36922. axisXControlRotation: boolean;
  36923. /**
  36924. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36925. */
  36926. axisYControlRadius: boolean;
  36927. /**
  36928. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36929. */
  36930. axisYControlHeight: boolean;
  36931. /**
  36932. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36933. */
  36934. axisYControlRotation: boolean;
  36935. /**
  36936. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36937. */
  36938. axisPinchControlRadius: boolean;
  36939. /**
  36940. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36941. */
  36942. axisPinchControlHeight: boolean;
  36943. /**
  36944. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36945. */
  36946. axisPinchControlRotation: boolean;
  36947. /**
  36948. * Log error messages if basic misconfiguration has occurred.
  36949. */
  36950. warningEnable: boolean;
  36951. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36952. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36953. private _warningCounter;
  36954. private _warning;
  36955. }
  36956. }
  36957. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36958. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36959. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36960. /**
  36961. * Default Inputs manager for the FollowCamera.
  36962. * It groups all the default supported inputs for ease of use.
  36963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36964. */
  36965. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36966. /**
  36967. * Instantiates a new FollowCameraInputsManager.
  36968. * @param camera Defines the camera the inputs belong to
  36969. */
  36970. constructor(camera: FollowCamera);
  36971. /**
  36972. * Add keyboard input support to the input manager.
  36973. * @returns the current input manager
  36974. */
  36975. addKeyboard(): FollowCameraInputsManager;
  36976. /**
  36977. * Add mouse wheel input support to the input manager.
  36978. * @returns the current input manager
  36979. */
  36980. addMouseWheel(): FollowCameraInputsManager;
  36981. /**
  36982. * Add pointers input support to the input manager.
  36983. * @returns the current input manager
  36984. */
  36985. addPointers(): FollowCameraInputsManager;
  36986. /**
  36987. * Add orientation input support to the input manager.
  36988. * @returns the current input manager
  36989. */
  36990. addVRDeviceOrientation(): FollowCameraInputsManager;
  36991. }
  36992. }
  36993. declare module "babylonjs/Cameras/followCamera" {
  36994. import { Nullable } from "babylonjs/types";
  36995. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36996. import { Scene } from "babylonjs/scene";
  36997. import { Vector3 } from "babylonjs/Maths/math";
  36998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36999. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37000. /**
  37001. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37002. * an arc rotate version arcFollowCamera are available.
  37003. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37004. */
  37005. export class FollowCamera extends TargetCamera {
  37006. /**
  37007. * Distance the follow camera should follow an object at
  37008. */
  37009. radius: number;
  37010. /**
  37011. * Minimum allowed distance of the camera to the axis of rotation
  37012. * (The camera can not get closer).
  37013. * This can help limiting how the Camera is able to move in the scene.
  37014. */
  37015. lowerRadiusLimit: Nullable<number>;
  37016. /**
  37017. * Maximum allowed distance of the camera to the axis of rotation
  37018. * (The camera can not get further).
  37019. * This can help limiting how the Camera is able to move in the scene.
  37020. */
  37021. upperRadiusLimit: Nullable<number>;
  37022. /**
  37023. * Define a rotation offset between the camera and the object it follows
  37024. */
  37025. rotationOffset: number;
  37026. /**
  37027. * Minimum allowed angle to camera position relative to target object.
  37028. * This can help limiting how the Camera is able to move in the scene.
  37029. */
  37030. lowerRotationOffsetLimit: Nullable<number>;
  37031. /**
  37032. * Maximum allowed angle to camera position relative to target object.
  37033. * This can help limiting how the Camera is able to move in the scene.
  37034. */
  37035. upperRotationOffsetLimit: Nullable<number>;
  37036. /**
  37037. * Define a height offset between the camera and the object it follows.
  37038. * It can help following an object from the top (like a car chaing a plane)
  37039. */
  37040. heightOffset: number;
  37041. /**
  37042. * Minimum allowed height of camera position relative to target object.
  37043. * This can help limiting how the Camera is able to move in the scene.
  37044. */
  37045. lowerHeightOffsetLimit: Nullable<number>;
  37046. /**
  37047. * Maximum allowed height of camera position relative to target object.
  37048. * This can help limiting how the Camera is able to move in the scene.
  37049. */
  37050. upperHeightOffsetLimit: Nullable<number>;
  37051. /**
  37052. * Define how fast the camera can accelerate to follow it s target.
  37053. */
  37054. cameraAcceleration: number;
  37055. /**
  37056. * Define the speed limit of the camera following an object.
  37057. */
  37058. maxCameraSpeed: number;
  37059. /**
  37060. * Define the target of the camera.
  37061. */
  37062. lockedTarget: Nullable<AbstractMesh>;
  37063. /**
  37064. * Defines the input associated with the camera.
  37065. */
  37066. inputs: FollowCameraInputsManager;
  37067. /**
  37068. * Instantiates the follow camera.
  37069. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37070. * @param name Define the name of the camera in the scene
  37071. * @param position Define the position of the camera
  37072. * @param scene Define the scene the camera belong to
  37073. * @param lockedTarget Define the target of the camera
  37074. */
  37075. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37076. private _follow;
  37077. /**
  37078. * Attached controls to the current camera.
  37079. * @param element Defines the element the controls should be listened from
  37080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37081. */
  37082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37083. /**
  37084. * Detach the current controls from the camera.
  37085. * The camera will stop reacting to inputs.
  37086. * @param element Defines the element to stop listening the inputs from
  37087. */
  37088. detachControl(element: HTMLElement): void;
  37089. /** @hidden */
  37090. _checkInputs(): void;
  37091. private _checkLimits;
  37092. /**
  37093. * Gets the camera class name.
  37094. * @returns the class name
  37095. */
  37096. getClassName(): string;
  37097. }
  37098. /**
  37099. * Arc Rotate version of the follow camera.
  37100. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37101. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37102. */
  37103. export class ArcFollowCamera extends TargetCamera {
  37104. /** The longitudinal angle of the camera */
  37105. alpha: number;
  37106. /** The latitudinal angle of the camera */
  37107. beta: number;
  37108. /** The radius of the camera from its target */
  37109. radius: number;
  37110. /** Define the camera target (the messh it should follow) */
  37111. target: Nullable<AbstractMesh>;
  37112. private _cartesianCoordinates;
  37113. /**
  37114. * Instantiates a new ArcFollowCamera
  37115. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37116. * @param name Define the name of the camera
  37117. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37118. * @param beta Define the rotation angle of the camera around the elevation axis
  37119. * @param radius Define the radius of the camera from its target point
  37120. * @param target Define the target of the camera
  37121. * @param scene Define the scene the camera belongs to
  37122. */
  37123. constructor(name: string,
  37124. /** The longitudinal angle of the camera */
  37125. alpha: number,
  37126. /** The latitudinal angle of the camera */
  37127. beta: number,
  37128. /** The radius of the camera from its target */
  37129. radius: number,
  37130. /** Define the camera target (the messh it should follow) */
  37131. target: Nullable<AbstractMesh>, scene: Scene);
  37132. private _follow;
  37133. /** @hidden */
  37134. _checkInputs(): void;
  37135. /**
  37136. * Returns the class name of the object.
  37137. * It is mostly used internally for serialization purposes.
  37138. */
  37139. getClassName(): string;
  37140. }
  37141. }
  37142. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37143. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37144. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37145. import { Nullable } from "babylonjs/types";
  37146. /**
  37147. * Manage the keyboard inputs to control the movement of a follow camera.
  37148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37149. */
  37150. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37151. /**
  37152. * Defines the camera the input is attached to.
  37153. */
  37154. camera: FollowCamera;
  37155. /**
  37156. * Defines the list of key codes associated with the up action (increase heightOffset)
  37157. */
  37158. keysHeightOffsetIncr: number[];
  37159. /**
  37160. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37161. */
  37162. keysHeightOffsetDecr: number[];
  37163. /**
  37164. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37165. */
  37166. keysHeightOffsetModifierAlt: boolean;
  37167. /**
  37168. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37169. */
  37170. keysHeightOffsetModifierCtrl: boolean;
  37171. /**
  37172. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37173. */
  37174. keysHeightOffsetModifierShift: boolean;
  37175. /**
  37176. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37177. */
  37178. keysRotationOffsetIncr: number[];
  37179. /**
  37180. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37181. */
  37182. keysRotationOffsetDecr: number[];
  37183. /**
  37184. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37185. */
  37186. keysRotationOffsetModifierAlt: boolean;
  37187. /**
  37188. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37189. */
  37190. keysRotationOffsetModifierCtrl: boolean;
  37191. /**
  37192. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37193. */
  37194. keysRotationOffsetModifierShift: boolean;
  37195. /**
  37196. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37197. */
  37198. keysRadiusIncr: number[];
  37199. /**
  37200. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37201. */
  37202. keysRadiusDecr: number[];
  37203. /**
  37204. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37205. */
  37206. keysRadiusModifierAlt: boolean;
  37207. /**
  37208. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37209. */
  37210. keysRadiusModifierCtrl: boolean;
  37211. /**
  37212. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37213. */
  37214. keysRadiusModifierShift: boolean;
  37215. /**
  37216. * Defines the rate of change of heightOffset.
  37217. */
  37218. heightSensibility: number;
  37219. /**
  37220. * Defines the rate of change of rotationOffset.
  37221. */
  37222. rotationSensibility: number;
  37223. /**
  37224. * Defines the rate of change of radius.
  37225. */
  37226. radiusSensibility: number;
  37227. private _keys;
  37228. private _ctrlPressed;
  37229. private _altPressed;
  37230. private _shiftPressed;
  37231. private _onCanvasBlurObserver;
  37232. private _onKeyboardObserver;
  37233. private _engine;
  37234. private _scene;
  37235. /**
  37236. * Attach the input controls to a specific dom element to get the input from.
  37237. * @param element Defines the element the controls should be listened from
  37238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37239. */
  37240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37241. /**
  37242. * Detach the current controls from the specified dom element.
  37243. * @param element Defines the element to stop listening the inputs from
  37244. */
  37245. detachControl(element: Nullable<HTMLElement>): void;
  37246. /**
  37247. * Update the current camera state depending on the inputs that have been used this frame.
  37248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37249. */
  37250. checkInputs(): void;
  37251. /**
  37252. * Gets the class name of the current input.
  37253. * @returns the class name
  37254. */
  37255. getClassName(): string;
  37256. /**
  37257. * Get the friendly name associated with the input class.
  37258. * @returns the input friendly name
  37259. */
  37260. getSimpleName(): string;
  37261. /**
  37262. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37263. * allow modification of the heightOffset value.
  37264. */
  37265. private _modifierHeightOffset;
  37266. /**
  37267. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37268. * allow modification of the rotationOffset value.
  37269. */
  37270. private _modifierRotationOffset;
  37271. /**
  37272. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37273. * allow modification of the radius value.
  37274. */
  37275. private _modifierRadius;
  37276. }
  37277. }
  37278. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37279. import { Nullable } from "babylonjs/types";
  37280. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37281. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37282. module "babylonjs/Cameras/freeCameraInputsManager" {
  37283. interface FreeCameraInputsManager {
  37284. /**
  37285. * Add orientation input support to the input manager.
  37286. * @returns the current input manager
  37287. */
  37288. addDeviceOrientation(): FreeCameraInputsManager;
  37289. }
  37290. }
  37291. /**
  37292. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37293. * Screen rotation is taken into account.
  37294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37295. */
  37296. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37297. private _camera;
  37298. private _screenOrientationAngle;
  37299. private _constantTranform;
  37300. private _screenQuaternion;
  37301. private _alpha;
  37302. private _beta;
  37303. private _gamma;
  37304. /**
  37305. * Instantiates a new input
  37306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37307. */
  37308. constructor();
  37309. /**
  37310. * Define the camera controlled by the input.
  37311. */
  37312. camera: FreeCamera;
  37313. /**
  37314. * Attach the input controls to a specific dom element to get the input from.
  37315. * @param element Defines the element the controls should be listened from
  37316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37317. */
  37318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37319. private _orientationChanged;
  37320. private _deviceOrientation;
  37321. /**
  37322. * Detach the current controls from the specified dom element.
  37323. * @param element Defines the element to stop listening the inputs from
  37324. */
  37325. detachControl(element: Nullable<HTMLElement>): void;
  37326. /**
  37327. * Update the current camera state depending on the inputs that have been used this frame.
  37328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37329. */
  37330. checkInputs(): void;
  37331. /**
  37332. * Gets the class name of the current intput.
  37333. * @returns the class name
  37334. */
  37335. getClassName(): string;
  37336. /**
  37337. * Get the friendly name associated with the input class.
  37338. * @returns the input friendly name
  37339. */
  37340. getSimpleName(): string;
  37341. }
  37342. }
  37343. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37344. import { Nullable } from "babylonjs/types";
  37345. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37346. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37347. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37348. /**
  37349. * Manage the gamepad inputs to control a free camera.
  37350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37351. */
  37352. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37353. /**
  37354. * Define the camera the input is attached to.
  37355. */
  37356. camera: FreeCamera;
  37357. /**
  37358. * Define the Gamepad controlling the input
  37359. */
  37360. gamepad: Nullable<Gamepad>;
  37361. /**
  37362. * Defines the gamepad rotation sensiblity.
  37363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37364. */
  37365. gamepadAngularSensibility: number;
  37366. /**
  37367. * Defines the gamepad move sensiblity.
  37368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37369. */
  37370. gamepadMoveSensibility: number;
  37371. private _onGamepadConnectedObserver;
  37372. private _onGamepadDisconnectedObserver;
  37373. private _cameraTransform;
  37374. private _deltaTransform;
  37375. private _vector3;
  37376. private _vector2;
  37377. /**
  37378. * Attach the input controls to a specific dom element to get the input from.
  37379. * @param element Defines the element the controls should be listened from
  37380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37381. */
  37382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37383. /**
  37384. * Detach the current controls from the specified dom element.
  37385. * @param element Defines the element to stop listening the inputs from
  37386. */
  37387. detachControl(element: Nullable<HTMLElement>): void;
  37388. /**
  37389. * Update the current camera state depending on the inputs that have been used this frame.
  37390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37391. */
  37392. checkInputs(): void;
  37393. /**
  37394. * Gets the class name of the current intput.
  37395. * @returns the class name
  37396. */
  37397. getClassName(): string;
  37398. /**
  37399. * Get the friendly name associated with the input class.
  37400. * @returns the input friendly name
  37401. */
  37402. getSimpleName(): string;
  37403. }
  37404. }
  37405. declare module "babylonjs/Misc/virtualJoystick" {
  37406. import { Nullable } from "babylonjs/types";
  37407. import { Vector3 } from "babylonjs/Maths/math";
  37408. /**
  37409. * Defines the potential axis of a Joystick
  37410. */
  37411. export enum JoystickAxis {
  37412. /** X axis */
  37413. X = 0,
  37414. /** Y axis */
  37415. Y = 1,
  37416. /** Z axis */
  37417. Z = 2
  37418. }
  37419. /**
  37420. * Class used to define virtual joystick (used in touch mode)
  37421. */
  37422. export class VirtualJoystick {
  37423. /**
  37424. * Gets or sets a boolean indicating that left and right values must be inverted
  37425. */
  37426. reverseLeftRight: boolean;
  37427. /**
  37428. * Gets or sets a boolean indicating that up and down values must be inverted
  37429. */
  37430. reverseUpDown: boolean;
  37431. /**
  37432. * Gets the offset value for the position (ie. the change of the position value)
  37433. */
  37434. deltaPosition: Vector3;
  37435. /**
  37436. * Gets a boolean indicating if the virtual joystick was pressed
  37437. */
  37438. pressed: boolean;
  37439. /**
  37440. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37441. */
  37442. static Canvas: Nullable<HTMLCanvasElement>;
  37443. private static _globalJoystickIndex;
  37444. private static vjCanvasContext;
  37445. private static vjCanvasWidth;
  37446. private static vjCanvasHeight;
  37447. private static halfWidth;
  37448. private _action;
  37449. private _axisTargetedByLeftAndRight;
  37450. private _axisTargetedByUpAndDown;
  37451. private _joystickSensibility;
  37452. private _inversedSensibility;
  37453. private _joystickPointerID;
  37454. private _joystickColor;
  37455. private _joystickPointerPos;
  37456. private _joystickPreviousPointerPos;
  37457. private _joystickPointerStartPos;
  37458. private _deltaJoystickVector;
  37459. private _leftJoystick;
  37460. private _touches;
  37461. private _onPointerDownHandlerRef;
  37462. private _onPointerMoveHandlerRef;
  37463. private _onPointerUpHandlerRef;
  37464. private _onResize;
  37465. /**
  37466. * Creates a new virtual joystick
  37467. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37468. */
  37469. constructor(leftJoystick?: boolean);
  37470. /**
  37471. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37472. * @param newJoystickSensibility defines the new sensibility
  37473. */
  37474. setJoystickSensibility(newJoystickSensibility: number): void;
  37475. private _onPointerDown;
  37476. private _onPointerMove;
  37477. private _onPointerUp;
  37478. /**
  37479. * Change the color of the virtual joystick
  37480. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37481. */
  37482. setJoystickColor(newColor: string): void;
  37483. /**
  37484. * Defines a callback to call when the joystick is touched
  37485. * @param action defines the callback
  37486. */
  37487. setActionOnTouch(action: () => any): void;
  37488. /**
  37489. * Defines which axis you'd like to control for left & right
  37490. * @param axis defines the axis to use
  37491. */
  37492. setAxisForLeftRight(axis: JoystickAxis): void;
  37493. /**
  37494. * Defines which axis you'd like to control for up & down
  37495. * @param axis defines the axis to use
  37496. */
  37497. setAxisForUpDown(axis: JoystickAxis): void;
  37498. private _drawVirtualJoystick;
  37499. /**
  37500. * Release internal HTML canvas
  37501. */
  37502. releaseCanvas(): void;
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37506. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37507. import { Nullable } from "babylonjs/types";
  37508. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37510. module "babylonjs/Cameras/freeCameraInputsManager" {
  37511. interface FreeCameraInputsManager {
  37512. /**
  37513. * Add virtual joystick input support to the input manager.
  37514. * @returns the current input manager
  37515. */
  37516. addVirtualJoystick(): FreeCameraInputsManager;
  37517. }
  37518. }
  37519. /**
  37520. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37522. */
  37523. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37524. /**
  37525. * Defines the camera the input is attached to.
  37526. */
  37527. camera: FreeCamera;
  37528. private _leftjoystick;
  37529. private _rightjoystick;
  37530. /**
  37531. * Gets the left stick of the virtual joystick.
  37532. * @returns The virtual Joystick
  37533. */
  37534. getLeftJoystick(): VirtualJoystick;
  37535. /**
  37536. * Gets the right stick of the virtual joystick.
  37537. * @returns The virtual Joystick
  37538. */
  37539. getRightJoystick(): VirtualJoystick;
  37540. /**
  37541. * Update the current camera state depending on the inputs that have been used this frame.
  37542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37543. */
  37544. checkInputs(): void;
  37545. /**
  37546. * Attach the input controls to a specific dom element to get the input from.
  37547. * @param element Defines the element the controls should be listened from
  37548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37551. /**
  37552. * Detach the current controls from the specified dom element.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: Nullable<HTMLElement>): void;
  37556. /**
  37557. * Gets the class name of the current intput.
  37558. * @returns the class name
  37559. */
  37560. getClassName(): string;
  37561. /**
  37562. * Get the friendly name associated with the input class.
  37563. * @returns the input friendly name
  37564. */
  37565. getSimpleName(): string;
  37566. }
  37567. }
  37568. declare module "babylonjs/Cameras/Inputs/index" {
  37569. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37570. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37571. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37572. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37573. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37574. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37575. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37576. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37577. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37578. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37579. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37580. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37581. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37582. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37583. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37584. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37585. }
  37586. declare module "babylonjs/Cameras/touchCamera" {
  37587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37588. import { Scene } from "babylonjs/scene";
  37589. import { Vector3 } from "babylonjs/Maths/math";
  37590. /**
  37591. * This represents a FPS type of camera controlled by touch.
  37592. * This is like a universal camera minus the Gamepad controls.
  37593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37594. */
  37595. export class TouchCamera extends FreeCamera {
  37596. /**
  37597. * Defines the touch sensibility for rotation.
  37598. * The higher the faster.
  37599. */
  37600. touchAngularSensibility: number;
  37601. /**
  37602. * Defines the touch sensibility for move.
  37603. * The higher the faster.
  37604. */
  37605. touchMoveSensibility: number;
  37606. /**
  37607. * Instantiates a new touch camera.
  37608. * This represents a FPS type of camera controlled by touch.
  37609. * This is like a universal camera minus the Gamepad controls.
  37610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37611. * @param name Define the name of the camera in the scene
  37612. * @param position Define the start position of the camera in the scene
  37613. * @param scene Define the scene the camera belongs to
  37614. */
  37615. constructor(name: string, position: Vector3, scene: Scene);
  37616. /**
  37617. * Gets the current object class name.
  37618. * @return the class name
  37619. */
  37620. getClassName(): string;
  37621. /** @hidden */
  37622. _setupInputs(): void;
  37623. }
  37624. }
  37625. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37626. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37627. import { Scene } from "babylonjs/scene";
  37628. import { Vector3, Axis } from "babylonjs/Maths/math";
  37629. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37630. /**
  37631. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37632. * being tilted forward or back and left or right.
  37633. */
  37634. export class DeviceOrientationCamera extends FreeCamera {
  37635. private _initialQuaternion;
  37636. private _quaternionCache;
  37637. /**
  37638. * Creates a new device orientation camera
  37639. * @param name The name of the camera
  37640. * @param position The start position camera
  37641. * @param scene The scene the camera belongs to
  37642. */
  37643. constructor(name: string, position: Vector3, scene: Scene);
  37644. /**
  37645. * Gets the current instance class name ("DeviceOrientationCamera").
  37646. * This helps avoiding instanceof at run time.
  37647. * @returns the class name
  37648. */
  37649. getClassName(): string;
  37650. /**
  37651. * @hidden
  37652. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37653. */
  37654. _checkInputs(): void;
  37655. /**
  37656. * Reset the camera to its default orientation on the specified axis only.
  37657. * @param axis The axis to reset
  37658. */
  37659. resetToCurrentRotation(axis?: Axis): void;
  37660. }
  37661. }
  37662. declare module "babylonjs/Cameras/universalCamera" {
  37663. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37664. import { Scene } from "babylonjs/scene";
  37665. import { Vector3 } from "babylonjs/Maths/math";
  37666. /**
  37667. * 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,
  37668. * which still works and will still be found in many Playgrounds.
  37669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37670. */
  37671. export class UniversalCamera extends TouchCamera {
  37672. /**
  37673. * Defines the gamepad rotation sensiblity.
  37674. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37675. */
  37676. gamepadAngularSensibility: number;
  37677. /**
  37678. * Defines the gamepad move sensiblity.
  37679. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37680. */
  37681. gamepadMoveSensibility: number;
  37682. /**
  37683. * 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,
  37684. * which still works and will still be found in many Playgrounds.
  37685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37686. * @param name Define the name of the camera in the scene
  37687. * @param position Define the start position of the camera in the scene
  37688. * @param scene Define the scene the camera belongs to
  37689. */
  37690. constructor(name: string, position: Vector3, scene: Scene);
  37691. /**
  37692. * Gets the current object class name.
  37693. * @return the class name
  37694. */
  37695. getClassName(): string;
  37696. }
  37697. }
  37698. declare module "babylonjs/Cameras/gamepadCamera" {
  37699. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37700. import { Scene } from "babylonjs/scene";
  37701. import { Vector3 } from "babylonjs/Maths/math";
  37702. /**
  37703. * This represents a FPS type of camera. This is only here for back compat purpose.
  37704. * Please use the UniversalCamera instead as both are identical.
  37705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37706. */
  37707. export class GamepadCamera extends UniversalCamera {
  37708. /**
  37709. * Instantiates a new Gamepad Camera
  37710. * This represents a FPS type of camera. This is only here for back compat purpose.
  37711. * Please use the UniversalCamera instead as both are identical.
  37712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37713. * @param name Define the name of the camera in the scene
  37714. * @param position Define the start position of the camera in the scene
  37715. * @param scene Define the scene the camera belongs to
  37716. */
  37717. constructor(name: string, position: Vector3, scene: Scene);
  37718. /**
  37719. * Gets the current object class name.
  37720. * @return the class name
  37721. */
  37722. getClassName(): string;
  37723. }
  37724. }
  37725. declare module "babylonjs/Shaders/pass.fragment" {
  37726. /** @hidden */
  37727. export var passPixelShader: {
  37728. name: string;
  37729. shader: string;
  37730. };
  37731. }
  37732. declare module "babylonjs/Shaders/passCube.fragment" {
  37733. /** @hidden */
  37734. export var passCubePixelShader: {
  37735. name: string;
  37736. shader: string;
  37737. };
  37738. }
  37739. declare module "babylonjs/PostProcesses/passPostProcess" {
  37740. import { Nullable } from "babylonjs/types";
  37741. import { Camera } from "babylonjs/Cameras/camera";
  37742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37743. import { Engine } from "babylonjs/Engines/engine";
  37744. import "babylonjs/Shaders/pass.fragment";
  37745. import "babylonjs/Shaders/passCube.fragment";
  37746. /**
  37747. * PassPostProcess which produces an output the same as it's input
  37748. */
  37749. export class PassPostProcess extends PostProcess {
  37750. /**
  37751. * Creates the PassPostProcess
  37752. * @param name The name of the effect.
  37753. * @param options The required width/height ratio to downsize to before computing the render pass.
  37754. * @param camera The camera to apply the render pass to.
  37755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37756. * @param engine The engine which the post process will be applied. (default: current engine)
  37757. * @param reusable If the post process can be reused on the same frame. (default: false)
  37758. * @param textureType The type of texture to be used when performing the post processing.
  37759. * @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)
  37760. */
  37761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37762. }
  37763. /**
  37764. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37765. */
  37766. export class PassCubePostProcess extends PostProcess {
  37767. private _face;
  37768. /**
  37769. * Gets or sets the cube face to display.
  37770. * * 0 is +X
  37771. * * 1 is -X
  37772. * * 2 is +Y
  37773. * * 3 is -Y
  37774. * * 4 is +Z
  37775. * * 5 is -Z
  37776. */
  37777. face: number;
  37778. /**
  37779. * Creates the PassCubePostProcess
  37780. * @param name The name of the effect.
  37781. * @param options The required width/height ratio to downsize to before computing the render pass.
  37782. * @param camera The camera to apply the render pass to.
  37783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37784. * @param engine The engine which the post process will be applied. (default: current engine)
  37785. * @param reusable If the post process can be reused on the same frame. (default: false)
  37786. * @param textureType The type of texture to be used when performing the post processing.
  37787. * @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)
  37788. */
  37789. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37790. }
  37791. }
  37792. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37793. /** @hidden */
  37794. export var anaglyphPixelShader: {
  37795. name: string;
  37796. shader: string;
  37797. };
  37798. }
  37799. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37800. import { Engine } from "babylonjs/Engines/engine";
  37801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37802. import { Camera } from "babylonjs/Cameras/camera";
  37803. import "babylonjs/Shaders/anaglyph.fragment";
  37804. /**
  37805. * Postprocess used to generate anaglyphic rendering
  37806. */
  37807. export class AnaglyphPostProcess extends PostProcess {
  37808. private _passedProcess;
  37809. /**
  37810. * Creates a new AnaglyphPostProcess
  37811. * @param name defines postprocess name
  37812. * @param options defines creation options or target ratio scale
  37813. * @param rigCameras defines cameras using this postprocess
  37814. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37815. * @param engine defines hosting engine
  37816. * @param reusable defines if the postprocess will be reused multiple times per frame
  37817. */
  37818. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37819. }
  37820. }
  37821. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37822. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37824. import { Scene } from "babylonjs/scene";
  37825. import { Vector3 } from "babylonjs/Maths/math";
  37826. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37827. /**
  37828. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37830. */
  37831. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37832. /**
  37833. * Creates a new AnaglyphArcRotateCamera
  37834. * @param name defines camera name
  37835. * @param alpha defines alpha angle (in radians)
  37836. * @param beta defines beta angle (in radians)
  37837. * @param radius defines radius
  37838. * @param target defines camera target
  37839. * @param interaxialDistance defines distance between each color axis
  37840. * @param scene defines the hosting scene
  37841. */
  37842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37843. /**
  37844. * Gets camera class name
  37845. * @returns AnaglyphArcRotateCamera
  37846. */
  37847. getClassName(): string;
  37848. }
  37849. }
  37850. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37851. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37852. import { Scene } from "babylonjs/scene";
  37853. import { Vector3 } from "babylonjs/Maths/math";
  37854. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37855. /**
  37856. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37857. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37858. */
  37859. export class AnaglyphFreeCamera extends FreeCamera {
  37860. /**
  37861. * Creates a new AnaglyphFreeCamera
  37862. * @param name defines camera name
  37863. * @param position defines initial position
  37864. * @param interaxialDistance defines distance between each color axis
  37865. * @param scene defines the hosting scene
  37866. */
  37867. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37868. /**
  37869. * Gets camera class name
  37870. * @returns AnaglyphFreeCamera
  37871. */
  37872. getClassName(): string;
  37873. }
  37874. }
  37875. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37876. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37877. import { Scene } from "babylonjs/scene";
  37878. import { Vector3 } from "babylonjs/Maths/math";
  37879. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37880. /**
  37881. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37883. */
  37884. export class AnaglyphGamepadCamera extends GamepadCamera {
  37885. /**
  37886. * Creates a new AnaglyphGamepadCamera
  37887. * @param name defines camera name
  37888. * @param position defines initial position
  37889. * @param interaxialDistance defines distance between each color axis
  37890. * @param scene defines the hosting scene
  37891. */
  37892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37893. /**
  37894. * Gets camera class name
  37895. * @returns AnaglyphGamepadCamera
  37896. */
  37897. getClassName(): string;
  37898. }
  37899. }
  37900. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37901. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37902. import { Scene } from "babylonjs/scene";
  37903. import { Vector3 } from "babylonjs/Maths/math";
  37904. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37905. /**
  37906. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37907. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37908. */
  37909. export class AnaglyphUniversalCamera extends UniversalCamera {
  37910. /**
  37911. * Creates a new AnaglyphUniversalCamera
  37912. * @param name defines camera name
  37913. * @param position defines initial position
  37914. * @param interaxialDistance defines distance between each color axis
  37915. * @param scene defines the hosting scene
  37916. */
  37917. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37918. /**
  37919. * Gets camera class name
  37920. * @returns AnaglyphUniversalCamera
  37921. */
  37922. getClassName(): string;
  37923. }
  37924. }
  37925. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37926. /** @hidden */
  37927. export var stereoscopicInterlacePixelShader: {
  37928. name: string;
  37929. shader: string;
  37930. };
  37931. }
  37932. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37933. import { Camera } from "babylonjs/Cameras/camera";
  37934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37935. import { Engine } from "babylonjs/Engines/engine";
  37936. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37937. /**
  37938. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37939. */
  37940. export class StereoscopicInterlacePostProcess extends PostProcess {
  37941. private _stepSize;
  37942. private _passedProcess;
  37943. /**
  37944. * Initializes a StereoscopicInterlacePostProcess
  37945. * @param name The name of the effect.
  37946. * @param rigCameras The rig cameras to be appled to the post process
  37947. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37949. * @param engine The engine which the post process will be applied. (default: current engine)
  37950. * @param reusable If the post process can be reused on the same frame. (default: false)
  37951. */
  37952. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37953. }
  37954. }
  37955. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37956. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37958. import { Scene } from "babylonjs/scene";
  37959. import { Vector3 } from "babylonjs/Maths/math";
  37960. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37961. /**
  37962. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37963. * @see http://doc.babylonjs.com/features/cameras
  37964. */
  37965. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37966. /**
  37967. * Creates a new StereoscopicArcRotateCamera
  37968. * @param name defines camera name
  37969. * @param alpha defines alpha angle (in radians)
  37970. * @param beta defines beta angle (in radians)
  37971. * @param radius defines radius
  37972. * @param target defines camera target
  37973. * @param interaxialDistance defines distance between each color axis
  37974. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37975. * @param scene defines the hosting scene
  37976. */
  37977. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37978. /**
  37979. * Gets camera class name
  37980. * @returns StereoscopicArcRotateCamera
  37981. */
  37982. getClassName(): string;
  37983. }
  37984. }
  37985. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37986. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37987. import { Scene } from "babylonjs/scene";
  37988. import { Vector3 } from "babylonjs/Maths/math";
  37989. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37990. /**
  37991. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37992. * @see http://doc.babylonjs.com/features/cameras
  37993. */
  37994. export class StereoscopicFreeCamera extends FreeCamera {
  37995. /**
  37996. * Creates a new StereoscopicFreeCamera
  37997. * @param name defines camera name
  37998. * @param position defines initial position
  37999. * @param interaxialDistance defines distance between each color axis
  38000. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38001. * @param scene defines the hosting scene
  38002. */
  38003. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38004. /**
  38005. * Gets camera class name
  38006. * @returns StereoscopicFreeCamera
  38007. */
  38008. getClassName(): string;
  38009. }
  38010. }
  38011. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38012. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38013. import { Scene } from "babylonjs/scene";
  38014. import { Vector3 } from "babylonjs/Maths/math";
  38015. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38016. /**
  38017. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38018. * @see http://doc.babylonjs.com/features/cameras
  38019. */
  38020. export class StereoscopicGamepadCamera extends GamepadCamera {
  38021. /**
  38022. * Creates a new StereoscopicGamepadCamera
  38023. * @param name defines camera name
  38024. * @param position defines initial position
  38025. * @param interaxialDistance defines distance between each color axis
  38026. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38027. * @param scene defines the hosting scene
  38028. */
  38029. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38030. /**
  38031. * Gets camera class name
  38032. * @returns StereoscopicGamepadCamera
  38033. */
  38034. getClassName(): string;
  38035. }
  38036. }
  38037. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38038. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38039. import { Scene } from "babylonjs/scene";
  38040. import { Vector3 } from "babylonjs/Maths/math";
  38041. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38042. /**
  38043. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38044. * @see http://doc.babylonjs.com/features/cameras
  38045. */
  38046. export class StereoscopicUniversalCamera extends UniversalCamera {
  38047. /**
  38048. * Creates a new StereoscopicUniversalCamera
  38049. * @param name defines camera name
  38050. * @param position defines initial position
  38051. * @param interaxialDistance defines distance between each color axis
  38052. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38053. * @param scene defines the hosting scene
  38054. */
  38055. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38056. /**
  38057. * Gets camera class name
  38058. * @returns StereoscopicUniversalCamera
  38059. */
  38060. getClassName(): string;
  38061. }
  38062. }
  38063. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38064. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38065. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38066. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38067. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38068. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38069. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38070. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38071. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38072. }
  38073. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38075. import { Scene } from "babylonjs/scene";
  38076. import { Vector3 } from "babylonjs/Maths/math";
  38077. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38078. /**
  38079. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38080. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38081. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38082. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38083. */
  38084. export class VirtualJoysticksCamera extends FreeCamera {
  38085. /**
  38086. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38087. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38088. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38089. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38090. * @param name Define the name of the camera in the scene
  38091. * @param position Define the start position of the camera in the scene
  38092. * @param scene Define the scene the camera belongs to
  38093. */
  38094. constructor(name: string, position: Vector3, scene: Scene);
  38095. /**
  38096. * Gets the current object class name.
  38097. * @return the class name
  38098. */
  38099. getClassName(): string;
  38100. }
  38101. }
  38102. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38103. import { Matrix } from "babylonjs/Maths/math";
  38104. /**
  38105. * This represents all the required metrics to create a VR camera.
  38106. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38107. */
  38108. export class VRCameraMetrics {
  38109. /**
  38110. * Define the horizontal resolution off the screen.
  38111. */
  38112. hResolution: number;
  38113. /**
  38114. * Define the vertical resolution off the screen.
  38115. */
  38116. vResolution: number;
  38117. /**
  38118. * Define the horizontal screen size.
  38119. */
  38120. hScreenSize: number;
  38121. /**
  38122. * Define the vertical screen size.
  38123. */
  38124. vScreenSize: number;
  38125. /**
  38126. * Define the vertical screen center position.
  38127. */
  38128. vScreenCenter: number;
  38129. /**
  38130. * Define the distance of the eyes to the screen.
  38131. */
  38132. eyeToScreenDistance: number;
  38133. /**
  38134. * Define the distance between both lenses
  38135. */
  38136. lensSeparationDistance: number;
  38137. /**
  38138. * Define the distance between both viewer's eyes.
  38139. */
  38140. interpupillaryDistance: number;
  38141. /**
  38142. * Define the distortion factor of the VR postprocess.
  38143. * Please, touch with care.
  38144. */
  38145. distortionK: number[];
  38146. /**
  38147. * Define the chromatic aberration correction factors for the VR post process.
  38148. */
  38149. chromaAbCorrection: number[];
  38150. /**
  38151. * Define the scale factor of the post process.
  38152. * The smaller the better but the slower.
  38153. */
  38154. postProcessScaleFactor: number;
  38155. /**
  38156. * Define an offset for the lens center.
  38157. */
  38158. lensCenterOffset: number;
  38159. /**
  38160. * Define if the current vr camera should compensate the distortion of the lense or not.
  38161. */
  38162. compensateDistortion: boolean;
  38163. /**
  38164. * Gets the rendering aspect ratio based on the provided resolutions.
  38165. */
  38166. readonly aspectRatio: number;
  38167. /**
  38168. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38169. */
  38170. readonly aspectRatioFov: number;
  38171. /**
  38172. * @hidden
  38173. */
  38174. readonly leftHMatrix: Matrix;
  38175. /**
  38176. * @hidden
  38177. */
  38178. readonly rightHMatrix: Matrix;
  38179. /**
  38180. * @hidden
  38181. */
  38182. readonly leftPreViewMatrix: Matrix;
  38183. /**
  38184. * @hidden
  38185. */
  38186. readonly rightPreViewMatrix: Matrix;
  38187. /**
  38188. * Get the default VRMetrics based on the most generic setup.
  38189. * @returns the default vr metrics
  38190. */
  38191. static GetDefault(): VRCameraMetrics;
  38192. }
  38193. }
  38194. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38195. /** @hidden */
  38196. export var vrDistortionCorrectionPixelShader: {
  38197. name: string;
  38198. shader: string;
  38199. };
  38200. }
  38201. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38202. import { Camera } from "babylonjs/Cameras/camera";
  38203. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38205. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38206. /**
  38207. * VRDistortionCorrectionPostProcess used for mobile VR
  38208. */
  38209. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38210. private _isRightEye;
  38211. private _distortionFactors;
  38212. private _postProcessScaleFactor;
  38213. private _lensCenterOffset;
  38214. private _scaleIn;
  38215. private _scaleFactor;
  38216. private _lensCenter;
  38217. /**
  38218. * Initializes the VRDistortionCorrectionPostProcess
  38219. * @param name The name of the effect.
  38220. * @param camera The camera to apply the render pass to.
  38221. * @param isRightEye If this is for the right eye distortion
  38222. * @param vrMetrics All the required metrics for the VR camera
  38223. */
  38224. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38225. }
  38226. }
  38227. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38228. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38229. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38230. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38231. import { Scene } from "babylonjs/scene";
  38232. import { Vector3 } from "babylonjs/Maths/math";
  38233. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38234. import "babylonjs/Cameras/RigModes/vrRigMode";
  38235. /**
  38236. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38237. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38238. */
  38239. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38240. /**
  38241. * Creates a new VRDeviceOrientationArcRotateCamera
  38242. * @param name defines camera name
  38243. * @param alpha defines the camera rotation along the logitudinal axis
  38244. * @param beta defines the camera rotation along the latitudinal axis
  38245. * @param radius defines the camera distance from its target
  38246. * @param target defines the camera target
  38247. * @param scene defines the scene the camera belongs to
  38248. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38249. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38250. */
  38251. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38252. /**
  38253. * Gets camera class name
  38254. * @returns VRDeviceOrientationArcRotateCamera
  38255. */
  38256. getClassName(): string;
  38257. }
  38258. }
  38259. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38260. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38261. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38262. import { Scene } from "babylonjs/scene";
  38263. import { Vector3 } from "babylonjs/Maths/math";
  38264. import "babylonjs/Cameras/RigModes/vrRigMode";
  38265. /**
  38266. * Camera used to simulate VR rendering (based on FreeCamera)
  38267. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38268. */
  38269. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38270. /**
  38271. * Creates a new VRDeviceOrientationFreeCamera
  38272. * @param name defines camera name
  38273. * @param position defines the start position of the camera
  38274. * @param scene defines the scene the camera belongs to
  38275. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38276. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38277. */
  38278. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38279. /**
  38280. * Gets camera class name
  38281. * @returns VRDeviceOrientationFreeCamera
  38282. */
  38283. getClassName(): string;
  38284. }
  38285. }
  38286. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38287. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38288. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38289. import { Scene } from "babylonjs/scene";
  38290. import { Vector3 } from "babylonjs/Maths/math";
  38291. /**
  38292. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38293. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38294. */
  38295. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38296. /**
  38297. * Creates a new VRDeviceOrientationGamepadCamera
  38298. * @param name defines camera name
  38299. * @param position defines the start position of the camera
  38300. * @param scene defines the scene the camera belongs to
  38301. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38302. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38303. */
  38304. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38305. /**
  38306. * Gets camera class name
  38307. * @returns VRDeviceOrientationGamepadCamera
  38308. */
  38309. getClassName(): string;
  38310. }
  38311. }
  38312. declare module "babylonjs/Gamepads/xboxGamepad" {
  38313. import { Observable } from "babylonjs/Misc/observable";
  38314. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38315. /**
  38316. * Defines supported buttons for XBox360 compatible gamepads
  38317. */
  38318. export enum Xbox360Button {
  38319. /** A */
  38320. A = 0,
  38321. /** B */
  38322. B = 1,
  38323. /** X */
  38324. X = 2,
  38325. /** Y */
  38326. Y = 3,
  38327. /** Start */
  38328. Start = 4,
  38329. /** Back */
  38330. Back = 5,
  38331. /** Left button */
  38332. LB = 6,
  38333. /** Right button */
  38334. RB = 7,
  38335. /** Left stick */
  38336. LeftStick = 8,
  38337. /** Right stick */
  38338. RightStick = 9
  38339. }
  38340. /** Defines values for XBox360 DPad */
  38341. export enum Xbox360Dpad {
  38342. /** Up */
  38343. Up = 0,
  38344. /** Down */
  38345. Down = 1,
  38346. /** Left */
  38347. Left = 2,
  38348. /** Right */
  38349. Right = 3
  38350. }
  38351. /**
  38352. * Defines a XBox360 gamepad
  38353. */
  38354. export class Xbox360Pad extends Gamepad {
  38355. private _leftTrigger;
  38356. private _rightTrigger;
  38357. private _onlefttriggerchanged;
  38358. private _onrighttriggerchanged;
  38359. private _onbuttondown;
  38360. private _onbuttonup;
  38361. private _ondpaddown;
  38362. private _ondpadup;
  38363. /** Observable raised when a button is pressed */
  38364. onButtonDownObservable: Observable<Xbox360Button>;
  38365. /** Observable raised when a button is released */
  38366. onButtonUpObservable: Observable<Xbox360Button>;
  38367. /** Observable raised when a pad is pressed */
  38368. onPadDownObservable: Observable<Xbox360Dpad>;
  38369. /** Observable raised when a pad is released */
  38370. onPadUpObservable: Observable<Xbox360Dpad>;
  38371. private _buttonA;
  38372. private _buttonB;
  38373. private _buttonX;
  38374. private _buttonY;
  38375. private _buttonBack;
  38376. private _buttonStart;
  38377. private _buttonLB;
  38378. private _buttonRB;
  38379. private _buttonLeftStick;
  38380. private _buttonRightStick;
  38381. private _dPadUp;
  38382. private _dPadDown;
  38383. private _dPadLeft;
  38384. private _dPadRight;
  38385. private _isXboxOnePad;
  38386. /**
  38387. * Creates a new XBox360 gamepad object
  38388. * @param id defines the id of this gamepad
  38389. * @param index defines its index
  38390. * @param gamepad defines the internal HTML gamepad object
  38391. * @param xboxOne defines if it is a XBox One gamepad
  38392. */
  38393. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38394. /**
  38395. * Defines the callback to call when left trigger is pressed
  38396. * @param callback defines the callback to use
  38397. */
  38398. onlefttriggerchanged(callback: (value: number) => void): void;
  38399. /**
  38400. * Defines the callback to call when right trigger is pressed
  38401. * @param callback defines the callback to use
  38402. */
  38403. onrighttriggerchanged(callback: (value: number) => void): void;
  38404. /**
  38405. * Gets the left trigger value
  38406. */
  38407. /**
  38408. * Sets the left trigger value
  38409. */
  38410. leftTrigger: number;
  38411. /**
  38412. * Gets the right trigger value
  38413. */
  38414. /**
  38415. * Sets the right trigger value
  38416. */
  38417. rightTrigger: number;
  38418. /**
  38419. * Defines the callback to call when a button is pressed
  38420. * @param callback defines the callback to use
  38421. */
  38422. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38423. /**
  38424. * Defines the callback to call when a button is released
  38425. * @param callback defines the callback to use
  38426. */
  38427. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38428. /**
  38429. * Defines the callback to call when a pad is pressed
  38430. * @param callback defines the callback to use
  38431. */
  38432. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38433. /**
  38434. * Defines the callback to call when a pad is released
  38435. * @param callback defines the callback to use
  38436. */
  38437. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38438. private _setButtonValue;
  38439. private _setDPadValue;
  38440. /**
  38441. * Gets the value of the `A` button
  38442. */
  38443. /**
  38444. * Sets the value of the `A` button
  38445. */
  38446. buttonA: number;
  38447. /**
  38448. * Gets the value of the `B` button
  38449. */
  38450. /**
  38451. * Sets the value of the `B` button
  38452. */
  38453. buttonB: number;
  38454. /**
  38455. * Gets the value of the `X` button
  38456. */
  38457. /**
  38458. * Sets the value of the `X` button
  38459. */
  38460. buttonX: number;
  38461. /**
  38462. * Gets the value of the `Y` button
  38463. */
  38464. /**
  38465. * Sets the value of the `Y` button
  38466. */
  38467. buttonY: number;
  38468. /**
  38469. * Gets the value of the `Start` button
  38470. */
  38471. /**
  38472. * Sets the value of the `Start` button
  38473. */
  38474. buttonStart: number;
  38475. /**
  38476. * Gets the value of the `Back` button
  38477. */
  38478. /**
  38479. * Sets the value of the `Back` button
  38480. */
  38481. buttonBack: number;
  38482. /**
  38483. * Gets the value of the `Left` button
  38484. */
  38485. /**
  38486. * Sets the value of the `Left` button
  38487. */
  38488. buttonLB: number;
  38489. /**
  38490. * Gets the value of the `Right` button
  38491. */
  38492. /**
  38493. * Sets the value of the `Right` button
  38494. */
  38495. buttonRB: number;
  38496. /**
  38497. * Gets the value of the Left joystick
  38498. */
  38499. /**
  38500. * Sets the value of the Left joystick
  38501. */
  38502. buttonLeftStick: number;
  38503. /**
  38504. * Gets the value of the Right joystick
  38505. */
  38506. /**
  38507. * Sets the value of the Right joystick
  38508. */
  38509. buttonRightStick: number;
  38510. /**
  38511. * Gets the value of D-pad up
  38512. */
  38513. /**
  38514. * Sets the value of D-pad up
  38515. */
  38516. dPadUp: number;
  38517. /**
  38518. * Gets the value of D-pad down
  38519. */
  38520. /**
  38521. * Sets the value of D-pad down
  38522. */
  38523. dPadDown: number;
  38524. /**
  38525. * Gets the value of D-pad left
  38526. */
  38527. /**
  38528. * Sets the value of D-pad left
  38529. */
  38530. dPadLeft: number;
  38531. /**
  38532. * Gets the value of D-pad right
  38533. */
  38534. /**
  38535. * Sets the value of D-pad right
  38536. */
  38537. dPadRight: number;
  38538. /**
  38539. * Force the gamepad to synchronize with device values
  38540. */
  38541. update(): void;
  38542. /**
  38543. * Disposes the gamepad
  38544. */
  38545. dispose(): void;
  38546. }
  38547. }
  38548. declare module "babylonjs/Materials/pushMaterial" {
  38549. import { Nullable } from "babylonjs/types";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Matrix } from "babylonjs/Maths/math";
  38552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38553. import { Mesh } from "babylonjs/Meshes/mesh";
  38554. import { Material } from "babylonjs/Materials/material";
  38555. import { Effect } from "babylonjs/Materials/effect";
  38556. /**
  38557. * Base class of materials working in push mode in babylon JS
  38558. * @hidden
  38559. */
  38560. export class PushMaterial extends Material {
  38561. protected _activeEffect: Effect;
  38562. protected _normalMatrix: Matrix;
  38563. /**
  38564. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38565. * This means that the material can keep using a previous shader while a new one is being compiled.
  38566. * This is mostly used when shader parallel compilation is supported (true by default)
  38567. */
  38568. allowShaderHotSwapping: boolean;
  38569. constructor(name: string, scene: Scene);
  38570. getEffect(): Effect;
  38571. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38572. /**
  38573. * Binds the given world matrix to the active effect
  38574. *
  38575. * @param world the matrix to bind
  38576. */
  38577. bindOnlyWorldMatrix(world: Matrix): void;
  38578. /**
  38579. * Binds the given normal matrix to the active effect
  38580. *
  38581. * @param normalMatrix the matrix to bind
  38582. */
  38583. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38584. bind(world: Matrix, mesh?: Mesh): void;
  38585. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38586. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38587. }
  38588. }
  38589. declare module "babylonjs/Materials/materialFlags" {
  38590. /**
  38591. * This groups all the flags used to control the materials channel.
  38592. */
  38593. export class MaterialFlags {
  38594. private static _DiffuseTextureEnabled;
  38595. /**
  38596. * Are diffuse textures enabled in the application.
  38597. */
  38598. static DiffuseTextureEnabled: boolean;
  38599. private static _AmbientTextureEnabled;
  38600. /**
  38601. * Are ambient textures enabled in the application.
  38602. */
  38603. static AmbientTextureEnabled: boolean;
  38604. private static _OpacityTextureEnabled;
  38605. /**
  38606. * Are opacity textures enabled in the application.
  38607. */
  38608. static OpacityTextureEnabled: boolean;
  38609. private static _ReflectionTextureEnabled;
  38610. /**
  38611. * Are reflection textures enabled in the application.
  38612. */
  38613. static ReflectionTextureEnabled: boolean;
  38614. private static _EmissiveTextureEnabled;
  38615. /**
  38616. * Are emissive textures enabled in the application.
  38617. */
  38618. static EmissiveTextureEnabled: boolean;
  38619. private static _SpecularTextureEnabled;
  38620. /**
  38621. * Are specular textures enabled in the application.
  38622. */
  38623. static SpecularTextureEnabled: boolean;
  38624. private static _BumpTextureEnabled;
  38625. /**
  38626. * Are bump textures enabled in the application.
  38627. */
  38628. static BumpTextureEnabled: boolean;
  38629. private static _LightmapTextureEnabled;
  38630. /**
  38631. * Are lightmap textures enabled in the application.
  38632. */
  38633. static LightmapTextureEnabled: boolean;
  38634. private static _RefractionTextureEnabled;
  38635. /**
  38636. * Are refraction textures enabled in the application.
  38637. */
  38638. static RefractionTextureEnabled: boolean;
  38639. private static _ColorGradingTextureEnabled;
  38640. /**
  38641. * Are color grading textures enabled in the application.
  38642. */
  38643. static ColorGradingTextureEnabled: boolean;
  38644. private static _FresnelEnabled;
  38645. /**
  38646. * Are fresnels enabled in the application.
  38647. */
  38648. static FresnelEnabled: boolean;
  38649. private static _ClearCoatTextureEnabled;
  38650. /**
  38651. * Are clear coat textures enabled in the application.
  38652. */
  38653. static ClearCoatTextureEnabled: boolean;
  38654. private static _ClearCoatBumpTextureEnabled;
  38655. /**
  38656. * Are clear coat bump textures enabled in the application.
  38657. */
  38658. static ClearCoatBumpTextureEnabled: boolean;
  38659. private static _ClearCoatTintTextureEnabled;
  38660. /**
  38661. * Are clear coat tint textures enabled in the application.
  38662. */
  38663. static ClearCoatTintTextureEnabled: boolean;
  38664. private static _SheenTextureEnabled;
  38665. /**
  38666. * Are sheen textures enabled in the application.
  38667. */
  38668. static SheenTextureEnabled: boolean;
  38669. private static _AnisotropicTextureEnabled;
  38670. /**
  38671. * Are anisotropic textures enabled in the application.
  38672. */
  38673. static AnisotropicTextureEnabled: boolean;
  38674. }
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38677. /** @hidden */
  38678. export var defaultFragmentDeclaration: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38684. /** @hidden */
  38685. export var defaultUboDeclaration: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38691. /** @hidden */
  38692. export var lightFragmentDeclaration: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38698. /** @hidden */
  38699. export var lightUboDeclaration: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38705. /** @hidden */
  38706. export var lightsFragmentFunctions: {
  38707. name: string;
  38708. shader: string;
  38709. };
  38710. }
  38711. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38712. /** @hidden */
  38713. export var shadowsFragmentFunctions: {
  38714. name: string;
  38715. shader: string;
  38716. };
  38717. }
  38718. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38719. /** @hidden */
  38720. export var fresnelFunction: {
  38721. name: string;
  38722. shader: string;
  38723. };
  38724. }
  38725. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38726. /** @hidden */
  38727. export var reflectionFunction: {
  38728. name: string;
  38729. shader: string;
  38730. };
  38731. }
  38732. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38733. /** @hidden */
  38734. export var bumpFragmentFunctions: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38740. /** @hidden */
  38741. export var logDepthDeclaration: {
  38742. name: string;
  38743. shader: string;
  38744. };
  38745. }
  38746. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38747. /** @hidden */
  38748. export var bumpFragment: {
  38749. name: string;
  38750. shader: string;
  38751. };
  38752. }
  38753. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38754. /** @hidden */
  38755. export var depthPrePass: {
  38756. name: string;
  38757. shader: string;
  38758. };
  38759. }
  38760. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38761. /** @hidden */
  38762. export var lightFragment: {
  38763. name: string;
  38764. shader: string;
  38765. };
  38766. }
  38767. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38768. /** @hidden */
  38769. export var logDepthFragment: {
  38770. name: string;
  38771. shader: string;
  38772. };
  38773. }
  38774. declare module "babylonjs/Shaders/default.fragment" {
  38775. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38776. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38778. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38779. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38780. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38781. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38782. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38783. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38784. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38785. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38786. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38787. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38788. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38789. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38790. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38791. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38792. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38793. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38794. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38795. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38796. /** @hidden */
  38797. export var defaultPixelShader: {
  38798. name: string;
  38799. shader: string;
  38800. };
  38801. }
  38802. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38803. /** @hidden */
  38804. export var defaultVertexDeclaration: {
  38805. name: string;
  38806. shader: string;
  38807. };
  38808. }
  38809. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38810. /** @hidden */
  38811. export var bumpVertexDeclaration: {
  38812. name: string;
  38813. shader: string;
  38814. };
  38815. }
  38816. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38817. /** @hidden */
  38818. export var bumpVertex: {
  38819. name: string;
  38820. shader: string;
  38821. };
  38822. }
  38823. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38824. /** @hidden */
  38825. export var fogVertex: {
  38826. name: string;
  38827. shader: string;
  38828. };
  38829. }
  38830. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38831. /** @hidden */
  38832. export var shadowsVertex: {
  38833. name: string;
  38834. shader: string;
  38835. };
  38836. }
  38837. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38838. /** @hidden */
  38839. export var pointCloudVertex: {
  38840. name: string;
  38841. shader: string;
  38842. };
  38843. }
  38844. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38845. /** @hidden */
  38846. export var logDepthVertex: {
  38847. name: string;
  38848. shader: string;
  38849. };
  38850. }
  38851. declare module "babylonjs/Shaders/default.vertex" {
  38852. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38853. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38854. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38856. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38857. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38859. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38860. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38861. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38864. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38866. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38867. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38868. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38869. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38870. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38871. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38872. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38873. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38874. /** @hidden */
  38875. export var defaultVertexShader: {
  38876. name: string;
  38877. shader: string;
  38878. };
  38879. }
  38880. declare module "babylonjs/Materials/standardMaterial" {
  38881. import { SmartArray } from "babylonjs/Misc/smartArray";
  38882. import { IAnimatable } from "babylonjs/Misc/tools";
  38883. import { Nullable } from "babylonjs/types";
  38884. import { Scene } from "babylonjs/scene";
  38885. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38888. import { Mesh } from "babylonjs/Meshes/mesh";
  38889. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38890. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38891. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38892. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38893. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38896. import "babylonjs/Shaders/default.fragment";
  38897. import "babylonjs/Shaders/default.vertex";
  38898. /** @hidden */
  38899. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38900. MAINUV1: boolean;
  38901. MAINUV2: boolean;
  38902. DIFFUSE: boolean;
  38903. DIFFUSEDIRECTUV: number;
  38904. AMBIENT: boolean;
  38905. AMBIENTDIRECTUV: number;
  38906. OPACITY: boolean;
  38907. OPACITYDIRECTUV: number;
  38908. OPACITYRGB: boolean;
  38909. REFLECTION: boolean;
  38910. EMISSIVE: boolean;
  38911. EMISSIVEDIRECTUV: number;
  38912. SPECULAR: boolean;
  38913. SPECULARDIRECTUV: number;
  38914. BUMP: boolean;
  38915. BUMPDIRECTUV: number;
  38916. PARALLAX: boolean;
  38917. PARALLAXOCCLUSION: boolean;
  38918. SPECULAROVERALPHA: boolean;
  38919. CLIPPLANE: boolean;
  38920. CLIPPLANE2: boolean;
  38921. CLIPPLANE3: boolean;
  38922. CLIPPLANE4: boolean;
  38923. ALPHATEST: boolean;
  38924. DEPTHPREPASS: boolean;
  38925. ALPHAFROMDIFFUSE: boolean;
  38926. POINTSIZE: boolean;
  38927. FOG: boolean;
  38928. SPECULARTERM: boolean;
  38929. DIFFUSEFRESNEL: boolean;
  38930. OPACITYFRESNEL: boolean;
  38931. REFLECTIONFRESNEL: boolean;
  38932. REFRACTIONFRESNEL: boolean;
  38933. EMISSIVEFRESNEL: boolean;
  38934. FRESNEL: boolean;
  38935. NORMAL: boolean;
  38936. UV1: boolean;
  38937. UV2: boolean;
  38938. VERTEXCOLOR: boolean;
  38939. VERTEXALPHA: boolean;
  38940. NUM_BONE_INFLUENCERS: number;
  38941. BonesPerMesh: number;
  38942. BONETEXTURE: boolean;
  38943. INSTANCES: boolean;
  38944. GLOSSINESS: boolean;
  38945. ROUGHNESS: boolean;
  38946. EMISSIVEASILLUMINATION: boolean;
  38947. LINKEMISSIVEWITHDIFFUSE: boolean;
  38948. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38949. LIGHTMAP: boolean;
  38950. LIGHTMAPDIRECTUV: number;
  38951. OBJECTSPACE_NORMALMAP: boolean;
  38952. USELIGHTMAPASSHADOWMAP: boolean;
  38953. REFLECTIONMAP_3D: boolean;
  38954. REFLECTIONMAP_SPHERICAL: boolean;
  38955. REFLECTIONMAP_PLANAR: boolean;
  38956. REFLECTIONMAP_CUBIC: boolean;
  38957. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38958. REFLECTIONMAP_PROJECTION: boolean;
  38959. REFLECTIONMAP_SKYBOX: boolean;
  38960. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38961. REFLECTIONMAP_EXPLICIT: boolean;
  38962. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38963. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38964. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38965. INVERTCUBICMAP: boolean;
  38966. LOGARITHMICDEPTH: boolean;
  38967. REFRACTION: boolean;
  38968. REFRACTIONMAP_3D: boolean;
  38969. REFLECTIONOVERALPHA: boolean;
  38970. TWOSIDEDLIGHTING: boolean;
  38971. SHADOWFLOAT: boolean;
  38972. MORPHTARGETS: boolean;
  38973. MORPHTARGETS_NORMAL: boolean;
  38974. MORPHTARGETS_TANGENT: boolean;
  38975. NUM_MORPH_INFLUENCERS: number;
  38976. NONUNIFORMSCALING: boolean;
  38977. PREMULTIPLYALPHA: boolean;
  38978. IMAGEPROCESSING: boolean;
  38979. VIGNETTE: boolean;
  38980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38981. VIGNETTEBLENDMODEOPAQUE: boolean;
  38982. TONEMAPPING: boolean;
  38983. TONEMAPPING_ACES: boolean;
  38984. CONTRAST: boolean;
  38985. COLORCURVES: boolean;
  38986. COLORGRADING: boolean;
  38987. COLORGRADING3D: boolean;
  38988. SAMPLER3DGREENDEPTH: boolean;
  38989. SAMPLER3DBGRMAP: boolean;
  38990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38991. /**
  38992. * If the reflection texture on this material is in linear color space
  38993. * @hidden
  38994. */
  38995. IS_REFLECTION_LINEAR: boolean;
  38996. /**
  38997. * If the refraction texture on this material is in linear color space
  38998. * @hidden
  38999. */
  39000. IS_REFRACTION_LINEAR: boolean;
  39001. EXPOSURE: boolean;
  39002. constructor();
  39003. setReflectionMode(modeToEnable: string): void;
  39004. }
  39005. /**
  39006. * This is the default material used in Babylon. It is the best trade off between quality
  39007. * and performances.
  39008. * @see http://doc.babylonjs.com/babylon101/materials
  39009. */
  39010. export class StandardMaterial extends PushMaterial {
  39011. private _diffuseTexture;
  39012. /**
  39013. * The basic texture of the material as viewed under a light.
  39014. */
  39015. diffuseTexture: Nullable<BaseTexture>;
  39016. private _ambientTexture;
  39017. /**
  39018. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39019. */
  39020. ambientTexture: Nullable<BaseTexture>;
  39021. private _opacityTexture;
  39022. /**
  39023. * Define the transparency of the material from a texture.
  39024. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39025. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39026. */
  39027. opacityTexture: Nullable<BaseTexture>;
  39028. private _reflectionTexture;
  39029. /**
  39030. * Define the texture used to display the reflection.
  39031. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39032. */
  39033. reflectionTexture: Nullable<BaseTexture>;
  39034. private _emissiveTexture;
  39035. /**
  39036. * Define texture of the material as if self lit.
  39037. * This will be mixed in the final result even in the absence of light.
  39038. */
  39039. emissiveTexture: Nullable<BaseTexture>;
  39040. private _specularTexture;
  39041. /**
  39042. * Define how the color and intensity of the highlight given by the light in the material.
  39043. */
  39044. specularTexture: Nullable<BaseTexture>;
  39045. private _bumpTexture;
  39046. /**
  39047. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39048. * 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.
  39049. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39050. */
  39051. bumpTexture: Nullable<BaseTexture>;
  39052. private _lightmapTexture;
  39053. /**
  39054. * Complex lighting can be computationally expensive to compute at runtime.
  39055. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39056. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39057. */
  39058. lightmapTexture: Nullable<BaseTexture>;
  39059. private _refractionTexture;
  39060. /**
  39061. * Define the texture used to display the refraction.
  39062. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39063. */
  39064. refractionTexture: Nullable<BaseTexture>;
  39065. /**
  39066. * The color of the material lit by the environmental background lighting.
  39067. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39068. */
  39069. ambientColor: Color3;
  39070. /**
  39071. * The basic color of the material as viewed under a light.
  39072. */
  39073. diffuseColor: Color3;
  39074. /**
  39075. * Define how the color and intensity of the highlight given by the light in the material.
  39076. */
  39077. specularColor: Color3;
  39078. /**
  39079. * Define the color of the material as if self lit.
  39080. * This will be mixed in the final result even in the absence of light.
  39081. */
  39082. emissiveColor: Color3;
  39083. /**
  39084. * Defines how sharp are the highlights in the material.
  39085. * The bigger the value the sharper giving a more glossy feeling to the result.
  39086. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39087. */
  39088. specularPower: number;
  39089. private _useAlphaFromDiffuseTexture;
  39090. /**
  39091. * Does the transparency come from the diffuse texture alpha channel.
  39092. */
  39093. useAlphaFromDiffuseTexture: boolean;
  39094. private _useEmissiveAsIllumination;
  39095. /**
  39096. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39097. */
  39098. useEmissiveAsIllumination: boolean;
  39099. private _linkEmissiveWithDiffuse;
  39100. /**
  39101. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39102. * the emissive level when the final color is close to one.
  39103. */
  39104. linkEmissiveWithDiffuse: boolean;
  39105. private _useSpecularOverAlpha;
  39106. /**
  39107. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39108. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39109. */
  39110. useSpecularOverAlpha: boolean;
  39111. private _useReflectionOverAlpha;
  39112. /**
  39113. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39114. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39115. */
  39116. useReflectionOverAlpha: boolean;
  39117. private _disableLighting;
  39118. /**
  39119. * Does lights from the scene impacts this material.
  39120. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39121. */
  39122. disableLighting: boolean;
  39123. private _useObjectSpaceNormalMap;
  39124. /**
  39125. * Allows using an object space normal map (instead of tangent space).
  39126. */
  39127. useObjectSpaceNormalMap: boolean;
  39128. private _useParallax;
  39129. /**
  39130. * Is parallax enabled or not.
  39131. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39132. */
  39133. useParallax: boolean;
  39134. private _useParallaxOcclusion;
  39135. /**
  39136. * Is parallax occlusion enabled or not.
  39137. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39138. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39139. */
  39140. useParallaxOcclusion: boolean;
  39141. /**
  39142. * 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.
  39143. */
  39144. parallaxScaleBias: number;
  39145. private _roughness;
  39146. /**
  39147. * Helps to define how blurry the reflections should appears in the material.
  39148. */
  39149. roughness: number;
  39150. /**
  39151. * In case of refraction, define the value of the indice of refraction.
  39152. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39153. */
  39154. indexOfRefraction: number;
  39155. /**
  39156. * Invert the refraction texture alongside the y axis.
  39157. * It can be useful with procedural textures or probe for instance.
  39158. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39159. */
  39160. invertRefractionY: boolean;
  39161. /**
  39162. * Defines the alpha limits in alpha test mode.
  39163. */
  39164. alphaCutOff: number;
  39165. private _useLightmapAsShadowmap;
  39166. /**
  39167. * In case of light mapping, define whether the map contains light or shadow informations.
  39168. */
  39169. useLightmapAsShadowmap: boolean;
  39170. private _diffuseFresnelParameters;
  39171. /**
  39172. * Define the diffuse fresnel parameters of the material.
  39173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39174. */
  39175. diffuseFresnelParameters: FresnelParameters;
  39176. private _opacityFresnelParameters;
  39177. /**
  39178. * Define the opacity fresnel parameters of the material.
  39179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39180. */
  39181. opacityFresnelParameters: FresnelParameters;
  39182. private _reflectionFresnelParameters;
  39183. /**
  39184. * Define the reflection fresnel parameters of the material.
  39185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39186. */
  39187. reflectionFresnelParameters: FresnelParameters;
  39188. private _refractionFresnelParameters;
  39189. /**
  39190. * Define the refraction fresnel parameters of the material.
  39191. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39192. */
  39193. refractionFresnelParameters: FresnelParameters;
  39194. private _emissiveFresnelParameters;
  39195. /**
  39196. * Define the emissive fresnel parameters of the material.
  39197. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39198. */
  39199. emissiveFresnelParameters: FresnelParameters;
  39200. private _useReflectionFresnelFromSpecular;
  39201. /**
  39202. * If true automatically deducts the fresnels values from the material specularity.
  39203. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39204. */
  39205. useReflectionFresnelFromSpecular: boolean;
  39206. private _useGlossinessFromSpecularMapAlpha;
  39207. /**
  39208. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39209. */
  39210. useGlossinessFromSpecularMapAlpha: boolean;
  39211. private _maxSimultaneousLights;
  39212. /**
  39213. * Defines the maximum number of lights that can be used in the material
  39214. */
  39215. maxSimultaneousLights: number;
  39216. private _invertNormalMapX;
  39217. /**
  39218. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39219. */
  39220. invertNormalMapX: boolean;
  39221. private _invertNormalMapY;
  39222. /**
  39223. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39224. */
  39225. invertNormalMapY: boolean;
  39226. private _twoSidedLighting;
  39227. /**
  39228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39229. */
  39230. twoSidedLighting: boolean;
  39231. /**
  39232. * Default configuration related to image processing available in the standard Material.
  39233. */
  39234. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39235. /**
  39236. * Gets the image processing configuration used either in this material.
  39237. */
  39238. /**
  39239. * Sets the Default image processing configuration used either in the this material.
  39240. *
  39241. * If sets to null, the scene one is in use.
  39242. */
  39243. imageProcessingConfiguration: ImageProcessingConfiguration;
  39244. /**
  39245. * Keep track of the image processing observer to allow dispose and replace.
  39246. */
  39247. private _imageProcessingObserver;
  39248. /**
  39249. * Attaches a new image processing configuration to the Standard Material.
  39250. * @param configuration
  39251. */
  39252. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39253. /**
  39254. * Gets wether the color curves effect is enabled.
  39255. */
  39256. /**
  39257. * Sets wether the color curves effect is enabled.
  39258. */
  39259. cameraColorCurvesEnabled: boolean;
  39260. /**
  39261. * Gets wether the color grading effect is enabled.
  39262. */
  39263. /**
  39264. * Gets wether the color grading effect is enabled.
  39265. */
  39266. cameraColorGradingEnabled: boolean;
  39267. /**
  39268. * Gets wether tonemapping is enabled or not.
  39269. */
  39270. /**
  39271. * Sets wether tonemapping is enabled or not
  39272. */
  39273. cameraToneMappingEnabled: boolean;
  39274. /**
  39275. * The camera exposure used on this material.
  39276. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39277. * This corresponds to a photographic exposure.
  39278. */
  39279. /**
  39280. * The camera exposure used on this material.
  39281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39282. * This corresponds to a photographic exposure.
  39283. */
  39284. cameraExposure: number;
  39285. /**
  39286. * Gets The camera contrast used on this material.
  39287. */
  39288. /**
  39289. * Sets The camera contrast used on this material.
  39290. */
  39291. cameraContrast: number;
  39292. /**
  39293. * Gets the Color Grading 2D Lookup Texture.
  39294. */
  39295. /**
  39296. * Sets the Color Grading 2D Lookup Texture.
  39297. */
  39298. cameraColorGradingTexture: Nullable<BaseTexture>;
  39299. /**
  39300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39302. * 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;
  39303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39304. */
  39305. /**
  39306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39308. * 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;
  39309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39310. */
  39311. cameraColorCurves: Nullable<ColorCurves>;
  39312. /**
  39313. * Custom callback helping to override the default shader used in the material.
  39314. */
  39315. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39316. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39317. protected _worldViewProjectionMatrix: Matrix;
  39318. protected _globalAmbientColor: Color3;
  39319. protected _useLogarithmicDepth: boolean;
  39320. /**
  39321. * Instantiates a new standard material.
  39322. * This is the default material used in Babylon. It is the best trade off between quality
  39323. * and performances.
  39324. * @see http://doc.babylonjs.com/babylon101/materials
  39325. * @param name Define the name of the material in the scene
  39326. * @param scene Define the scene the material belong to
  39327. */
  39328. constructor(name: string, scene: Scene);
  39329. /**
  39330. * Gets a boolean indicating that current material needs to register RTT
  39331. */
  39332. readonly hasRenderTargetTextures: boolean;
  39333. /**
  39334. * Gets the current class name of the material e.g. "StandardMaterial"
  39335. * Mainly use in serialization.
  39336. * @returns the class name
  39337. */
  39338. getClassName(): string;
  39339. /**
  39340. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39341. * You can try switching to logarithmic depth.
  39342. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39343. */
  39344. useLogarithmicDepth: boolean;
  39345. /**
  39346. * Specifies if the material will require alpha blending
  39347. * @returns a boolean specifying if alpha blending is needed
  39348. */
  39349. needAlphaBlending(): boolean;
  39350. /**
  39351. * Specifies if this material should be rendered in alpha test mode
  39352. * @returns a boolean specifying if an alpha test is needed.
  39353. */
  39354. needAlphaTesting(): boolean;
  39355. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39356. /**
  39357. * Get the texture used for alpha test purpose.
  39358. * @returns the diffuse texture in case of the standard material.
  39359. */
  39360. getAlphaTestTexture(): Nullable<BaseTexture>;
  39361. /**
  39362. * Get if the submesh is ready to be used and all its information available.
  39363. * Child classes can use it to update shaders
  39364. * @param mesh defines the mesh to check
  39365. * @param subMesh defines which submesh to check
  39366. * @param useInstances specifies that instances should be used
  39367. * @returns a boolean indicating that the submesh is ready or not
  39368. */
  39369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39370. /**
  39371. * Builds the material UBO layouts.
  39372. * Used internally during the effect preparation.
  39373. */
  39374. buildUniformLayout(): void;
  39375. /**
  39376. * Unbinds the material from the mesh
  39377. */
  39378. unbind(): void;
  39379. /**
  39380. * Binds the submesh to this material by preparing the effect and shader to draw
  39381. * @param world defines the world transformation matrix
  39382. * @param mesh defines the mesh containing the submesh
  39383. * @param subMesh defines the submesh to bind the material to
  39384. */
  39385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39386. /**
  39387. * Get the list of animatables in the material.
  39388. * @returns the list of animatables object used in the material
  39389. */
  39390. getAnimatables(): IAnimatable[];
  39391. /**
  39392. * Gets the active textures from the material
  39393. * @returns an array of textures
  39394. */
  39395. getActiveTextures(): BaseTexture[];
  39396. /**
  39397. * Specifies if the material uses a texture
  39398. * @param texture defines the texture to check against the material
  39399. * @returns a boolean specifying if the material uses the texture
  39400. */
  39401. hasTexture(texture: BaseTexture): boolean;
  39402. /**
  39403. * Disposes the material
  39404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39406. */
  39407. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39408. /**
  39409. * Makes a duplicate of the material, and gives it a new name
  39410. * @param name defines the new name for the duplicated material
  39411. * @returns the cloned material
  39412. */
  39413. clone(name: string): StandardMaterial;
  39414. /**
  39415. * Serializes this material in a JSON representation
  39416. * @returns the serialized material object
  39417. */
  39418. serialize(): any;
  39419. /**
  39420. * Creates a standard material from parsed material data
  39421. * @param source defines the JSON representation of the material
  39422. * @param scene defines the hosting scene
  39423. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39424. * @returns a new standard material
  39425. */
  39426. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39427. /**
  39428. * Are diffuse textures enabled in the application.
  39429. */
  39430. static DiffuseTextureEnabled: boolean;
  39431. /**
  39432. * Are ambient textures enabled in the application.
  39433. */
  39434. static AmbientTextureEnabled: boolean;
  39435. /**
  39436. * Are opacity textures enabled in the application.
  39437. */
  39438. static OpacityTextureEnabled: boolean;
  39439. /**
  39440. * Are reflection textures enabled in the application.
  39441. */
  39442. static ReflectionTextureEnabled: boolean;
  39443. /**
  39444. * Are emissive textures enabled in the application.
  39445. */
  39446. static EmissiveTextureEnabled: boolean;
  39447. /**
  39448. * Are specular textures enabled in the application.
  39449. */
  39450. static SpecularTextureEnabled: boolean;
  39451. /**
  39452. * Are bump textures enabled in the application.
  39453. */
  39454. static BumpTextureEnabled: boolean;
  39455. /**
  39456. * Are lightmap textures enabled in the application.
  39457. */
  39458. static LightmapTextureEnabled: boolean;
  39459. /**
  39460. * Are refraction textures enabled in the application.
  39461. */
  39462. static RefractionTextureEnabled: boolean;
  39463. /**
  39464. * Are color grading textures enabled in the application.
  39465. */
  39466. static ColorGradingTextureEnabled: boolean;
  39467. /**
  39468. * Are fresnels enabled in the application.
  39469. */
  39470. static FresnelEnabled: boolean;
  39471. }
  39472. }
  39473. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39474. import { Scene } from "babylonjs/scene";
  39475. import { Texture } from "babylonjs/Materials/Textures/texture";
  39476. /**
  39477. * A class extending Texture allowing drawing on a texture
  39478. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39479. */
  39480. export class DynamicTexture extends Texture {
  39481. private _generateMipMaps;
  39482. private _canvas;
  39483. private _context;
  39484. private _engine;
  39485. /**
  39486. * Creates a DynamicTexture
  39487. * @param name defines the name of the texture
  39488. * @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
  39489. * @param scene defines the scene where you want the texture
  39490. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39491. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39492. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39493. */
  39494. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39495. /**
  39496. * Get the current class name of the texture useful for serialization or dynamic coding.
  39497. * @returns "DynamicTexture"
  39498. */
  39499. getClassName(): string;
  39500. /**
  39501. * Gets the current state of canRescale
  39502. */
  39503. readonly canRescale: boolean;
  39504. private _recreate;
  39505. /**
  39506. * Scales the texture
  39507. * @param ratio the scale factor to apply to both width and height
  39508. */
  39509. scale(ratio: number): void;
  39510. /**
  39511. * Resizes the texture
  39512. * @param width the new width
  39513. * @param height the new height
  39514. */
  39515. scaleTo(width: number, height: number): void;
  39516. /**
  39517. * Gets the context of the canvas used by the texture
  39518. * @returns the canvas context of the dynamic texture
  39519. */
  39520. getContext(): CanvasRenderingContext2D;
  39521. /**
  39522. * Clears the texture
  39523. */
  39524. clear(): void;
  39525. /**
  39526. * Updates the texture
  39527. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39528. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39529. */
  39530. update(invertY?: boolean, premulAlpha?: boolean): void;
  39531. /**
  39532. * Draws text onto the texture
  39533. * @param text defines the text to be drawn
  39534. * @param x defines the placement of the text from the left
  39535. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39536. * @param font defines the font to be used with font-style, font-size, font-name
  39537. * @param color defines the color used for the text
  39538. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39539. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39540. * @param update defines whether texture is immediately update (default is true)
  39541. */
  39542. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39543. /**
  39544. * Clones the texture
  39545. * @returns the clone of the texture.
  39546. */
  39547. clone(): DynamicTexture;
  39548. /**
  39549. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39550. * @returns a serialized dynamic texture object
  39551. */
  39552. serialize(): any;
  39553. /** @hidden */
  39554. _rebuild(): void;
  39555. }
  39556. }
  39557. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39558. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39560. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39561. /** @hidden */
  39562. export var imageProcessingPixelShader: {
  39563. name: string;
  39564. shader: string;
  39565. };
  39566. }
  39567. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39568. import { Nullable } from "babylonjs/types";
  39569. import { Color4 } from "babylonjs/Maths/math";
  39570. import { Camera } from "babylonjs/Cameras/camera";
  39571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39573. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39575. import { Engine } from "babylonjs/Engines/engine";
  39576. import "babylonjs/Shaders/imageProcessing.fragment";
  39577. import "babylonjs/Shaders/postprocess.vertex";
  39578. /**
  39579. * ImageProcessingPostProcess
  39580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39581. */
  39582. export class ImageProcessingPostProcess extends PostProcess {
  39583. /**
  39584. * Default configuration related to image processing available in the PBR Material.
  39585. */
  39586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39587. /**
  39588. * Gets the image processing configuration used either in this material.
  39589. */
  39590. /**
  39591. * Sets the Default image processing configuration used either in the this material.
  39592. *
  39593. * If sets to null, the scene one is in use.
  39594. */
  39595. imageProcessingConfiguration: ImageProcessingConfiguration;
  39596. /**
  39597. * Keep track of the image processing observer to allow dispose and replace.
  39598. */
  39599. private _imageProcessingObserver;
  39600. /**
  39601. * Attaches a new image processing configuration to the PBR Material.
  39602. * @param configuration
  39603. */
  39604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39605. /**
  39606. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39607. */
  39608. /**
  39609. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39610. */
  39611. colorCurves: Nullable<ColorCurves>;
  39612. /**
  39613. * Gets wether the color curves effect is enabled.
  39614. */
  39615. /**
  39616. * Sets wether the color curves effect is enabled.
  39617. */
  39618. colorCurvesEnabled: boolean;
  39619. /**
  39620. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39621. */
  39622. /**
  39623. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39624. */
  39625. colorGradingTexture: Nullable<BaseTexture>;
  39626. /**
  39627. * Gets wether the color grading effect is enabled.
  39628. */
  39629. /**
  39630. * Gets wether the color grading effect is enabled.
  39631. */
  39632. colorGradingEnabled: boolean;
  39633. /**
  39634. * Gets exposure used in the effect.
  39635. */
  39636. /**
  39637. * Sets exposure used in the effect.
  39638. */
  39639. exposure: number;
  39640. /**
  39641. * Gets wether tonemapping is enabled or not.
  39642. */
  39643. /**
  39644. * Sets wether tonemapping is enabled or not
  39645. */
  39646. toneMappingEnabled: boolean;
  39647. /**
  39648. * Gets the type of tone mapping effect.
  39649. */
  39650. /**
  39651. * Sets the type of tone mapping effect.
  39652. */
  39653. toneMappingType: number;
  39654. /**
  39655. * Gets contrast used in the effect.
  39656. */
  39657. /**
  39658. * Sets contrast used in the effect.
  39659. */
  39660. contrast: number;
  39661. /**
  39662. * Gets Vignette stretch size.
  39663. */
  39664. /**
  39665. * Sets Vignette stretch size.
  39666. */
  39667. vignetteStretch: number;
  39668. /**
  39669. * Gets Vignette centre X Offset.
  39670. */
  39671. /**
  39672. * Sets Vignette centre X Offset.
  39673. */
  39674. vignetteCentreX: number;
  39675. /**
  39676. * Gets Vignette centre Y Offset.
  39677. */
  39678. /**
  39679. * Sets Vignette centre Y Offset.
  39680. */
  39681. vignetteCentreY: number;
  39682. /**
  39683. * Gets Vignette weight or intensity of the vignette effect.
  39684. */
  39685. /**
  39686. * Sets Vignette weight or intensity of the vignette effect.
  39687. */
  39688. vignetteWeight: number;
  39689. /**
  39690. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39691. * if vignetteEnabled is set to true.
  39692. */
  39693. /**
  39694. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39695. * if vignetteEnabled is set to true.
  39696. */
  39697. vignetteColor: Color4;
  39698. /**
  39699. * Gets Camera field of view used by the Vignette effect.
  39700. */
  39701. /**
  39702. * Sets Camera field of view used by the Vignette effect.
  39703. */
  39704. vignetteCameraFov: number;
  39705. /**
  39706. * Gets the vignette blend mode allowing different kind of effect.
  39707. */
  39708. /**
  39709. * Sets the vignette blend mode allowing different kind of effect.
  39710. */
  39711. vignetteBlendMode: number;
  39712. /**
  39713. * Gets wether the vignette effect is enabled.
  39714. */
  39715. /**
  39716. * Sets wether the vignette effect is enabled.
  39717. */
  39718. vignetteEnabled: boolean;
  39719. private _fromLinearSpace;
  39720. /**
  39721. * Gets wether the input of the processing is in Gamma or Linear Space.
  39722. */
  39723. /**
  39724. * Sets wether the input of the processing is in Gamma or Linear Space.
  39725. */
  39726. fromLinearSpace: boolean;
  39727. /**
  39728. * Defines cache preventing GC.
  39729. */
  39730. private _defines;
  39731. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39732. /**
  39733. * "ImageProcessingPostProcess"
  39734. * @returns "ImageProcessingPostProcess"
  39735. */
  39736. getClassName(): string;
  39737. protected _updateParameters(): void;
  39738. dispose(camera?: Camera): void;
  39739. }
  39740. }
  39741. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39742. import { Scene } from "babylonjs/scene";
  39743. import { Color3 } from "babylonjs/Maths/math";
  39744. import { Mesh } from "babylonjs/Meshes/mesh";
  39745. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39746. /**
  39747. * Class containing static functions to help procedurally build meshes
  39748. */
  39749. export class GroundBuilder {
  39750. /**
  39751. * Creates a ground mesh
  39752. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39753. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39755. * @param name defines the name of the mesh
  39756. * @param options defines the options used to create the mesh
  39757. * @param scene defines the hosting scene
  39758. * @returns the ground mesh
  39759. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39760. */
  39761. static CreateGround(name: string, options: {
  39762. width?: number;
  39763. height?: number;
  39764. subdivisions?: number;
  39765. subdivisionsX?: number;
  39766. subdivisionsY?: number;
  39767. updatable?: boolean;
  39768. }, scene: any): Mesh;
  39769. /**
  39770. * Creates a tiled ground mesh
  39771. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39772. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39773. * * 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
  39774. * * 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
  39775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39776. * @param name defines the name of the mesh
  39777. * @param options defines the options used to create the mesh
  39778. * @param scene defines the hosting scene
  39779. * @returns the tiled ground mesh
  39780. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39781. */
  39782. static CreateTiledGround(name: string, options: {
  39783. xmin: number;
  39784. zmin: number;
  39785. xmax: number;
  39786. zmax: number;
  39787. subdivisions?: {
  39788. w: number;
  39789. h: number;
  39790. };
  39791. precision?: {
  39792. w: number;
  39793. h: number;
  39794. };
  39795. updatable?: boolean;
  39796. }, scene: Scene): Mesh;
  39797. /**
  39798. * Creates a ground mesh from a height map
  39799. * * The parameter `url` sets the URL of the height map image resource.
  39800. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39801. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39802. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39803. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39804. * * 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.
  39805. * * 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).
  39806. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39808. * @param name defines the name of the mesh
  39809. * @param url defines the url to the height map
  39810. * @param options defines the options used to create the mesh
  39811. * @param scene defines the hosting scene
  39812. * @returns the ground mesh
  39813. * @see https://doc.babylonjs.com/babylon101/height_map
  39814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39815. */
  39816. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39817. width?: number;
  39818. height?: number;
  39819. subdivisions?: number;
  39820. minHeight?: number;
  39821. maxHeight?: number;
  39822. colorFilter?: Color3;
  39823. alphaFilter?: number;
  39824. updatable?: boolean;
  39825. onReady?: (mesh: GroundMesh) => void;
  39826. }, scene: Scene): GroundMesh;
  39827. }
  39828. }
  39829. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39830. import { Vector4 } from "babylonjs/Maths/math";
  39831. import { Mesh } from "babylonjs/Meshes/mesh";
  39832. /**
  39833. * Class containing static functions to help procedurally build meshes
  39834. */
  39835. export class TorusBuilder {
  39836. /**
  39837. * Creates a torus mesh
  39838. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39839. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39840. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39844. * @param name defines the name of the mesh
  39845. * @param options defines the options used to create the mesh
  39846. * @param scene defines the hosting scene
  39847. * @returns the torus mesh
  39848. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39849. */
  39850. static CreateTorus(name: string, options: {
  39851. diameter?: number;
  39852. thickness?: number;
  39853. tessellation?: number;
  39854. updatable?: boolean;
  39855. sideOrientation?: number;
  39856. frontUVs?: Vector4;
  39857. backUVs?: Vector4;
  39858. }, scene: any): Mesh;
  39859. }
  39860. }
  39861. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39862. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39863. import { Mesh } from "babylonjs/Meshes/mesh";
  39864. /**
  39865. * Class containing static functions to help procedurally build meshes
  39866. */
  39867. export class CylinderBuilder {
  39868. /**
  39869. * Creates a cylinder or a cone mesh
  39870. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39871. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39872. * * 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.
  39873. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39874. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39875. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39876. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39877. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39878. * * 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).
  39879. * * 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
  39880. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39881. * * 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
  39882. * * 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.
  39883. * * If `enclose` is false, a ring surface is one element.
  39884. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39885. * * 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
  39886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39889. * @param name defines the name of the mesh
  39890. * @param options defines the options used to create the mesh
  39891. * @param scene defines the hosting scene
  39892. * @returns the cylinder mesh
  39893. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39894. */
  39895. static CreateCylinder(name: string, options: {
  39896. height?: number;
  39897. diameterTop?: number;
  39898. diameterBottom?: number;
  39899. diameter?: number;
  39900. tessellation?: number;
  39901. subdivisions?: number;
  39902. arc?: number;
  39903. faceColors?: Color4[];
  39904. faceUV?: Vector4[];
  39905. updatable?: boolean;
  39906. hasRings?: boolean;
  39907. enclose?: boolean;
  39908. sideOrientation?: number;
  39909. frontUVs?: Vector4;
  39910. backUVs?: Vector4;
  39911. }, scene: any): Mesh;
  39912. }
  39913. }
  39914. declare module "babylonjs/Gamepads/gamepadManager" {
  39915. import { Observable } from "babylonjs/Misc/observable";
  39916. import { Nullable } from "babylonjs/types";
  39917. import { Scene } from "babylonjs/scene";
  39918. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39919. /**
  39920. * Manager for handling gamepads
  39921. */
  39922. export class GamepadManager {
  39923. private _scene?;
  39924. private _babylonGamepads;
  39925. private _oneGamepadConnected;
  39926. /** @hidden */
  39927. _isMonitoring: boolean;
  39928. private _gamepadEventSupported;
  39929. private _gamepadSupport;
  39930. /**
  39931. * observable to be triggered when the gamepad controller has been connected
  39932. */
  39933. onGamepadConnectedObservable: Observable<Gamepad>;
  39934. /**
  39935. * observable to be triggered when the gamepad controller has been disconnected
  39936. */
  39937. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39938. private _onGamepadConnectedEvent;
  39939. private _onGamepadDisconnectedEvent;
  39940. /**
  39941. * Initializes the gamepad manager
  39942. * @param _scene BabylonJS scene
  39943. */
  39944. constructor(_scene?: Scene | undefined);
  39945. /**
  39946. * The gamepads in the game pad manager
  39947. */
  39948. readonly gamepads: Gamepad[];
  39949. /**
  39950. * Get the gamepad controllers based on type
  39951. * @param type The type of gamepad controller
  39952. * @returns Nullable gamepad
  39953. */
  39954. getGamepadByType(type?: number): Nullable<Gamepad>;
  39955. /**
  39956. * Disposes the gamepad manager
  39957. */
  39958. dispose(): void;
  39959. private _addNewGamepad;
  39960. private _startMonitoringGamepads;
  39961. private _stopMonitoringGamepads;
  39962. /** @hidden */
  39963. _checkGamepadsStatus(): void;
  39964. private _updateGamepadObjects;
  39965. }
  39966. }
  39967. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39968. import { Nullable } from "babylonjs/types";
  39969. import { Scene } from "babylonjs/scene";
  39970. import { ISceneComponent } from "babylonjs/sceneComponent";
  39971. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39972. module "babylonjs/scene" {
  39973. interface Scene {
  39974. /** @hidden */
  39975. _gamepadManager: Nullable<GamepadManager>;
  39976. /**
  39977. * Gets the gamepad manager associated with the scene
  39978. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39979. */
  39980. gamepadManager: GamepadManager;
  39981. }
  39982. }
  39983. module "babylonjs/Cameras/freeCameraInputsManager" {
  39984. /**
  39985. * Interface representing a free camera inputs manager
  39986. */
  39987. interface FreeCameraInputsManager {
  39988. /**
  39989. * Adds gamepad input support to the FreeCameraInputsManager.
  39990. * @returns the FreeCameraInputsManager
  39991. */
  39992. addGamepad(): FreeCameraInputsManager;
  39993. }
  39994. }
  39995. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39996. /**
  39997. * Interface representing an arc rotate camera inputs manager
  39998. */
  39999. interface ArcRotateCameraInputsManager {
  40000. /**
  40001. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40002. * @returns the camera inputs manager
  40003. */
  40004. addGamepad(): ArcRotateCameraInputsManager;
  40005. }
  40006. }
  40007. /**
  40008. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40009. */
  40010. export class GamepadSystemSceneComponent implements ISceneComponent {
  40011. /**
  40012. * The component name helpfull to identify the component in the list of scene components.
  40013. */
  40014. readonly name: string;
  40015. /**
  40016. * The scene the component belongs to.
  40017. */
  40018. scene: Scene;
  40019. /**
  40020. * Creates a new instance of the component for the given scene
  40021. * @param scene Defines the scene to register the component in
  40022. */
  40023. constructor(scene: Scene);
  40024. /**
  40025. * Registers the component in a given scene
  40026. */
  40027. register(): void;
  40028. /**
  40029. * Rebuilds the elements related to this component in case of
  40030. * context lost for instance.
  40031. */
  40032. rebuild(): void;
  40033. /**
  40034. * Disposes the component and the associated ressources
  40035. */
  40036. dispose(): void;
  40037. private _beforeCameraUpdate;
  40038. }
  40039. }
  40040. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40041. import { Observable } from "babylonjs/Misc/observable";
  40042. import { Nullable } from "babylonjs/types";
  40043. import { Camera } from "babylonjs/Cameras/camera";
  40044. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40045. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40046. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40047. import { Scene } from "babylonjs/scene";
  40048. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40049. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40051. import { Mesh } from "babylonjs/Meshes/mesh";
  40052. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40053. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40054. import "babylonjs/Meshes/Builders/groundBuilder";
  40055. import "babylonjs/Meshes/Builders/torusBuilder";
  40056. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40057. import "babylonjs/Gamepads/gamepadSceneComponent";
  40058. import "babylonjs/Animations/animatable";
  40059. /**
  40060. * Options to modify the vr teleportation behavior.
  40061. */
  40062. export interface VRTeleportationOptions {
  40063. /**
  40064. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40065. */
  40066. floorMeshName?: string;
  40067. /**
  40068. * A list of meshes to be used as the teleportation floor. (default: empty)
  40069. */
  40070. floorMeshes?: Mesh[];
  40071. }
  40072. /**
  40073. * Options to modify the vr experience helper's behavior.
  40074. */
  40075. export interface VRExperienceHelperOptions extends WebVROptions {
  40076. /**
  40077. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40078. */
  40079. createDeviceOrientationCamera?: boolean;
  40080. /**
  40081. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40082. */
  40083. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40084. /**
  40085. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40086. */
  40087. laserToggle?: boolean;
  40088. /**
  40089. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40090. */
  40091. floorMeshes?: Mesh[];
  40092. /**
  40093. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40094. */
  40095. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40096. }
  40097. /**
  40098. * Event containing information after VR has been entered
  40099. */
  40100. export class OnAfterEnteringVRObservableEvent {
  40101. /**
  40102. * If entering vr was successful
  40103. */
  40104. success: boolean;
  40105. }
  40106. /**
  40107. * Helps to quickly add VR support to an existing scene.
  40108. * See http://doc.babylonjs.com/how_to/webvr_helper
  40109. */
  40110. export class VRExperienceHelper {
  40111. /** Options to modify the vr experience helper's behavior. */
  40112. webVROptions: VRExperienceHelperOptions;
  40113. private _scene;
  40114. private _position;
  40115. private _btnVR;
  40116. private _btnVRDisplayed;
  40117. private _webVRsupported;
  40118. private _webVRready;
  40119. private _webVRrequesting;
  40120. private _webVRpresenting;
  40121. private _hasEnteredVR;
  40122. private _fullscreenVRpresenting;
  40123. private _canvas;
  40124. private _webVRCamera;
  40125. private _vrDeviceOrientationCamera;
  40126. private _deviceOrientationCamera;
  40127. private _existingCamera;
  40128. private _onKeyDown;
  40129. private _onVrDisplayPresentChange;
  40130. private _onVRDisplayChanged;
  40131. private _onVRRequestPresentStart;
  40132. private _onVRRequestPresentComplete;
  40133. /**
  40134. * Observable raised right before entering VR.
  40135. */
  40136. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40137. /**
  40138. * Observable raised when entering VR has completed.
  40139. */
  40140. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40141. /**
  40142. * Observable raised when exiting VR.
  40143. */
  40144. onExitingVRObservable: Observable<VRExperienceHelper>;
  40145. /**
  40146. * Observable raised when controller mesh is loaded.
  40147. */
  40148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40149. /** Return this.onEnteringVRObservable
  40150. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40151. */
  40152. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40153. /** Return this.onExitingVRObservable
  40154. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40155. */
  40156. readonly onExitingVR: Observable<VRExperienceHelper>;
  40157. /** Return this.onControllerMeshLoadedObservable
  40158. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40159. */
  40160. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40161. private _rayLength;
  40162. private _useCustomVRButton;
  40163. private _teleportationRequested;
  40164. private _teleportActive;
  40165. private _floorMeshName;
  40166. private _floorMeshesCollection;
  40167. private _rotationAllowed;
  40168. private _teleportBackwardsVector;
  40169. private _teleportationTarget;
  40170. private _isDefaultTeleportationTarget;
  40171. private _postProcessMove;
  40172. private _teleportationFillColor;
  40173. private _teleportationBorderColor;
  40174. private _rotationAngle;
  40175. private _haloCenter;
  40176. private _cameraGazer;
  40177. private _padSensibilityUp;
  40178. private _padSensibilityDown;
  40179. private _leftController;
  40180. private _rightController;
  40181. /**
  40182. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40183. */
  40184. onNewMeshSelected: Observable<AbstractMesh>;
  40185. /**
  40186. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40187. */
  40188. onNewMeshPicked: Observable<PickingInfo>;
  40189. private _circleEase;
  40190. /**
  40191. * Observable raised before camera teleportation
  40192. */
  40193. onBeforeCameraTeleport: Observable<Vector3>;
  40194. /**
  40195. * Observable raised after camera teleportation
  40196. */
  40197. onAfterCameraTeleport: Observable<Vector3>;
  40198. /**
  40199. * Observable raised when current selected mesh gets unselected
  40200. */
  40201. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40202. private _raySelectionPredicate;
  40203. /**
  40204. * To be optionaly changed by user to define custom ray selection
  40205. */
  40206. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40207. /**
  40208. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40209. */
  40210. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40211. /**
  40212. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40213. */
  40214. teleportationEnabled: boolean;
  40215. private _defaultHeight;
  40216. private _teleportationInitialized;
  40217. private _interactionsEnabled;
  40218. private _interactionsRequested;
  40219. private _displayGaze;
  40220. private _displayLaserPointer;
  40221. /**
  40222. * The mesh used to display where the user is going to teleport.
  40223. */
  40224. /**
  40225. * Sets the mesh to be used to display where the user is going to teleport.
  40226. */
  40227. teleportationTarget: Mesh;
  40228. /**
  40229. * 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
  40230. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40231. * See http://doc.babylonjs.com/resources/baking_transformations
  40232. */
  40233. gazeTrackerMesh: Mesh;
  40234. /**
  40235. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40236. */
  40237. updateGazeTrackerScale: boolean;
  40238. /**
  40239. * If the gaze trackers color should be updated when selecting meshes
  40240. */
  40241. updateGazeTrackerColor: boolean;
  40242. /**
  40243. * The gaze tracking mesh corresponding to the left controller
  40244. */
  40245. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40246. /**
  40247. * The gaze tracking mesh corresponding to the right controller
  40248. */
  40249. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40250. /**
  40251. * If the ray of the gaze should be displayed.
  40252. */
  40253. /**
  40254. * Sets if the ray of the gaze should be displayed.
  40255. */
  40256. displayGaze: boolean;
  40257. /**
  40258. * If the ray of the LaserPointer should be displayed.
  40259. */
  40260. /**
  40261. * Sets if the ray of the LaserPointer should be displayed.
  40262. */
  40263. displayLaserPointer: boolean;
  40264. /**
  40265. * The deviceOrientationCamera used as the camera when not in VR.
  40266. */
  40267. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40268. /**
  40269. * Based on the current WebVR support, returns the current VR camera used.
  40270. */
  40271. readonly currentVRCamera: Nullable<Camera>;
  40272. /**
  40273. * The webVRCamera which is used when in VR.
  40274. */
  40275. readonly webVRCamera: WebVRFreeCamera;
  40276. /**
  40277. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40278. */
  40279. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40280. private readonly _teleportationRequestInitiated;
  40281. /**
  40282. * Defines wether or not Pointer lock should be requested when switching to
  40283. * full screen.
  40284. */
  40285. requestPointerLockOnFullScreen: boolean;
  40286. /**
  40287. * Instantiates a VRExperienceHelper.
  40288. * Helps to quickly add VR support to an existing scene.
  40289. * @param scene The scene the VRExperienceHelper belongs to.
  40290. * @param webVROptions Options to modify the vr experience helper's behavior.
  40291. */
  40292. constructor(scene: Scene,
  40293. /** Options to modify the vr experience helper's behavior. */
  40294. webVROptions?: VRExperienceHelperOptions);
  40295. private _onDefaultMeshLoaded;
  40296. private _onResize;
  40297. private _onFullscreenChange;
  40298. /**
  40299. * Gets a value indicating if we are currently in VR mode.
  40300. */
  40301. readonly isInVRMode: boolean;
  40302. private onVrDisplayPresentChange;
  40303. private onVRDisplayChanged;
  40304. private moveButtonToBottomRight;
  40305. private displayVRButton;
  40306. private updateButtonVisibility;
  40307. private _cachedAngularSensibility;
  40308. /**
  40309. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40310. * Otherwise, will use the fullscreen API.
  40311. */
  40312. enterVR(): void;
  40313. /**
  40314. * Attempt to exit VR, or fullscreen.
  40315. */
  40316. exitVR(): void;
  40317. /**
  40318. * The position of the vr experience helper.
  40319. */
  40320. /**
  40321. * Sets the position of the vr experience helper.
  40322. */
  40323. position: Vector3;
  40324. /**
  40325. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40326. */
  40327. enableInteractions(): void;
  40328. private readonly _noControllerIsActive;
  40329. private beforeRender;
  40330. private _isTeleportationFloor;
  40331. /**
  40332. * Adds a floor mesh to be used for teleportation.
  40333. * @param floorMesh the mesh to be used for teleportation.
  40334. */
  40335. addFloorMesh(floorMesh: Mesh): void;
  40336. /**
  40337. * Removes a floor mesh from being used for teleportation.
  40338. * @param floorMesh the mesh to be removed.
  40339. */
  40340. removeFloorMesh(floorMesh: Mesh): void;
  40341. /**
  40342. * Enables interactions and teleportation using the VR controllers and gaze.
  40343. * @param vrTeleportationOptions options to modify teleportation behavior.
  40344. */
  40345. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40346. private _onNewGamepadConnected;
  40347. private _tryEnableInteractionOnController;
  40348. private _onNewGamepadDisconnected;
  40349. private _enableInteractionOnController;
  40350. private _checkTeleportWithRay;
  40351. private _checkRotate;
  40352. private _checkTeleportBackwards;
  40353. private _enableTeleportationOnController;
  40354. private _createTeleportationCircles;
  40355. private _displayTeleportationTarget;
  40356. private _hideTeleportationTarget;
  40357. private _rotateCamera;
  40358. private _moveTeleportationSelectorTo;
  40359. private _workingVector;
  40360. private _workingQuaternion;
  40361. private _workingMatrix;
  40362. /**
  40363. * Teleports the users feet to the desired location
  40364. * @param location The location where the user's feet should be placed
  40365. */
  40366. teleportCamera(location: Vector3): void;
  40367. private _convertNormalToDirectionOfRay;
  40368. private _castRayAndSelectObject;
  40369. private _notifySelectedMeshUnselected;
  40370. /**
  40371. * Sets the color of the laser ray from the vr controllers.
  40372. * @param color new color for the ray.
  40373. */
  40374. changeLaserColor(color: Color3): void;
  40375. /**
  40376. * Sets the color of the ray from the vr headsets gaze.
  40377. * @param color new color for the ray.
  40378. */
  40379. changeGazeColor(color: Color3): void;
  40380. /**
  40381. * Exits VR and disposes of the vr experience helper
  40382. */
  40383. dispose(): void;
  40384. /**
  40385. * Gets the name of the VRExperienceHelper class
  40386. * @returns "VRExperienceHelper"
  40387. */
  40388. getClassName(): string;
  40389. }
  40390. }
  40391. declare module "babylonjs/Cameras/VR/index" {
  40392. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40393. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40394. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40395. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40396. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40397. export * from "babylonjs/Cameras/VR/webVRCamera";
  40398. }
  40399. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40400. import { Observable } from "babylonjs/Misc/observable";
  40401. import { Nullable } from "babylonjs/types";
  40402. import { IDisposable, Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math";
  40404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40405. import { Ray } from "babylonjs/Culling/ray";
  40406. /**
  40407. * Manages an XRSession
  40408. * @see https://doc.babylonjs.com/how_to/webxr
  40409. */
  40410. export class WebXRSessionManager implements IDisposable {
  40411. private scene;
  40412. /**
  40413. * Fires every time a new xrFrame arrives which can be used to update the camera
  40414. */
  40415. onXRFrameObservable: Observable<any>;
  40416. /**
  40417. * Fires when the xr session is ended either by the device or manually done
  40418. */
  40419. onXRSessionEnded: Observable<any>;
  40420. /** @hidden */
  40421. _xrSession: XRSession;
  40422. /** @hidden */
  40423. _frameOfReference: XRFrameOfReference;
  40424. /** @hidden */
  40425. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40426. /** @hidden */
  40427. _currentXRFrame: Nullable<XRFrame>;
  40428. private _xrNavigator;
  40429. private _xrDevice;
  40430. private _tmpMatrix;
  40431. /**
  40432. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40433. * @param scene The scene which the session should be created for
  40434. */
  40435. constructor(scene: Scene);
  40436. /**
  40437. * Initializes the manager
  40438. * After initialization enterXR can be called to start an XR session
  40439. * @returns Promise which resolves after it is initialized
  40440. */
  40441. initializeAsync(): Promise<void>;
  40442. /**
  40443. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40444. * @param sessionCreationOptions xr options to create the session with
  40445. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40446. * @returns Promise which resolves after it enters XR
  40447. */
  40448. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40449. /**
  40450. * Stops the xrSession and restores the renderloop
  40451. * @returns Promise which resolves after it exits XR
  40452. */
  40453. exitXRAsync(): Promise<void>;
  40454. /**
  40455. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40456. * @param ray ray to cast into the environment
  40457. * @returns Promise which resolves with a collision point in the environment if it exists
  40458. */
  40459. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40460. /**
  40461. * Checks if a session would be supported for the creation options specified
  40462. * @param options creation options to check if they are supported
  40463. * @returns true if supported
  40464. */
  40465. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40466. /**
  40467. * @hidden
  40468. * Converts the render layer of xrSession to a render target
  40469. * @param session session to create render target for
  40470. * @param scene scene the new render target should be created for
  40471. */
  40472. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40473. /**
  40474. * Disposes of the session manager
  40475. */
  40476. dispose(): void;
  40477. }
  40478. }
  40479. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40480. import { Scene } from "babylonjs/scene";
  40481. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40482. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40483. /**
  40484. * WebXR Camera which holds the views for the xrSession
  40485. * @see https://doc.babylonjs.com/how_to/webxr
  40486. */
  40487. export class WebXRCamera extends FreeCamera {
  40488. private static _TmpMatrix;
  40489. /**
  40490. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40491. * @param name the name of the camera
  40492. * @param scene the scene to add the camera to
  40493. */
  40494. constructor(name: string, scene: Scene);
  40495. private _updateNumberOfRigCameras;
  40496. /** @hidden */
  40497. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40498. /**
  40499. * Updates the cameras position from the current pose information of the XR session
  40500. * @param xrSessionManager the session containing pose information
  40501. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40502. */
  40503. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40504. }
  40505. }
  40506. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40507. import { Nullable } from "babylonjs/types";
  40508. import { Observable } from "babylonjs/Misc/observable";
  40509. import { IDisposable, Scene } from "babylonjs/scene";
  40510. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40512. import { Ray } from "babylonjs/Culling/ray";
  40513. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40514. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40515. /**
  40516. * States of the webXR experience
  40517. */
  40518. export enum WebXRState {
  40519. /**
  40520. * Transitioning to being in XR mode
  40521. */
  40522. ENTERING_XR = 0,
  40523. /**
  40524. * Transitioning to non XR mode
  40525. */
  40526. EXITING_XR = 1,
  40527. /**
  40528. * In XR mode and presenting
  40529. */
  40530. IN_XR = 2,
  40531. /**
  40532. * Not entered XR mode
  40533. */
  40534. NOT_IN_XR = 3
  40535. }
  40536. /**
  40537. * Helper class used to enable XR
  40538. * @see https://doc.babylonjs.com/how_to/webxr
  40539. */
  40540. export class WebXRExperienceHelper implements IDisposable {
  40541. private scene;
  40542. /**
  40543. * 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
  40544. */
  40545. container: AbstractMesh;
  40546. /**
  40547. * Camera used to render xr content
  40548. */
  40549. camera: WebXRCamera;
  40550. /**
  40551. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40552. */
  40553. state: WebXRState;
  40554. private _setState;
  40555. private static _TmpVector;
  40556. /**
  40557. * Fires when the state of the experience helper has changed
  40558. */
  40559. onStateChangedObservable: Observable<WebXRState>;
  40560. /** @hidden */
  40561. _sessionManager: WebXRSessionManager;
  40562. private _nonVRCamera;
  40563. private _originalSceneAutoClear;
  40564. private _supported;
  40565. /**
  40566. * Creates the experience helper
  40567. * @param scene the scene to attach the experience helper to
  40568. * @returns a promise for the experience helper
  40569. */
  40570. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40571. /**
  40572. * Creates a WebXRExperienceHelper
  40573. * @param scene The scene the helper should be created in
  40574. */
  40575. private constructor();
  40576. /**
  40577. * Exits XR mode and returns the scene to its original state
  40578. * @returns promise that resolves after xr mode has exited
  40579. */
  40580. exitXRAsync(): Promise<void>;
  40581. /**
  40582. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40583. * @param sessionCreationOptions options for the XR session
  40584. * @param frameOfReference frame of reference of the XR session
  40585. * @returns promise that resolves after xr mode has entered
  40586. */
  40587. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40588. /**
  40589. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40590. * @param ray ray to cast into the environment
  40591. * @returns Promise which resolves with a collision point in the environment if it exists
  40592. */
  40593. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40594. /**
  40595. * Updates the global position of the camera by moving the camera's container
  40596. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40597. * @param position The desired global position of the camera
  40598. */
  40599. setPositionOfCameraUsingContainer(position: Vector3): void;
  40600. /**
  40601. * Rotates the xr camera by rotating the camera's container around the camera's position
  40602. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40603. * @param rotation the desired quaternion rotation to apply to the camera
  40604. */
  40605. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40606. /**
  40607. * Checks if the creation options are supported by the xr session
  40608. * @param options creation options
  40609. * @returns true if supported
  40610. */
  40611. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40612. /**
  40613. * Disposes of the experience helper
  40614. */
  40615. dispose(): void;
  40616. }
  40617. }
  40618. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40619. import { Nullable } from "babylonjs/types";
  40620. import { Observable } from "babylonjs/Misc/observable";
  40621. import { IDisposable, Scene } from "babylonjs/scene";
  40622. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40623. /**
  40624. * Button which can be used to enter a different mode of XR
  40625. */
  40626. export class WebXREnterExitUIButton {
  40627. /** button element */
  40628. element: HTMLElement;
  40629. /** XR initialization options for the button */
  40630. initializationOptions: XRSessionCreationOptions;
  40631. /**
  40632. * Creates a WebXREnterExitUIButton
  40633. * @param element button element
  40634. * @param initializationOptions XR initialization options for the button
  40635. */
  40636. constructor(
  40637. /** button element */
  40638. element: HTMLElement,
  40639. /** XR initialization options for the button */
  40640. initializationOptions: XRSessionCreationOptions);
  40641. /**
  40642. * Overwritable function which can be used to update the button's visuals when the state changes
  40643. * @param activeButton the current active button in the UI
  40644. */
  40645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40646. }
  40647. /**
  40648. * Options to create the webXR UI
  40649. */
  40650. export class WebXREnterExitUIOptions {
  40651. /**
  40652. * Context to enter xr with
  40653. */
  40654. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40655. /**
  40656. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40657. */
  40658. customButtons?: Array<WebXREnterExitUIButton>;
  40659. }
  40660. /**
  40661. * UI to allow the user to enter/exit XR mode
  40662. */
  40663. export class WebXREnterExitUI implements IDisposable {
  40664. private scene;
  40665. private _overlay;
  40666. private _buttons;
  40667. private _activeButton;
  40668. /**
  40669. * Fired every time the active button is changed.
  40670. *
  40671. * When xr is entered via a button that launches xr that button will be the callback parameter
  40672. *
  40673. * When exiting xr the callback parameter will be null)
  40674. */
  40675. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40676. /**
  40677. * Creates UI to allow the user to enter/exit XR mode
  40678. * @param scene the scene to add the ui to
  40679. * @param helper the xr experience helper to enter/exit xr with
  40680. * @param options options to configure the UI
  40681. * @returns the created ui
  40682. */
  40683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40684. private constructor();
  40685. private _updateButtons;
  40686. /**
  40687. * Disposes of the object
  40688. */
  40689. dispose(): void;
  40690. }
  40691. }
  40692. declare module "babylonjs/Cameras/XR/webXRInput" {
  40693. import { IDisposable, Scene } from "babylonjs/scene";
  40694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40695. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40696. /**
  40697. * Represents an XR input
  40698. */
  40699. export class WebXRController {
  40700. /**
  40701. * 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
  40702. */
  40703. grip?: AbstractMesh;
  40704. /**
  40705. * Pointer which can be used to select objects or attach a visible laser to
  40706. */
  40707. pointer: AbstractMesh;
  40708. /**
  40709. * Creates the controller
  40710. * @see https://doc.babylonjs.com/how_to/webxr
  40711. * @param scene the scene which the controller should be associated to
  40712. */
  40713. constructor(scene: Scene);
  40714. /**
  40715. * Disposes of the object
  40716. */
  40717. dispose(): void;
  40718. }
  40719. /**
  40720. * XR input used to track XR inputs such as controllers/rays
  40721. */
  40722. export class WebXRInput implements IDisposable {
  40723. private helper;
  40724. /**
  40725. * XR controllers being tracked
  40726. */
  40727. controllers: Array<WebXRController>;
  40728. private _tmpMatrix;
  40729. private _frameObserver;
  40730. /**
  40731. * Initializes the WebXRInput
  40732. * @param helper experience helper which the input should be created for
  40733. */
  40734. constructor(helper: WebXRExperienceHelper);
  40735. /**
  40736. * Disposes of the object
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40742. import { Nullable } from "babylonjs/types";
  40743. import { IDisposable } from "babylonjs/scene";
  40744. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40745. /**
  40746. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40747. */
  40748. export class WebXRManagedOutputCanvas implements IDisposable {
  40749. private _canvas;
  40750. /**
  40751. * xrpresent context of the canvas which can be used to display/mirror xr content
  40752. */
  40753. canvasContext: Nullable<WebGLRenderingContext>;
  40754. /**
  40755. * Initializes the canvas to be added/removed upon entering/exiting xr
  40756. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40757. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40758. */
  40759. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40760. /**
  40761. * Disposes of the object
  40762. */
  40763. dispose(): void;
  40764. private _setManagedOutputCanvas;
  40765. private _addCanvas;
  40766. private _removeCanvas;
  40767. }
  40768. }
  40769. declare module "babylonjs/Cameras/XR/index" {
  40770. export * from "babylonjs/Cameras/XR/webXRCamera";
  40771. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40772. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40773. export * from "babylonjs/Cameras/XR/webXRInput";
  40774. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40775. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40776. }
  40777. declare module "babylonjs/Cameras/RigModes/index" {
  40778. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40779. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40780. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40781. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40782. }
  40783. declare module "babylonjs/Cameras/index" {
  40784. export * from "babylonjs/Cameras/Inputs/index";
  40785. export * from "babylonjs/Cameras/cameraInputsManager";
  40786. export * from "babylonjs/Cameras/camera";
  40787. export * from "babylonjs/Cameras/targetCamera";
  40788. export * from "babylonjs/Cameras/freeCamera";
  40789. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40790. export * from "babylonjs/Cameras/touchCamera";
  40791. export * from "babylonjs/Cameras/arcRotateCamera";
  40792. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40793. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40794. export * from "babylonjs/Cameras/flyCamera";
  40795. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40796. export * from "babylonjs/Cameras/followCamera";
  40797. export * from "babylonjs/Cameras/gamepadCamera";
  40798. export * from "babylonjs/Cameras/Stereoscopic/index";
  40799. export * from "babylonjs/Cameras/universalCamera";
  40800. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40801. export * from "babylonjs/Cameras/VR/index";
  40802. export * from "babylonjs/Cameras/XR/index";
  40803. export * from "babylonjs/Cameras/RigModes/index";
  40804. }
  40805. declare module "babylonjs/Collisions/index" {
  40806. export * from "babylonjs/Collisions/collider";
  40807. export * from "babylonjs/Collisions/collisionCoordinator";
  40808. export * from "babylonjs/Collisions/pickingInfo";
  40809. export * from "babylonjs/Collisions/intersectionInfo";
  40810. }
  40811. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40812. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40813. import { Vector3, Plane } from "babylonjs/Maths/math";
  40814. import { Ray } from "babylonjs/Culling/ray";
  40815. /**
  40816. * Contains an array of blocks representing the octree
  40817. */
  40818. export interface IOctreeContainer<T> {
  40819. /**
  40820. * Blocks within the octree
  40821. */
  40822. blocks: Array<OctreeBlock<T>>;
  40823. }
  40824. /**
  40825. * Class used to store a cell in an octree
  40826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40827. */
  40828. export class OctreeBlock<T> {
  40829. /**
  40830. * Gets the content of the current block
  40831. */
  40832. entries: T[];
  40833. /**
  40834. * Gets the list of block children
  40835. */
  40836. blocks: Array<OctreeBlock<T>>;
  40837. private _depth;
  40838. private _maxDepth;
  40839. private _capacity;
  40840. private _minPoint;
  40841. private _maxPoint;
  40842. private _boundingVectors;
  40843. private _creationFunc;
  40844. /**
  40845. * Creates a new block
  40846. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40847. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40848. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40849. * @param depth defines the current depth of this block in the octree
  40850. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40851. * @param creationFunc defines a callback to call when an element is added to the block
  40852. */
  40853. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40854. /**
  40855. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40856. */
  40857. readonly capacity: number;
  40858. /**
  40859. * Gets the minimum vector (in world space) of the block's bounding box
  40860. */
  40861. readonly minPoint: Vector3;
  40862. /**
  40863. * Gets the maximum vector (in world space) of the block's bounding box
  40864. */
  40865. readonly maxPoint: Vector3;
  40866. /**
  40867. * Add a new element to this block
  40868. * @param entry defines the element to add
  40869. */
  40870. addEntry(entry: T): void;
  40871. /**
  40872. * Remove an element from this block
  40873. * @param entry defines the element to remove
  40874. */
  40875. removeEntry(entry: T): void;
  40876. /**
  40877. * Add an array of elements to this block
  40878. * @param entries defines the array of elements to add
  40879. */
  40880. addEntries(entries: T[]): void;
  40881. /**
  40882. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40883. * @param frustumPlanes defines the frustum planes to test
  40884. * @param selection defines the array to store current content if selection is positive
  40885. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40886. */
  40887. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40888. /**
  40889. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40890. * @param sphereCenter defines the bounding sphere center
  40891. * @param sphereRadius defines the bounding sphere radius
  40892. * @param selection defines the array to store current content if selection is positive
  40893. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40894. */
  40895. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40896. /**
  40897. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40898. * @param ray defines the ray to test with
  40899. * @param selection defines the array to store current content if selection is positive
  40900. */
  40901. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40902. /**
  40903. * Subdivide the content into child blocks (this block will then be empty)
  40904. */
  40905. createInnerBlocks(): void;
  40906. /**
  40907. * @hidden
  40908. */
  40909. 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;
  40910. }
  40911. }
  40912. declare module "babylonjs/Culling/Octrees/octree" {
  40913. import { SmartArray } from "babylonjs/Misc/smartArray";
  40914. import { Vector3, Plane } from "babylonjs/Maths/math";
  40915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40917. import { Ray } from "babylonjs/Culling/ray";
  40918. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40919. /**
  40920. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40921. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40922. */
  40923. export class Octree<T> {
  40924. /** 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.) */
  40925. maxDepth: number;
  40926. /**
  40927. * Blocks within the octree containing objects
  40928. */
  40929. blocks: Array<OctreeBlock<T>>;
  40930. /**
  40931. * Content stored in the octree
  40932. */
  40933. dynamicContent: T[];
  40934. private _maxBlockCapacity;
  40935. private _selectionContent;
  40936. private _creationFunc;
  40937. /**
  40938. * Creates a octree
  40939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40940. * @param creationFunc function to be used to instatiate the octree
  40941. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40942. * @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.)
  40943. */
  40944. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40945. /** 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.) */
  40946. maxDepth?: number);
  40947. /**
  40948. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40949. * @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);
  40950. * @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);
  40951. * @param entries meshes to be added to the octree blocks
  40952. */
  40953. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40954. /**
  40955. * Adds a mesh to the octree
  40956. * @param entry Mesh to add to the octree
  40957. */
  40958. addMesh(entry: T): void;
  40959. /**
  40960. * Remove an element from the octree
  40961. * @param entry defines the element to remove
  40962. */
  40963. removeMesh(entry: T): void;
  40964. /**
  40965. * Selects an array of meshes within the frustum
  40966. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40967. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40968. * @returns array of meshes within the frustum
  40969. */
  40970. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40971. /**
  40972. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40973. * @param sphereCenter defines the bounding sphere center
  40974. * @param sphereRadius defines the bounding sphere radius
  40975. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40976. * @returns an array of objects that intersect the sphere
  40977. */
  40978. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40979. /**
  40980. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40981. * @param ray defines the ray to test with
  40982. * @returns array of intersected objects
  40983. */
  40984. intersectsRay(ray: Ray): SmartArray<T>;
  40985. /**
  40986. * Adds a mesh into the octree block if it intersects the block
  40987. */
  40988. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40989. /**
  40990. * Adds a submesh into the octree block if it intersects the block
  40991. */
  40992. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40993. }
  40994. }
  40995. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40996. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40997. import { Scene } from "babylonjs/scene";
  40998. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41000. import { Ray } from "babylonjs/Culling/ray";
  41001. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41002. import { Collider } from "babylonjs/Collisions/collider";
  41003. module "babylonjs/scene" {
  41004. interface Scene {
  41005. /**
  41006. * @hidden
  41007. * Backing Filed
  41008. */
  41009. _selectionOctree: Octree<AbstractMesh>;
  41010. /**
  41011. * Gets the octree used to boost mesh selection (picking)
  41012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41013. */
  41014. selectionOctree: Octree<AbstractMesh>;
  41015. /**
  41016. * Creates or updates the octree used to boost selection (picking)
  41017. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41018. * @param maxCapacity defines the maximum capacity per leaf
  41019. * @param maxDepth defines the maximum depth of the octree
  41020. * @returns an octree of AbstractMesh
  41021. */
  41022. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41023. }
  41024. }
  41025. module "babylonjs/Meshes/abstractMesh" {
  41026. interface AbstractMesh {
  41027. /**
  41028. * @hidden
  41029. * Backing Field
  41030. */
  41031. _submeshesOctree: Octree<SubMesh>;
  41032. /**
  41033. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41034. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41035. * @param maxCapacity defines the maximum size of each block (64 by default)
  41036. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41037. * @returns the new octree
  41038. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41040. */
  41041. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41042. }
  41043. }
  41044. /**
  41045. * Defines the octree scene component responsible to manage any octrees
  41046. * in a given scene.
  41047. */
  41048. export class OctreeSceneComponent {
  41049. /**
  41050. * The component name helpfull to identify the component in the list of scene components.
  41051. */
  41052. readonly name: string;
  41053. /**
  41054. * The scene the component belongs to.
  41055. */
  41056. scene: Scene;
  41057. /**
  41058. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41059. */
  41060. readonly checksIsEnabled: boolean;
  41061. /**
  41062. * Creates a new instance of the component for the given scene
  41063. * @param scene Defines the scene to register the component in
  41064. */
  41065. constructor(scene: Scene);
  41066. /**
  41067. * Registers the component in a given scene
  41068. */
  41069. register(): void;
  41070. /**
  41071. * Return the list of active meshes
  41072. * @returns the list of active meshes
  41073. */
  41074. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41075. /**
  41076. * Return the list of active sub meshes
  41077. * @param mesh The mesh to get the candidates sub meshes from
  41078. * @returns the list of active sub meshes
  41079. */
  41080. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41081. private _tempRay;
  41082. /**
  41083. * Return the list of sub meshes intersecting with a given local ray
  41084. * @param mesh defines the mesh to find the submesh for
  41085. * @param localRay defines the ray in local space
  41086. * @returns the list of intersecting sub meshes
  41087. */
  41088. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41089. /**
  41090. * Return the list of sub meshes colliding with a collider
  41091. * @param mesh defines the mesh to find the submesh for
  41092. * @param collider defines the collider to evaluate the collision against
  41093. * @returns the list of colliding sub meshes
  41094. */
  41095. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41096. /**
  41097. * Rebuilds the elements related to this component in case of
  41098. * context lost for instance.
  41099. */
  41100. rebuild(): void;
  41101. /**
  41102. * Disposes the component and the associated ressources.
  41103. */
  41104. dispose(): void;
  41105. }
  41106. }
  41107. declare module "babylonjs/Culling/Octrees/index" {
  41108. export * from "babylonjs/Culling/Octrees/octree";
  41109. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41110. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41111. }
  41112. declare module "babylonjs/Culling/index" {
  41113. export * from "babylonjs/Culling/boundingBox";
  41114. export * from "babylonjs/Culling/boundingInfo";
  41115. export * from "babylonjs/Culling/boundingSphere";
  41116. export * from "babylonjs/Culling/Octrees/index";
  41117. export * from "babylonjs/Culling/ray";
  41118. }
  41119. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41120. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41121. import { Nullable } from "babylonjs/types";
  41122. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41123. import { Scene } from "babylonjs/scene";
  41124. /**
  41125. * Class containing static functions to help procedurally build meshes
  41126. */
  41127. export class LinesBuilder {
  41128. /**
  41129. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41130. * * 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
  41131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41132. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41133. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41134. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41135. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41136. * * 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
  41137. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41140. * @param name defines the name of the new line system
  41141. * @param options defines the options used to create the line system
  41142. * @param scene defines the hosting scene
  41143. * @returns a new line system mesh
  41144. */
  41145. static CreateLineSystem(name: string, options: {
  41146. lines: Vector3[][];
  41147. updatable?: boolean;
  41148. instance?: Nullable<LinesMesh>;
  41149. colors?: Nullable<Color4[][]>;
  41150. useVertexAlpha?: boolean;
  41151. }, scene: Nullable<Scene>): LinesMesh;
  41152. /**
  41153. * Creates a line mesh
  41154. * 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
  41155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41156. * * The parameter `points` is an array successive Vector3
  41157. * * 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
  41158. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41159. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41160. * * When updating an instance, remember that only point positions can change, not the number of points
  41161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41163. * @param name defines the name of the new line system
  41164. * @param options defines the options used to create the line system
  41165. * @param scene defines the hosting scene
  41166. * @returns a new line mesh
  41167. */
  41168. static CreateLines(name: string, options: {
  41169. points: Vector3[];
  41170. updatable?: boolean;
  41171. instance?: Nullable<LinesMesh>;
  41172. colors?: Color4[];
  41173. useVertexAlpha?: boolean;
  41174. }, scene?: Nullable<Scene>): LinesMesh;
  41175. /**
  41176. * Creates a dashed line mesh
  41177. * * 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
  41178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41179. * * The parameter `points` is an array successive Vector3
  41180. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41181. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41182. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41183. * * 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
  41184. * * When updating an instance, remember that only point positions can change, not the number of points
  41185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41186. * @param name defines the name of the mesh
  41187. * @param options defines the options used to create the mesh
  41188. * @param scene defines the hosting scene
  41189. * @returns the dashed line mesh
  41190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41191. */
  41192. static CreateDashedLines(name: string, options: {
  41193. points: Vector3[];
  41194. dashSize?: number;
  41195. gapSize?: number;
  41196. dashNb?: number;
  41197. updatable?: boolean;
  41198. instance?: LinesMesh;
  41199. }, scene?: Nullable<Scene>): LinesMesh;
  41200. }
  41201. }
  41202. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41203. import { IDisposable, Scene } from "babylonjs/scene";
  41204. import { Nullable } from "babylonjs/types";
  41205. import { Observable } from "babylonjs/Misc/observable";
  41206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41207. /**
  41208. * Renders a layer on top of an existing scene
  41209. */
  41210. export class UtilityLayerRenderer implements IDisposable {
  41211. /** the original scene that will be rendered on top of */
  41212. originalScene: Scene;
  41213. private _pointerCaptures;
  41214. private _lastPointerEvents;
  41215. private static _DefaultUtilityLayer;
  41216. private static _DefaultKeepDepthUtilityLayer;
  41217. /**
  41218. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41219. */
  41220. pickUtilitySceneFirst: boolean;
  41221. /**
  41222. * 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)
  41223. */
  41224. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41225. /**
  41226. * 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)
  41227. */
  41228. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41229. /**
  41230. * The scene that is rendered on top of the original scene
  41231. */
  41232. utilityLayerScene: Scene;
  41233. /**
  41234. * If the utility layer should automatically be rendered on top of existing scene
  41235. */
  41236. shouldRender: boolean;
  41237. /**
  41238. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41239. */
  41240. onlyCheckPointerDownEvents: boolean;
  41241. /**
  41242. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41243. */
  41244. processAllEvents: boolean;
  41245. /**
  41246. * Observable raised when the pointer move from the utility layer scene to the main scene
  41247. */
  41248. onPointerOutObservable: Observable<number>;
  41249. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41250. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41251. private _afterRenderObserver;
  41252. private _sceneDisposeObserver;
  41253. private _originalPointerObserver;
  41254. /**
  41255. * Instantiates a UtilityLayerRenderer
  41256. * @param originalScene the original scene that will be rendered on top of
  41257. * @param handleEvents boolean indicating if the utility layer should handle events
  41258. */
  41259. constructor(
  41260. /** the original scene that will be rendered on top of */
  41261. originalScene: Scene, handleEvents?: boolean);
  41262. private _notifyObservers;
  41263. /**
  41264. * Renders the utility layers scene on top of the original scene
  41265. */
  41266. render(): void;
  41267. /**
  41268. * Disposes of the renderer
  41269. */
  41270. dispose(): void;
  41271. private _updateCamera;
  41272. }
  41273. }
  41274. declare module "babylonjs/Gizmos/gizmo" {
  41275. import { Nullable } from "babylonjs/types";
  41276. import { IDisposable } from "babylonjs/scene";
  41277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41278. import { Mesh } from "babylonjs/Meshes/mesh";
  41279. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41280. /**
  41281. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41282. */
  41283. export class Gizmo implements IDisposable {
  41284. /** The utility layer the gizmo will be added to */
  41285. gizmoLayer: UtilityLayerRenderer;
  41286. /**
  41287. * The root mesh of the gizmo
  41288. */
  41289. _rootMesh: Mesh;
  41290. private _attachedMesh;
  41291. /**
  41292. * Ratio for the scale of the gizmo (Default: 1)
  41293. */
  41294. scaleRatio: number;
  41295. private _tmpMatrix;
  41296. /**
  41297. * If a custom mesh has been set (Default: false)
  41298. */
  41299. protected _customMeshSet: boolean;
  41300. /**
  41301. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41302. * * When set, interactions will be enabled
  41303. */
  41304. attachedMesh: Nullable<AbstractMesh>;
  41305. /**
  41306. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41307. * @param mesh The mesh to replace the default mesh of the gizmo
  41308. */
  41309. setCustomMesh(mesh: Mesh): void;
  41310. /**
  41311. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41312. */
  41313. updateGizmoRotationToMatchAttachedMesh: boolean;
  41314. /**
  41315. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41316. */
  41317. updateGizmoPositionToMatchAttachedMesh: boolean;
  41318. /**
  41319. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41320. */
  41321. protected _updateScale: boolean;
  41322. protected _interactionsEnabled: boolean;
  41323. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41324. private _beforeRenderObserver;
  41325. /**
  41326. * Creates a gizmo
  41327. * @param gizmoLayer The utility layer the gizmo will be added to
  41328. */
  41329. constructor(
  41330. /** The utility layer the gizmo will be added to */
  41331. gizmoLayer?: UtilityLayerRenderer);
  41332. private _tempVector;
  41333. /**
  41334. * @hidden
  41335. * Updates the gizmo to match the attached mesh's position/rotation
  41336. */
  41337. protected _update(): void;
  41338. /**
  41339. * Disposes of the gizmo
  41340. */
  41341. dispose(): void;
  41342. }
  41343. }
  41344. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41345. import { Observable } from "babylonjs/Misc/observable";
  41346. import { Nullable } from "babylonjs/types";
  41347. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41350. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41352. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41353. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41354. import { Scene } from "babylonjs/scene";
  41355. /**
  41356. * Single axis drag gizmo
  41357. */
  41358. export class AxisDragGizmo extends Gizmo {
  41359. /**
  41360. * Drag behavior responsible for the gizmos dragging interactions
  41361. */
  41362. dragBehavior: PointerDragBehavior;
  41363. private _pointerObserver;
  41364. /**
  41365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41366. */
  41367. snapDistance: number;
  41368. /**
  41369. * Event that fires each time the gizmo snaps to a new location.
  41370. * * snapDistance is the the change in distance
  41371. */
  41372. onSnapObservable: Observable<{
  41373. snapDistance: number;
  41374. }>;
  41375. /** @hidden */
  41376. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41377. /** @hidden */
  41378. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41379. /**
  41380. * Creates an AxisDragGizmo
  41381. * @param gizmoLayer The utility layer the gizmo will be added to
  41382. * @param dragAxis The axis which the gizmo will be able to drag on
  41383. * @param color The color of the gizmo
  41384. */
  41385. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41386. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41387. /**
  41388. * Disposes of the gizmo
  41389. */
  41390. dispose(): void;
  41391. }
  41392. }
  41393. declare module "babylonjs/Debug/axesViewer" {
  41394. import { Vector3 } from "babylonjs/Maths/math";
  41395. import { Nullable } from "babylonjs/types";
  41396. import { Scene } from "babylonjs/scene";
  41397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41398. /**
  41399. * The Axes viewer will show 3 axes in a specific point in space
  41400. */
  41401. export class AxesViewer {
  41402. private _xAxis;
  41403. private _yAxis;
  41404. private _zAxis;
  41405. private _scaleLinesFactor;
  41406. private _instanced;
  41407. /**
  41408. * Gets the hosting scene
  41409. */
  41410. scene: Scene;
  41411. /**
  41412. * Gets or sets a number used to scale line length
  41413. */
  41414. scaleLines: number;
  41415. /** Gets the node hierarchy used to render x-axis */
  41416. readonly xAxis: TransformNode;
  41417. /** Gets the node hierarchy used to render y-axis */
  41418. readonly yAxis: TransformNode;
  41419. /** Gets the node hierarchy used to render z-axis */
  41420. readonly zAxis: TransformNode;
  41421. /**
  41422. * Creates a new AxesViewer
  41423. * @param scene defines the hosting scene
  41424. * @param scaleLines defines a number used to scale line length (1 by default)
  41425. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41426. * @param xAxis defines the node hierarchy used to render the x-axis
  41427. * @param yAxis defines the node hierarchy used to render the y-axis
  41428. * @param zAxis defines the node hierarchy used to render the z-axis
  41429. */
  41430. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41431. /**
  41432. * Force the viewer to update
  41433. * @param position defines the position of the viewer
  41434. * @param xaxis defines the x axis of the viewer
  41435. * @param yaxis defines the y axis of the viewer
  41436. * @param zaxis defines the z axis of the viewer
  41437. */
  41438. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41439. /**
  41440. * Creates an instance of this axes viewer.
  41441. * @returns a new axes viewer with instanced meshes
  41442. */
  41443. createInstance(): AxesViewer;
  41444. /** Releases resources */
  41445. dispose(): void;
  41446. private static _SetRenderingGroupId;
  41447. }
  41448. }
  41449. declare module "babylonjs/Debug/boneAxesViewer" {
  41450. import { Nullable } from "babylonjs/types";
  41451. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41452. import { Vector3 } from "babylonjs/Maths/math";
  41453. import { Mesh } from "babylonjs/Meshes/mesh";
  41454. import { Bone } from "babylonjs/Bones/bone";
  41455. import { Scene } from "babylonjs/scene";
  41456. /**
  41457. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41458. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41459. */
  41460. export class BoneAxesViewer extends AxesViewer {
  41461. /**
  41462. * Gets or sets the target mesh where to display the axes viewer
  41463. */
  41464. mesh: Nullable<Mesh>;
  41465. /**
  41466. * Gets or sets the target bone where to display the axes viewer
  41467. */
  41468. bone: Nullable<Bone>;
  41469. /** Gets current position */
  41470. pos: Vector3;
  41471. /** Gets direction of X axis */
  41472. xaxis: Vector3;
  41473. /** Gets direction of Y axis */
  41474. yaxis: Vector3;
  41475. /** Gets direction of Z axis */
  41476. zaxis: Vector3;
  41477. /**
  41478. * Creates a new BoneAxesViewer
  41479. * @param scene defines the hosting scene
  41480. * @param bone defines the target bone
  41481. * @param mesh defines the target mesh
  41482. * @param scaleLines defines a scaling factor for line length (1 by default)
  41483. */
  41484. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41485. /**
  41486. * Force the viewer to update
  41487. */
  41488. update(): void;
  41489. /** Releases resources */
  41490. dispose(): void;
  41491. }
  41492. }
  41493. declare module "babylonjs/Debug/debugLayer" {
  41494. import { Observable } from "babylonjs/Misc/observable";
  41495. import { Scene } from "babylonjs/scene";
  41496. /**
  41497. * Interface used to define scene explorer extensibility option
  41498. */
  41499. export interface IExplorerExtensibilityOption {
  41500. /**
  41501. * Define the option label
  41502. */
  41503. label: string;
  41504. /**
  41505. * Defines the action to execute on click
  41506. */
  41507. action: (entity: any) => void;
  41508. }
  41509. /**
  41510. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41511. */
  41512. export interface IExplorerExtensibilityGroup {
  41513. /**
  41514. * Defines a predicate to test if a given type mut be extended
  41515. */
  41516. predicate: (entity: any) => boolean;
  41517. /**
  41518. * Gets the list of options added to a type
  41519. */
  41520. entries: IExplorerExtensibilityOption[];
  41521. }
  41522. /**
  41523. * Interface used to define the options to use to create the Inspector
  41524. */
  41525. export interface IInspectorOptions {
  41526. /**
  41527. * Display in overlay mode (default: false)
  41528. */
  41529. overlay?: boolean;
  41530. /**
  41531. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41532. */
  41533. globalRoot?: HTMLElement;
  41534. /**
  41535. * Display the Scene explorer
  41536. */
  41537. showExplorer?: boolean;
  41538. /**
  41539. * Display the property inspector
  41540. */
  41541. showInspector?: boolean;
  41542. /**
  41543. * Display in embed mode (both panes on the right)
  41544. */
  41545. embedMode?: boolean;
  41546. /**
  41547. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41548. */
  41549. handleResize?: boolean;
  41550. /**
  41551. * Allow the panes to popup (default: true)
  41552. */
  41553. enablePopup?: boolean;
  41554. /**
  41555. * Allow the panes to be closed by users (default: true)
  41556. */
  41557. enableClose?: boolean;
  41558. /**
  41559. * Optional list of extensibility entries
  41560. */
  41561. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41562. /**
  41563. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41564. */
  41565. inspectorURL?: string;
  41566. }
  41567. module "babylonjs/scene" {
  41568. interface Scene {
  41569. /**
  41570. * @hidden
  41571. * Backing field
  41572. */
  41573. _debugLayer: DebugLayer;
  41574. /**
  41575. * Gets the debug layer (aka Inspector) associated with the scene
  41576. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41577. */
  41578. debugLayer: DebugLayer;
  41579. }
  41580. }
  41581. /**
  41582. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41583. * what is happening in your scene
  41584. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41585. */
  41586. export class DebugLayer {
  41587. /**
  41588. * Define the url to get the inspector script from.
  41589. * By default it uses the babylonjs CDN.
  41590. * @ignoreNaming
  41591. */
  41592. static InspectorURL: string;
  41593. private _scene;
  41594. private BJSINSPECTOR;
  41595. /**
  41596. * Observable triggered when a property is changed through the inspector.
  41597. */
  41598. onPropertyChangedObservable: Observable<{
  41599. object: any;
  41600. property: string;
  41601. value: any;
  41602. initialValue: any;
  41603. }>;
  41604. /**
  41605. * Instantiates a new debug layer.
  41606. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41607. * what is happening in your scene
  41608. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41609. * @param scene Defines the scene to inspect
  41610. */
  41611. constructor(scene: Scene);
  41612. /** Creates the inspector window. */
  41613. private _createInspector;
  41614. /**
  41615. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41616. * @param entity defines the entity to select
  41617. * @param lineContainerTitle defines the specific block to highlight
  41618. */
  41619. select(entity: any, lineContainerTitle?: string): void;
  41620. /** Get the inspector from bundle or global */
  41621. private _getGlobalInspector;
  41622. /**
  41623. * Get if the inspector is visible or not.
  41624. * @returns true if visible otherwise, false
  41625. */
  41626. isVisible(): boolean;
  41627. /**
  41628. * Hide the inspector and close its window.
  41629. */
  41630. hide(): void;
  41631. /**
  41632. * Launch the debugLayer.
  41633. * @param config Define the configuration of the inspector
  41634. * @return a promise fulfilled when the debug layer is visible
  41635. */
  41636. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41637. }
  41638. }
  41639. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41640. import { Nullable } from "babylonjs/types";
  41641. import { Scene } from "babylonjs/scene";
  41642. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41643. import { Mesh } from "babylonjs/Meshes/mesh";
  41644. /**
  41645. * Class containing static functions to help procedurally build meshes
  41646. */
  41647. export class BoxBuilder {
  41648. /**
  41649. * Creates a box mesh
  41650. * * The parameter `size` sets the size (float) of each box side (default 1)
  41651. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41652. * * 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)
  41653. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41657. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41658. * @param name defines the name of the mesh
  41659. * @param options defines the options used to create the mesh
  41660. * @param scene defines the hosting scene
  41661. * @returns the box mesh
  41662. */
  41663. static CreateBox(name: string, options: {
  41664. size?: number;
  41665. width?: number;
  41666. height?: number;
  41667. depth?: number;
  41668. faceUV?: Vector4[];
  41669. faceColors?: Color4[];
  41670. sideOrientation?: number;
  41671. frontUVs?: Vector4;
  41672. backUVs?: Vector4;
  41673. updatable?: boolean;
  41674. }, scene?: Nullable<Scene>): Mesh;
  41675. }
  41676. }
  41677. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41678. import { Vector4 } from "babylonjs/Maths/math";
  41679. import { Mesh } from "babylonjs/Meshes/mesh";
  41680. /**
  41681. * Class containing static functions to help procedurally build meshes
  41682. */
  41683. export class SphereBuilder {
  41684. /**
  41685. * Creates a sphere mesh
  41686. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41687. * * 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`)
  41688. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41689. * * 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
  41690. * * 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)
  41691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41694. * @param name defines the name of the mesh
  41695. * @param options defines the options used to create the mesh
  41696. * @param scene defines the hosting scene
  41697. * @returns the sphere mesh
  41698. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41699. */
  41700. static CreateSphere(name: string, options: {
  41701. segments?: number;
  41702. diameter?: number;
  41703. diameterX?: number;
  41704. diameterY?: number;
  41705. diameterZ?: number;
  41706. arc?: number;
  41707. slice?: number;
  41708. sideOrientation?: number;
  41709. frontUVs?: Vector4;
  41710. backUVs?: Vector4;
  41711. updatable?: boolean;
  41712. }, scene: any): Mesh;
  41713. }
  41714. }
  41715. declare module "babylonjs/Debug/physicsViewer" {
  41716. import { Nullable } from "babylonjs/types";
  41717. import { Scene } from "babylonjs/scene";
  41718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41719. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41721. /**
  41722. * Used to show the physics impostor around the specific mesh
  41723. */
  41724. export class PhysicsViewer {
  41725. /** @hidden */
  41726. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41727. /** @hidden */
  41728. protected _meshes: Array<Nullable<AbstractMesh>>;
  41729. /** @hidden */
  41730. protected _scene: Nullable<Scene>;
  41731. /** @hidden */
  41732. protected _numMeshes: number;
  41733. /** @hidden */
  41734. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41735. private _renderFunction;
  41736. private _utilityLayer;
  41737. private _debugBoxMesh;
  41738. private _debugSphereMesh;
  41739. private _debugMaterial;
  41740. /**
  41741. * Creates a new PhysicsViewer
  41742. * @param scene defines the hosting scene
  41743. */
  41744. constructor(scene: Scene);
  41745. /** @hidden */
  41746. protected _updateDebugMeshes(): void;
  41747. /**
  41748. * Renders a specified physic impostor
  41749. * @param impostor defines the impostor to render
  41750. * @returns the new debug mesh used to render the impostor
  41751. */
  41752. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41753. /**
  41754. * Hides a specified physic impostor
  41755. * @param impostor defines the impostor to hide
  41756. */
  41757. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41758. private _getDebugMaterial;
  41759. private _getDebugBoxMesh;
  41760. private _getDebugSphereMesh;
  41761. private _getDebugMesh;
  41762. /** Releases all resources */
  41763. dispose(): void;
  41764. }
  41765. }
  41766. declare module "babylonjs/Debug/rayHelper" {
  41767. import { Nullable } from "babylonjs/types";
  41768. import { Ray } from "babylonjs/Culling/ray";
  41769. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41770. import { Scene } from "babylonjs/scene";
  41771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41772. import "babylonjs/Meshes/Builders/linesBuilder";
  41773. /**
  41774. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41775. * in order to better appreciate the issue one might have.
  41776. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41777. */
  41778. export class RayHelper {
  41779. /**
  41780. * Defines the ray we are currently tryin to visualize.
  41781. */
  41782. ray: Nullable<Ray>;
  41783. private _renderPoints;
  41784. private _renderLine;
  41785. private _renderFunction;
  41786. private _scene;
  41787. private _updateToMeshFunction;
  41788. private _attachedToMesh;
  41789. private _meshSpaceDirection;
  41790. private _meshSpaceOrigin;
  41791. /**
  41792. * Helper function to create a colored helper in a scene in one line.
  41793. * @param ray Defines the ray we are currently tryin to visualize
  41794. * @param scene Defines the scene the ray is used in
  41795. * @param color Defines the color we want to see the ray in
  41796. * @returns The newly created ray helper.
  41797. */
  41798. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41799. /**
  41800. * Instantiate a new ray helper.
  41801. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41802. * in order to better appreciate the issue one might have.
  41803. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41804. * @param ray Defines the ray we are currently tryin to visualize
  41805. */
  41806. constructor(ray: Ray);
  41807. /**
  41808. * Shows the ray we are willing to debug.
  41809. * @param scene Defines the scene the ray needs to be rendered in
  41810. * @param color Defines the color the ray needs to be rendered in
  41811. */
  41812. show(scene: Scene, color?: Color3): void;
  41813. /**
  41814. * Hides the ray we are debugging.
  41815. */
  41816. hide(): void;
  41817. private _render;
  41818. /**
  41819. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41820. * @param mesh Defines the mesh we want the helper attached to
  41821. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41822. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41823. * @param length Defines the length of the ray
  41824. */
  41825. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41826. /**
  41827. * Detach the ray helper from the mesh it has previously been attached to.
  41828. */
  41829. detachFromMesh(): void;
  41830. private _updateToMesh;
  41831. /**
  41832. * Dispose the helper and release its associated resources.
  41833. */
  41834. dispose(): void;
  41835. }
  41836. }
  41837. declare module "babylonjs/Debug/skeletonViewer" {
  41838. import { Color3 } from "babylonjs/Maths/math";
  41839. import { Scene } from "babylonjs/scene";
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Skeleton } from "babylonjs/Bones/skeleton";
  41842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41843. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41844. /**
  41845. * Class used to render a debug view of a given skeleton
  41846. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41847. */
  41848. export class SkeletonViewer {
  41849. /** defines the skeleton to render */
  41850. skeleton: Skeleton;
  41851. /** defines the mesh attached to the skeleton */
  41852. mesh: AbstractMesh;
  41853. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41854. autoUpdateBonesMatrices: boolean;
  41855. /** defines the rendering group id to use with the viewer */
  41856. renderingGroupId: number;
  41857. /** Gets or sets the color used to render the skeleton */
  41858. color: Color3;
  41859. private _scene;
  41860. private _debugLines;
  41861. private _debugMesh;
  41862. private _isEnabled;
  41863. private _renderFunction;
  41864. private _utilityLayer;
  41865. /**
  41866. * Returns the mesh used to render the bones
  41867. */
  41868. readonly debugMesh: Nullable<LinesMesh>;
  41869. /**
  41870. * Creates a new SkeletonViewer
  41871. * @param skeleton defines the skeleton to render
  41872. * @param mesh defines the mesh attached to the skeleton
  41873. * @param scene defines the hosting scene
  41874. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41875. * @param renderingGroupId defines the rendering group id to use with the viewer
  41876. */
  41877. constructor(
  41878. /** defines the skeleton to render */
  41879. skeleton: Skeleton,
  41880. /** defines the mesh attached to the skeleton */
  41881. mesh: AbstractMesh, scene: Scene,
  41882. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41883. autoUpdateBonesMatrices?: boolean,
  41884. /** defines the rendering group id to use with the viewer */
  41885. renderingGroupId?: number);
  41886. /** Gets or sets a boolean indicating if the viewer is enabled */
  41887. isEnabled: boolean;
  41888. private _getBonePosition;
  41889. private _getLinesForBonesWithLength;
  41890. private _getLinesForBonesNoLength;
  41891. /** Update the viewer to sync with current skeleton state */
  41892. update(): void;
  41893. /** Release associated resources */
  41894. dispose(): void;
  41895. }
  41896. }
  41897. declare module "babylonjs/Debug/index" {
  41898. export * from "babylonjs/Debug/axesViewer";
  41899. export * from "babylonjs/Debug/boneAxesViewer";
  41900. export * from "babylonjs/Debug/debugLayer";
  41901. export * from "babylonjs/Debug/physicsViewer";
  41902. export * from "babylonjs/Debug/rayHelper";
  41903. export * from "babylonjs/Debug/skeletonViewer";
  41904. }
  41905. declare module "babylonjs/Engines/nullEngine" {
  41906. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41907. import { Scene } from "babylonjs/scene";
  41908. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41909. import { Engine } from "babylonjs/Engines/engine";
  41910. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41911. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41913. import { Effect } from "babylonjs/Materials/effect";
  41914. /**
  41915. * Options to create the null engine
  41916. */
  41917. export class NullEngineOptions {
  41918. /**
  41919. * Render width (Default: 512)
  41920. */
  41921. renderWidth: number;
  41922. /**
  41923. * Render height (Default: 256)
  41924. */
  41925. renderHeight: number;
  41926. /**
  41927. * Texture size (Default: 512)
  41928. */
  41929. textureSize: number;
  41930. /**
  41931. * If delta time between frames should be constant
  41932. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41933. */
  41934. deterministicLockstep: boolean;
  41935. /**
  41936. * Maximum about of steps between frames (Default: 4)
  41937. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41938. */
  41939. lockstepMaxSteps: number;
  41940. }
  41941. /**
  41942. * The null engine class provides support for headless version of babylon.js.
  41943. * This can be used in server side scenario or for testing purposes
  41944. */
  41945. export class NullEngine extends Engine {
  41946. private _options;
  41947. /**
  41948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41949. */
  41950. isDeterministicLockStep(): boolean;
  41951. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41952. getLockstepMaxSteps(): number;
  41953. /**
  41954. * Sets hardware scaling, used to save performance if needed
  41955. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41956. */
  41957. getHardwareScalingLevel(): number;
  41958. constructor(options?: NullEngineOptions);
  41959. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41960. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41961. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41962. getRenderWidth(useScreen?: boolean): number;
  41963. getRenderHeight(useScreen?: boolean): number;
  41964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41965. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41966. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41967. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41968. bindSamplers(effect: Effect): void;
  41969. enableEffect(effect: Effect): void;
  41970. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41971. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41972. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41973. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41974. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41975. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41976. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41977. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41978. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41979. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41980. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41981. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41982. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41983. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41984. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41985. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41986. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41987. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41988. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41989. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41990. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41991. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41992. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41993. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41994. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41995. bindBuffers(vertexBuffers: {
  41996. [key: string]: VertexBuffer;
  41997. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41998. wipeCaches(bruteForce?: boolean): void;
  41999. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42000. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42001. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42002. /** @hidden */
  42003. _createTexture(): WebGLTexture;
  42004. /** @hidden */
  42005. _releaseTexture(texture: InternalTexture): void;
  42006. 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;
  42007. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42008. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42010. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42011. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42012. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42013. areAllEffectsReady(): boolean;
  42014. /**
  42015. * @hidden
  42016. * Get the current error code of the webGL context
  42017. * @returns the error code
  42018. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42019. */
  42020. getError(): number;
  42021. /** @hidden */
  42022. _getUnpackAlignement(): number;
  42023. /** @hidden */
  42024. _unpackFlipY(value: boolean): void;
  42025. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42026. /**
  42027. * Updates a dynamic vertex buffer.
  42028. * @param vertexBuffer the vertex buffer to update
  42029. * @param data the data used to update the vertex buffer
  42030. * @param byteOffset the byte offset of the data (optional)
  42031. * @param byteLength the byte length of the data (optional)
  42032. */
  42033. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42034. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42035. /** @hidden */
  42036. _bindTexture(channel: number, texture: InternalTexture): void;
  42037. /** @hidden */
  42038. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42039. releaseEffects(): void;
  42040. displayLoadingUI(): void;
  42041. hideLoadingUI(): void;
  42042. /** @hidden */
  42043. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42044. /** @hidden */
  42045. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42046. /** @hidden */
  42047. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42048. /** @hidden */
  42049. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42050. }
  42051. }
  42052. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42053. import { Nullable, int } from "babylonjs/types";
  42054. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42055. /** @hidden */
  42056. export class _OcclusionDataStorage {
  42057. /** @hidden */
  42058. occlusionInternalRetryCounter: number;
  42059. /** @hidden */
  42060. isOcclusionQueryInProgress: boolean;
  42061. /** @hidden */
  42062. isOccluded: boolean;
  42063. /** @hidden */
  42064. occlusionRetryCount: number;
  42065. /** @hidden */
  42066. occlusionType: number;
  42067. /** @hidden */
  42068. occlusionQueryAlgorithmType: number;
  42069. }
  42070. module "babylonjs/Engines/engine" {
  42071. interface Engine {
  42072. /**
  42073. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42074. * @return the new query
  42075. */
  42076. createQuery(): WebGLQuery;
  42077. /**
  42078. * Delete and release a webGL query
  42079. * @param query defines the query to delete
  42080. * @return the current engine
  42081. */
  42082. deleteQuery(query: WebGLQuery): Engine;
  42083. /**
  42084. * Check if a given query has resolved and got its value
  42085. * @param query defines the query to check
  42086. * @returns true if the query got its value
  42087. */
  42088. isQueryResultAvailable(query: WebGLQuery): boolean;
  42089. /**
  42090. * Gets the value of a given query
  42091. * @param query defines the query to check
  42092. * @returns the value of the query
  42093. */
  42094. getQueryResult(query: WebGLQuery): number;
  42095. /**
  42096. * Initiates an occlusion query
  42097. * @param algorithmType defines the algorithm to use
  42098. * @param query defines the query to use
  42099. * @returns the current engine
  42100. * @see http://doc.babylonjs.com/features/occlusionquery
  42101. */
  42102. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42103. /**
  42104. * Ends an occlusion query
  42105. * @see http://doc.babylonjs.com/features/occlusionquery
  42106. * @param algorithmType defines the algorithm to use
  42107. * @returns the current engine
  42108. */
  42109. endOcclusionQuery(algorithmType: number): Engine;
  42110. /**
  42111. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42112. * Please note that only one query can be issued at a time
  42113. * @returns a time token used to track the time span
  42114. */
  42115. startTimeQuery(): Nullable<_TimeToken>;
  42116. /**
  42117. * Ends a time query
  42118. * @param token defines the token used to measure the time span
  42119. * @returns the time spent (in ns)
  42120. */
  42121. endTimeQuery(token: _TimeToken): int;
  42122. /** @hidden */
  42123. _currentNonTimestampToken: Nullable<_TimeToken>;
  42124. /** @hidden */
  42125. _createTimeQuery(): WebGLQuery;
  42126. /** @hidden */
  42127. _deleteTimeQuery(query: WebGLQuery): void;
  42128. /** @hidden */
  42129. _getGlAlgorithmType(algorithmType: number): number;
  42130. /** @hidden */
  42131. _getTimeQueryResult(query: WebGLQuery): any;
  42132. /** @hidden */
  42133. _getTimeQueryAvailability(query: WebGLQuery): any;
  42134. }
  42135. }
  42136. module "babylonjs/Meshes/abstractMesh" {
  42137. interface AbstractMesh {
  42138. /**
  42139. * Backing filed
  42140. * @hidden
  42141. */
  42142. __occlusionDataStorage: _OcclusionDataStorage;
  42143. /**
  42144. * Access property
  42145. * @hidden
  42146. */
  42147. _occlusionDataStorage: _OcclusionDataStorage;
  42148. /**
  42149. * 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.
  42150. * The default value is -1 which means don't break the query and wait till the result
  42151. * @see http://doc.babylonjs.com/features/occlusionquery
  42152. */
  42153. occlusionRetryCount: number;
  42154. /**
  42155. * 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:
  42156. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42157. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42158. * * 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.
  42159. * @see http://doc.babylonjs.com/features/occlusionquery
  42160. */
  42161. occlusionType: number;
  42162. /**
  42163. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42164. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42165. * * 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.
  42166. * @see http://doc.babylonjs.com/features/occlusionquery
  42167. */
  42168. occlusionQueryAlgorithmType: number;
  42169. /**
  42170. * 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
  42171. * @see http://doc.babylonjs.com/features/occlusionquery
  42172. */
  42173. isOccluded: boolean;
  42174. /**
  42175. * Flag to check the progress status of the query
  42176. * @see http://doc.babylonjs.com/features/occlusionquery
  42177. */
  42178. isOcclusionQueryInProgress: boolean;
  42179. }
  42180. }
  42181. }
  42182. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42183. import { Nullable } from "babylonjs/types";
  42184. /** @hidden */
  42185. export var _forceTransformFeedbackToBundle: boolean;
  42186. module "babylonjs/Engines/engine" {
  42187. interface Engine {
  42188. /**
  42189. * Creates a webGL transform feedback object
  42190. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42191. * @returns the webGL transform feedback object
  42192. */
  42193. createTransformFeedback(): WebGLTransformFeedback;
  42194. /**
  42195. * Delete a webGL transform feedback object
  42196. * @param value defines the webGL transform feedback object to delete
  42197. */
  42198. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42199. /**
  42200. * Bind a webGL transform feedback object to the webgl context
  42201. * @param value defines the webGL transform feedback object to bind
  42202. */
  42203. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42204. /**
  42205. * Begins a transform feedback operation
  42206. * @param usePoints defines if points or triangles must be used
  42207. */
  42208. beginTransformFeedback(usePoints: boolean): void;
  42209. /**
  42210. * Ends a transform feedback operation
  42211. */
  42212. endTransformFeedback(): void;
  42213. /**
  42214. * Specify the varyings to use with transform feedback
  42215. * @param program defines the associated webGL program
  42216. * @param value defines the list of strings representing the varying names
  42217. */
  42218. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42219. /**
  42220. * Bind a webGL buffer for a transform feedback operation
  42221. * @param value defines the webGL buffer to bind
  42222. */
  42223. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42224. }
  42225. }
  42226. }
  42227. declare module "babylonjs/Engines/Extensions/index" {
  42228. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42229. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42230. }
  42231. declare module "babylonjs/Engines/index" {
  42232. export * from "babylonjs/Engines/constants";
  42233. export * from "babylonjs/Engines/engine";
  42234. export * from "babylonjs/Engines/engineStore";
  42235. export * from "babylonjs/Engines/nullEngine";
  42236. export * from "babylonjs/Engines/Extensions/index";
  42237. }
  42238. declare module "babylonjs/Events/clipboardEvents" {
  42239. /**
  42240. * Gather the list of clipboard event types as constants.
  42241. */
  42242. export class ClipboardEventTypes {
  42243. /**
  42244. * The clipboard event is fired when a copy command is active (pressed).
  42245. */
  42246. static readonly COPY: number;
  42247. /**
  42248. * The clipboard event is fired when a cut command is active (pressed).
  42249. */
  42250. static readonly CUT: number;
  42251. /**
  42252. * The clipboard event is fired when a paste command is active (pressed).
  42253. */
  42254. static readonly PASTE: number;
  42255. }
  42256. /**
  42257. * This class is used to store clipboard related info for the onClipboardObservable event.
  42258. */
  42259. export class ClipboardInfo {
  42260. /**
  42261. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42262. */
  42263. type: number;
  42264. /**
  42265. * Defines the related dom event
  42266. */
  42267. event: ClipboardEvent;
  42268. /**
  42269. *Creates an instance of ClipboardInfo.
  42270. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42271. * @param event Defines the related dom event
  42272. */
  42273. constructor(
  42274. /**
  42275. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42276. */
  42277. type: number,
  42278. /**
  42279. * Defines the related dom event
  42280. */
  42281. event: ClipboardEvent);
  42282. /**
  42283. * Get the clipboard event's type from the keycode.
  42284. * @param keyCode Defines the keyCode for the current keyboard event.
  42285. * @return {number}
  42286. */
  42287. static GetTypeFromCharacter(keyCode: number): number;
  42288. }
  42289. }
  42290. declare module "babylonjs/Events/index" {
  42291. export * from "babylonjs/Events/keyboardEvents";
  42292. export * from "babylonjs/Events/pointerEvents";
  42293. export * from "babylonjs/Events/clipboardEvents";
  42294. }
  42295. declare module "babylonjs/Loading/sceneLoader" {
  42296. import { Observable } from "babylonjs/Misc/observable";
  42297. import { Nullable } from "babylonjs/types";
  42298. import { Scene } from "babylonjs/scene";
  42299. import { Engine } from "babylonjs/Engines/engine";
  42300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42301. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42302. import { AssetContainer } from "babylonjs/assetContainer";
  42303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42304. import { Skeleton } from "babylonjs/Bones/skeleton";
  42305. /**
  42306. * Class used to represent data loading progression
  42307. */
  42308. export class SceneLoaderProgressEvent {
  42309. /** defines if data length to load can be evaluated */
  42310. readonly lengthComputable: boolean;
  42311. /** defines the loaded data length */
  42312. readonly loaded: number;
  42313. /** defines the data length to load */
  42314. readonly total: number;
  42315. /**
  42316. * Create a new progress event
  42317. * @param lengthComputable defines if data length to load can be evaluated
  42318. * @param loaded defines the loaded data length
  42319. * @param total defines the data length to load
  42320. */
  42321. constructor(
  42322. /** defines if data length to load can be evaluated */
  42323. lengthComputable: boolean,
  42324. /** defines the loaded data length */
  42325. loaded: number,
  42326. /** defines the data length to load */
  42327. total: number);
  42328. /**
  42329. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42330. * @param event defines the source event
  42331. * @returns a new SceneLoaderProgressEvent
  42332. */
  42333. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42334. }
  42335. /**
  42336. * Interface used by SceneLoader plugins to define supported file extensions
  42337. */
  42338. export interface ISceneLoaderPluginExtensions {
  42339. /**
  42340. * Defines the list of supported extensions
  42341. */
  42342. [extension: string]: {
  42343. isBinary: boolean;
  42344. };
  42345. }
  42346. /**
  42347. * Interface used by SceneLoader plugin factory
  42348. */
  42349. export interface ISceneLoaderPluginFactory {
  42350. /**
  42351. * Defines the name of the factory
  42352. */
  42353. name: string;
  42354. /**
  42355. * Function called to create a new plugin
  42356. * @return the new plugin
  42357. */
  42358. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42359. /**
  42360. * Boolean indicating if the plugin can direct load specific data
  42361. */
  42362. canDirectLoad?: (data: string) => boolean;
  42363. }
  42364. /**
  42365. * Interface used to define a SceneLoader plugin
  42366. */
  42367. export interface ISceneLoaderPlugin {
  42368. /**
  42369. * The friendly name of this plugin.
  42370. */
  42371. name: string;
  42372. /**
  42373. * The file extensions supported by this plugin.
  42374. */
  42375. extensions: string | ISceneLoaderPluginExtensions;
  42376. /**
  42377. * Import meshes into a scene.
  42378. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42379. * @param scene The scene to import into
  42380. * @param data The data to import
  42381. * @param rootUrl The root url for scene and resources
  42382. * @param meshes The meshes array to import into
  42383. * @param particleSystems The particle systems array to import into
  42384. * @param skeletons The skeletons array to import into
  42385. * @param onError The callback when import fails
  42386. * @returns True if successful or false otherwise
  42387. */
  42388. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42389. /**
  42390. * Load into a scene.
  42391. * @param scene The scene to load into
  42392. * @param data The data to import
  42393. * @param rootUrl The root url for scene and resources
  42394. * @param onError The callback when import fails
  42395. * @returns true if successful or false otherwise
  42396. */
  42397. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42398. /**
  42399. * The callback that returns true if the data can be directly loaded.
  42400. */
  42401. canDirectLoad?: (data: string) => boolean;
  42402. /**
  42403. * The callback that allows custom handling of the root url based on the response url.
  42404. */
  42405. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42406. /**
  42407. * Load into an asset container.
  42408. * @param scene The scene to load into
  42409. * @param data The data to import
  42410. * @param rootUrl The root url for scene and resources
  42411. * @param onError The callback when import fails
  42412. * @returns The loaded asset container
  42413. */
  42414. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42415. }
  42416. /**
  42417. * Interface used to define an async SceneLoader plugin
  42418. */
  42419. export interface ISceneLoaderPluginAsync {
  42420. /**
  42421. * The friendly name of this plugin.
  42422. */
  42423. name: string;
  42424. /**
  42425. * The file extensions supported by this plugin.
  42426. */
  42427. extensions: string | ISceneLoaderPluginExtensions;
  42428. /**
  42429. * Import meshes into a scene.
  42430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42431. * @param scene The scene to import into
  42432. * @param data The data to import
  42433. * @param rootUrl The root url for scene and resources
  42434. * @param onProgress The callback when the load progresses
  42435. * @param fileName Defines the name of the file to load
  42436. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42437. */
  42438. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42439. meshes: AbstractMesh[];
  42440. particleSystems: IParticleSystem[];
  42441. skeletons: Skeleton[];
  42442. animationGroups: AnimationGroup[];
  42443. }>;
  42444. /**
  42445. * Load into a scene.
  42446. * @param scene The scene to load into
  42447. * @param data The data to import
  42448. * @param rootUrl The root url for scene and resources
  42449. * @param onProgress The callback when the load progresses
  42450. * @param fileName Defines the name of the file to load
  42451. * @returns Nothing
  42452. */
  42453. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42454. /**
  42455. * The callback that returns true if the data can be directly loaded.
  42456. */
  42457. canDirectLoad?: (data: string) => boolean;
  42458. /**
  42459. * The callback that allows custom handling of the root url based on the response url.
  42460. */
  42461. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42462. /**
  42463. * Load into an asset container.
  42464. * @param scene The scene to load into
  42465. * @param data The data to import
  42466. * @param rootUrl The root url for scene and resources
  42467. * @param onProgress The callback when the load progresses
  42468. * @param fileName Defines the name of the file to load
  42469. * @returns The loaded asset container
  42470. */
  42471. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42472. }
  42473. /**
  42474. * Class used to load scene from various file formats using registered plugins
  42475. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42476. */
  42477. export class SceneLoader {
  42478. /**
  42479. * No logging while loading
  42480. */
  42481. static readonly NO_LOGGING: number;
  42482. /**
  42483. * Minimal logging while loading
  42484. */
  42485. static readonly MINIMAL_LOGGING: number;
  42486. /**
  42487. * Summary logging while loading
  42488. */
  42489. static readonly SUMMARY_LOGGING: number;
  42490. /**
  42491. * Detailled logging while loading
  42492. */
  42493. static readonly DETAILED_LOGGING: number;
  42494. /**
  42495. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42496. */
  42497. static ForceFullSceneLoadingForIncremental: boolean;
  42498. /**
  42499. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42500. */
  42501. static ShowLoadingScreen: boolean;
  42502. /**
  42503. * Defines the current logging level (while loading the scene)
  42504. * @ignorenaming
  42505. */
  42506. static loggingLevel: number;
  42507. /**
  42508. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42509. */
  42510. static CleanBoneMatrixWeights: boolean;
  42511. /**
  42512. * Event raised when a plugin is used to load a scene
  42513. */
  42514. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42515. private static _registeredPlugins;
  42516. private static _getDefaultPlugin;
  42517. private static _getPluginForExtension;
  42518. private static _getPluginForDirectLoad;
  42519. private static _getPluginForFilename;
  42520. private static _getDirectLoad;
  42521. private static _loadData;
  42522. private static _getFileInfo;
  42523. /**
  42524. * Gets a plugin that can load the given extension
  42525. * @param extension defines the extension to load
  42526. * @returns a plugin or null if none works
  42527. */
  42528. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42529. /**
  42530. * Gets a boolean indicating that the given extension can be loaded
  42531. * @param extension defines the extension to load
  42532. * @returns true if the extension is supported
  42533. */
  42534. static IsPluginForExtensionAvailable(extension: string): boolean;
  42535. /**
  42536. * Adds a new plugin to the list of registered plugins
  42537. * @param plugin defines the plugin to add
  42538. */
  42539. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42540. /**
  42541. * Import meshes into a scene
  42542. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42543. * @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)
  42544. * @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)
  42545. * @param scene the instance of BABYLON.Scene to append to
  42546. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42547. * @param onProgress a callback with a progress event for each file being loaded
  42548. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42549. * @param pluginExtension the extension used to determine the plugin
  42550. * @returns The loaded plugin
  42551. */
  42552. 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>;
  42553. /**
  42554. * Import meshes into a scene
  42555. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42556. * @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)
  42557. * @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)
  42558. * @param scene the instance of BABYLON.Scene to append to
  42559. * @param onProgress a callback with a progress event for each file being loaded
  42560. * @param pluginExtension the extension used to determine the plugin
  42561. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42562. */
  42563. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42564. meshes: AbstractMesh[];
  42565. particleSystems: IParticleSystem[];
  42566. skeletons: Skeleton[];
  42567. animationGroups: AnimationGroup[];
  42568. }>;
  42569. /**
  42570. * Load a scene
  42571. * @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)
  42572. * @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)
  42573. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42574. * @param onSuccess a callback with the scene when import succeeds
  42575. * @param onProgress a callback with a progress event for each file being loaded
  42576. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42577. * @param pluginExtension the extension used to determine the plugin
  42578. * @returns The loaded plugin
  42579. */
  42580. 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>;
  42581. /**
  42582. * Load a scene
  42583. * @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)
  42584. * @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)
  42585. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42586. * @param onProgress a callback with a progress event for each file being loaded
  42587. * @param pluginExtension the extension used to determine the plugin
  42588. * @returns The loaded scene
  42589. */
  42590. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42591. /**
  42592. * Append a scene
  42593. * @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)
  42594. * @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)
  42595. * @param scene is the instance of BABYLON.Scene to append to
  42596. * @param onSuccess a callback with the scene when import succeeds
  42597. * @param onProgress a callback with a progress event for each file being loaded
  42598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42599. * @param pluginExtension the extension used to determine the plugin
  42600. * @returns The loaded plugin
  42601. */
  42602. 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>;
  42603. /**
  42604. * Append a scene
  42605. * @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)
  42606. * @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)
  42607. * @param scene is the instance of BABYLON.Scene to append to
  42608. * @param onProgress a callback with a progress event for each file being loaded
  42609. * @param pluginExtension the extension used to determine the plugin
  42610. * @returns The given scene
  42611. */
  42612. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42613. /**
  42614. * Load a scene into an asset container
  42615. * @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)
  42616. * @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)
  42617. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42618. * @param onSuccess a callback with the scene when import succeeds
  42619. * @param onProgress a callback with a progress event for each file being loaded
  42620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42621. * @param pluginExtension the extension used to determine the plugin
  42622. * @returns The loaded plugin
  42623. */
  42624. 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>;
  42625. /**
  42626. * Load a scene into an asset container
  42627. * @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)
  42628. * @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)
  42629. * @param scene is the instance of Scene to append to
  42630. * @param onProgress a callback with a progress event for each file being loaded
  42631. * @param pluginExtension the extension used to determine the plugin
  42632. * @returns The loaded asset container
  42633. */
  42634. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42635. }
  42636. }
  42637. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42638. import { Scene } from "babylonjs/scene";
  42639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42640. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42641. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42642. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42643. /**
  42644. * Google Daydream controller
  42645. */
  42646. export class DaydreamController extends WebVRController {
  42647. /**
  42648. * Base Url for the controller model.
  42649. */
  42650. static MODEL_BASE_URL: string;
  42651. /**
  42652. * File name for the controller model.
  42653. */
  42654. static MODEL_FILENAME: string;
  42655. /**
  42656. * Gamepad Id prefix used to identify Daydream Controller.
  42657. */
  42658. static readonly GAMEPAD_ID_PREFIX: string;
  42659. /**
  42660. * Creates a new DaydreamController from a gamepad
  42661. * @param vrGamepad the gamepad that the controller should be created from
  42662. */
  42663. constructor(vrGamepad: any);
  42664. /**
  42665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42666. * @param scene scene in which to add meshes
  42667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42668. */
  42669. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42670. /**
  42671. * Called once for each button that changed state since the last frame
  42672. * @param buttonIdx Which button index changed
  42673. * @param state New state of the button
  42674. * @param changes Which properties on the state changed since last frame
  42675. */
  42676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42677. }
  42678. }
  42679. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42680. import { Scene } from "babylonjs/scene";
  42681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42682. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42683. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42684. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42685. /**
  42686. * Gear VR Controller
  42687. */
  42688. export class GearVRController extends WebVRController {
  42689. /**
  42690. * Base Url for the controller model.
  42691. */
  42692. static MODEL_BASE_URL: string;
  42693. /**
  42694. * File name for the controller model.
  42695. */
  42696. static MODEL_FILENAME: string;
  42697. /**
  42698. * Gamepad Id prefix used to identify this controller.
  42699. */
  42700. static readonly GAMEPAD_ID_PREFIX: string;
  42701. private readonly _buttonIndexToObservableNameMap;
  42702. /**
  42703. * Creates a new GearVRController from a gamepad
  42704. * @param vrGamepad the gamepad that the controller should be created from
  42705. */
  42706. constructor(vrGamepad: any);
  42707. /**
  42708. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42709. * @param scene scene in which to add meshes
  42710. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42711. */
  42712. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42713. /**
  42714. * Called once for each button that changed state since the last frame
  42715. * @param buttonIdx Which button index changed
  42716. * @param state New state of the button
  42717. * @param changes Which properties on the state changed since last frame
  42718. */
  42719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42720. }
  42721. }
  42722. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42723. import { Scene } from "babylonjs/scene";
  42724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42725. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42726. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42727. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42728. /**
  42729. * Generic Controller
  42730. */
  42731. export class GenericController extends WebVRController {
  42732. /**
  42733. * Base Url for the controller model.
  42734. */
  42735. static readonly MODEL_BASE_URL: string;
  42736. /**
  42737. * File name for the controller model.
  42738. */
  42739. static readonly MODEL_FILENAME: string;
  42740. /**
  42741. * Creates a new GenericController from a gamepad
  42742. * @param vrGamepad the gamepad that the controller should be created from
  42743. */
  42744. constructor(vrGamepad: any);
  42745. /**
  42746. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42747. * @param scene scene in which to add meshes
  42748. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42749. */
  42750. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42751. /**
  42752. * Called once for each button that changed state since the last frame
  42753. * @param buttonIdx Which button index changed
  42754. * @param state New state of the button
  42755. * @param changes Which properties on the state changed since last frame
  42756. */
  42757. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42758. }
  42759. }
  42760. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42761. import { Observable } from "babylonjs/Misc/observable";
  42762. import { Scene } from "babylonjs/scene";
  42763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42764. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42765. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42766. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42767. /**
  42768. * Oculus Touch Controller
  42769. */
  42770. export class OculusTouchController extends WebVRController {
  42771. /**
  42772. * Base Url for the controller model.
  42773. */
  42774. static MODEL_BASE_URL: string;
  42775. /**
  42776. * File name for the left controller model.
  42777. */
  42778. static MODEL_LEFT_FILENAME: string;
  42779. /**
  42780. * File name for the right controller model.
  42781. */
  42782. static MODEL_RIGHT_FILENAME: string;
  42783. /**
  42784. * Fired when the secondary trigger on this controller is modified
  42785. */
  42786. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42787. /**
  42788. * Fired when the thumb rest on this controller is modified
  42789. */
  42790. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42791. /**
  42792. * Creates a new OculusTouchController from a gamepad
  42793. * @param vrGamepad the gamepad that the controller should be created from
  42794. */
  42795. constructor(vrGamepad: any);
  42796. /**
  42797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42798. * @param scene scene in which to add meshes
  42799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42800. */
  42801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42802. /**
  42803. * Fired when the A button on this controller is modified
  42804. */
  42805. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42806. /**
  42807. * Fired when the B button on this controller is modified
  42808. */
  42809. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42810. /**
  42811. * Fired when the X button on this controller is modified
  42812. */
  42813. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42814. /**
  42815. * Fired when the Y button on this controller is modified
  42816. */
  42817. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42818. /**
  42819. * Called once for each button that changed state since the last frame
  42820. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42821. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42822. * 2) secondary trigger (same)
  42823. * 3) A (right) X (left), touch, pressed = value
  42824. * 4) B / Y
  42825. * 5) thumb rest
  42826. * @param buttonIdx Which button index changed
  42827. * @param state New state of the button
  42828. * @param changes Which properties on the state changed since last frame
  42829. */
  42830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42834. import { Scene } from "babylonjs/scene";
  42835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42836. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42837. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42838. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42839. import { Observable } from "babylonjs/Misc/observable";
  42840. /**
  42841. * Vive Controller
  42842. */
  42843. export class ViveController extends WebVRController {
  42844. /**
  42845. * Base Url for the controller model.
  42846. */
  42847. static MODEL_BASE_URL: string;
  42848. /**
  42849. * File name for the controller model.
  42850. */
  42851. static MODEL_FILENAME: string;
  42852. /**
  42853. * Creates a new ViveController from a gamepad
  42854. * @param vrGamepad the gamepad that the controller should be created from
  42855. */
  42856. constructor(vrGamepad: any);
  42857. /**
  42858. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42859. * @param scene scene in which to add meshes
  42860. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42861. */
  42862. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42863. /**
  42864. * Fired when the left button on this controller is modified
  42865. */
  42866. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42867. /**
  42868. * Fired when the right button on this controller is modified
  42869. */
  42870. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42871. /**
  42872. * Fired when the menu button on this controller is modified
  42873. */
  42874. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42875. /**
  42876. * Called once for each button that changed state since the last frame
  42877. * Vive mapping:
  42878. * 0: touchpad
  42879. * 1: trigger
  42880. * 2: left AND right buttons
  42881. * 3: menu button
  42882. * @param buttonIdx Which button index changed
  42883. * @param state New state of the button
  42884. * @param changes Which properties on the state changed since last frame
  42885. */
  42886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42887. }
  42888. }
  42889. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42890. import { Observable } from "babylonjs/Misc/observable";
  42891. import { Scene } from "babylonjs/scene";
  42892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42893. import { Ray } from "babylonjs/Culling/ray";
  42894. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42895. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42896. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42897. /**
  42898. * Defines the WindowsMotionController object that the state of the windows motion controller
  42899. */
  42900. export class WindowsMotionController extends WebVRController {
  42901. /**
  42902. * The base url used to load the left and right controller models
  42903. */
  42904. static MODEL_BASE_URL: string;
  42905. /**
  42906. * The name of the left controller model file
  42907. */
  42908. static MODEL_LEFT_FILENAME: string;
  42909. /**
  42910. * The name of the right controller model file
  42911. */
  42912. static MODEL_RIGHT_FILENAME: string;
  42913. /**
  42914. * The controller name prefix for this controller type
  42915. */
  42916. static readonly GAMEPAD_ID_PREFIX: string;
  42917. /**
  42918. * The controller id pattern for this controller type
  42919. */
  42920. private static readonly GAMEPAD_ID_PATTERN;
  42921. private _loadedMeshInfo;
  42922. private readonly _mapping;
  42923. /**
  42924. * Fired when the trackpad on this controller is clicked
  42925. */
  42926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Fired when the trackpad on this controller is modified
  42929. */
  42930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42931. /**
  42932. * The current x and y values of this controller's trackpad
  42933. */
  42934. trackpad: StickValues;
  42935. /**
  42936. * Creates a new WindowsMotionController from a gamepad
  42937. * @param vrGamepad the gamepad that the controller should be created from
  42938. */
  42939. constructor(vrGamepad: any);
  42940. /**
  42941. * Fired when the trigger on this controller is modified
  42942. */
  42943. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42944. /**
  42945. * Fired when the menu button on this controller is modified
  42946. */
  42947. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42948. /**
  42949. * Fired when the grip button on this controller is modified
  42950. */
  42951. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42952. /**
  42953. * Fired when the thumbstick button on this controller is modified
  42954. */
  42955. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42956. /**
  42957. * Fired when the touchpad button on this controller is modified
  42958. */
  42959. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42960. /**
  42961. * Fired when the touchpad values on this controller are modified
  42962. */
  42963. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42964. private _updateTrackpad;
  42965. /**
  42966. * Called once per frame by the engine.
  42967. */
  42968. update(): void;
  42969. /**
  42970. * Called once for each button that changed state since the last frame
  42971. * @param buttonIdx Which button index changed
  42972. * @param state New state of the button
  42973. * @param changes Which properties on the state changed since last frame
  42974. */
  42975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42976. /**
  42977. * Moves the buttons on the controller mesh based on their current state
  42978. * @param buttonName the name of the button to move
  42979. * @param buttonValue the value of the button which determines the buttons new position
  42980. */
  42981. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42982. /**
  42983. * Moves the axis on the controller mesh based on its current state
  42984. * @param axis the index of the axis
  42985. * @param axisValue the value of the axis which determines the meshes new position
  42986. * @hidden
  42987. */
  42988. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42989. /**
  42990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42991. * @param scene scene in which to add meshes
  42992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42993. */
  42994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42995. /**
  42996. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42997. * can be transformed by button presses and axes values, based on this._mapping.
  42998. *
  42999. * @param scene scene in which the meshes exist
  43000. * @param meshes list of meshes that make up the controller model to process
  43001. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43002. */
  43003. private processModel;
  43004. private createMeshInfo;
  43005. /**
  43006. * Gets the ray of the controller in the direction the controller is pointing
  43007. * @param length the length the resulting ray should be
  43008. * @returns a ray in the direction the controller is pointing
  43009. */
  43010. getForwardRay(length?: number): Ray;
  43011. /**
  43012. * Disposes of the controller
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Gamepads/Controllers/index" {
  43018. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43019. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43020. export * from "babylonjs/Gamepads/Controllers/genericController";
  43021. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43022. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43023. export * from "babylonjs/Gamepads/Controllers/viveController";
  43024. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43025. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43026. }
  43027. declare module "babylonjs/Gamepads/index" {
  43028. export * from "babylonjs/Gamepads/Controllers/index";
  43029. export * from "babylonjs/Gamepads/gamepad";
  43030. export * from "babylonjs/Gamepads/gamepadManager";
  43031. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43032. export * from "babylonjs/Gamepads/xboxGamepad";
  43033. }
  43034. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43035. import { Observable } from "babylonjs/Misc/observable";
  43036. import { Nullable } from "babylonjs/types";
  43037. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43039. import { Mesh } from "babylonjs/Meshes/mesh";
  43040. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43041. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43042. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43043. /**
  43044. * Single axis scale gizmo
  43045. */
  43046. export class AxisScaleGizmo extends Gizmo {
  43047. private _coloredMaterial;
  43048. /**
  43049. * Drag behavior responsible for the gizmos dragging interactions
  43050. */
  43051. dragBehavior: PointerDragBehavior;
  43052. private _pointerObserver;
  43053. /**
  43054. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43055. */
  43056. snapDistance: number;
  43057. /**
  43058. * Event that fires each time the gizmo snaps to a new location.
  43059. * * snapDistance is the the change in distance
  43060. */
  43061. onSnapObservable: Observable<{
  43062. snapDistance: number;
  43063. }>;
  43064. /**
  43065. * If the scaling operation should be done on all axis (default: false)
  43066. */
  43067. uniformScaling: boolean;
  43068. /**
  43069. * Creates an AxisScaleGizmo
  43070. * @param gizmoLayer The utility layer the gizmo will be added to
  43071. * @param dragAxis The axis which the gizmo will be able to scale on
  43072. * @param color The color of the gizmo
  43073. */
  43074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43076. /**
  43077. * Disposes of the gizmo
  43078. */
  43079. dispose(): void;
  43080. /**
  43081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43082. * @param mesh The mesh to replace the default mesh of the gizmo
  43083. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43084. */
  43085. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43086. }
  43087. }
  43088. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43089. import { Observable } from "babylonjs/Misc/observable";
  43090. import { Nullable } from "babylonjs/types";
  43091. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43093. import { Mesh } from "babylonjs/Meshes/mesh";
  43094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43096. import "babylonjs/Meshes/Builders/boxBuilder";
  43097. /**
  43098. * Bounding box gizmo
  43099. */
  43100. export class BoundingBoxGizmo extends Gizmo {
  43101. private _lineBoundingBox;
  43102. private _rotateSpheresParent;
  43103. private _scaleBoxesParent;
  43104. private _boundingDimensions;
  43105. private _renderObserver;
  43106. private _pointerObserver;
  43107. private _scaleDragSpeed;
  43108. private _tmpQuaternion;
  43109. private _tmpVector;
  43110. private _tmpRotationMatrix;
  43111. /**
  43112. * 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)
  43113. */
  43114. ignoreChildren: boolean;
  43115. /**
  43116. * 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)
  43117. */
  43118. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43119. /**
  43120. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43121. */
  43122. rotationSphereSize: number;
  43123. /**
  43124. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43125. */
  43126. scaleBoxSize: number;
  43127. /**
  43128. * 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)
  43129. */
  43130. fixedDragMeshScreenSize: boolean;
  43131. /**
  43132. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43133. */
  43134. fixedDragMeshScreenSizeDistanceFactor: number;
  43135. /**
  43136. * Fired when a rotation sphere or scale box is dragged
  43137. */
  43138. onDragStartObservable: Observable<{}>;
  43139. /**
  43140. * Fired when a scale box is dragged
  43141. */
  43142. onScaleBoxDragObservable: Observable<{}>;
  43143. /**
  43144. * Fired when a scale box drag is ended
  43145. */
  43146. onScaleBoxDragEndObservable: Observable<{}>;
  43147. /**
  43148. * Fired when a rotation sphere is dragged
  43149. */
  43150. onRotationSphereDragObservable: Observable<{}>;
  43151. /**
  43152. * Fired when a rotation sphere drag is ended
  43153. */
  43154. onRotationSphereDragEndObservable: Observable<{}>;
  43155. /**
  43156. * 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)
  43157. */
  43158. scalePivot: Nullable<Vector3>;
  43159. private _anchorMesh;
  43160. private _existingMeshScale;
  43161. private _dragMesh;
  43162. private pointerDragBehavior;
  43163. private coloredMaterial;
  43164. private hoverColoredMaterial;
  43165. /**
  43166. * Sets the color of the bounding box gizmo
  43167. * @param color the color to set
  43168. */
  43169. setColor(color: Color3): void;
  43170. /**
  43171. * Creates an BoundingBoxGizmo
  43172. * @param gizmoLayer The utility layer the gizmo will be added to
  43173. * @param color The color of the gizmo
  43174. */
  43175. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43177. private _selectNode;
  43178. /**
  43179. * Updates the bounding box information for the Gizmo
  43180. */
  43181. updateBoundingBox(): void;
  43182. private _updateRotationSpheres;
  43183. private _updateScaleBoxes;
  43184. /**
  43185. * Enables rotation on the specified axis and disables rotation on the others
  43186. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43187. */
  43188. setEnabledRotationAxis(axis: string): void;
  43189. /**
  43190. * Enables/disables scaling
  43191. * @param enable if scaling should be enabled
  43192. */
  43193. setEnabledScaling(enable: boolean): void;
  43194. private _updateDummy;
  43195. /**
  43196. * Enables a pointer drag behavior on the bounding box of the gizmo
  43197. */
  43198. enableDragBehavior(): void;
  43199. /**
  43200. * Disposes of the gizmo
  43201. */
  43202. dispose(): void;
  43203. /**
  43204. * 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)
  43205. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43206. * @returns the bounding box mesh with the passed in mesh as a child
  43207. */
  43208. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43209. /**
  43210. * CustomMeshes are not supported by this gizmo
  43211. * @param mesh The mesh to replace the default mesh of the gizmo
  43212. */
  43213. setCustomMesh(mesh: Mesh): void;
  43214. }
  43215. }
  43216. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43217. import { Observable } from "babylonjs/Misc/observable";
  43218. import { Nullable } from "babylonjs/types";
  43219. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43221. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43222. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43223. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43224. import "babylonjs/Meshes/Builders/linesBuilder";
  43225. /**
  43226. * Single plane rotation gizmo
  43227. */
  43228. export class PlaneRotationGizmo extends Gizmo {
  43229. /**
  43230. * Drag behavior responsible for the gizmos dragging interactions
  43231. */
  43232. dragBehavior: PointerDragBehavior;
  43233. private _pointerObserver;
  43234. /**
  43235. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43236. */
  43237. snapDistance: number;
  43238. /**
  43239. * Event that fires each time the gizmo snaps to a new location.
  43240. * * snapDistance is the the change in distance
  43241. */
  43242. onSnapObservable: Observable<{
  43243. snapDistance: number;
  43244. }>;
  43245. /**
  43246. * Creates a PlaneRotationGizmo
  43247. * @param gizmoLayer The utility layer the gizmo will be added to
  43248. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43249. * @param color The color of the gizmo
  43250. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43251. */
  43252. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43254. /**
  43255. * Disposes of the gizmo
  43256. */
  43257. dispose(): void;
  43258. }
  43259. }
  43260. declare module "babylonjs/Gizmos/rotationGizmo" {
  43261. import { Observable } from "babylonjs/Misc/observable";
  43262. import { Nullable } from "babylonjs/types";
  43263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43264. import { Mesh } from "babylonjs/Meshes/mesh";
  43265. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43266. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43267. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43268. /**
  43269. * Gizmo that enables rotating a mesh along 3 axis
  43270. */
  43271. export class RotationGizmo extends Gizmo {
  43272. /**
  43273. * Internal gizmo used for interactions on the x axis
  43274. */
  43275. xGizmo: PlaneRotationGizmo;
  43276. /**
  43277. * Internal gizmo used for interactions on the y axis
  43278. */
  43279. yGizmo: PlaneRotationGizmo;
  43280. /**
  43281. * Internal gizmo used for interactions on the z axis
  43282. */
  43283. zGizmo: PlaneRotationGizmo;
  43284. /** Fires an event when any of it's sub gizmos are dragged */
  43285. onDragStartObservable: Observable<{}>;
  43286. /** Fires an event when any of it's sub gizmos are released from dragging */
  43287. onDragEndObservable: Observable<{}>;
  43288. attachedMesh: Nullable<AbstractMesh>;
  43289. /**
  43290. * Creates a RotationGizmo
  43291. * @param gizmoLayer The utility layer the gizmo will be added to
  43292. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43293. */
  43294. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43295. updateGizmoRotationToMatchAttachedMesh: boolean;
  43296. /**
  43297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43298. */
  43299. snapDistance: number;
  43300. /**
  43301. * Ratio for the scale of the gizmo (Default: 1)
  43302. */
  43303. scaleRatio: number;
  43304. /**
  43305. * Disposes of the gizmo
  43306. */
  43307. dispose(): void;
  43308. /**
  43309. * CustomMeshes are not supported by this gizmo
  43310. * @param mesh The mesh to replace the default mesh of the gizmo
  43311. */
  43312. setCustomMesh(mesh: Mesh): void;
  43313. }
  43314. }
  43315. declare module "babylonjs/Gizmos/positionGizmo" {
  43316. import { Observable } from "babylonjs/Misc/observable";
  43317. import { Nullable } from "babylonjs/types";
  43318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43319. import { Mesh } from "babylonjs/Meshes/mesh";
  43320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43321. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43322. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43323. /**
  43324. * Gizmo that enables dragging a mesh along 3 axis
  43325. */
  43326. export class PositionGizmo extends Gizmo {
  43327. /**
  43328. * Internal gizmo used for interactions on the x axis
  43329. */
  43330. xGizmo: AxisDragGizmo;
  43331. /**
  43332. * Internal gizmo used for interactions on the y axis
  43333. */
  43334. yGizmo: AxisDragGizmo;
  43335. /**
  43336. * Internal gizmo used for interactions on the z axis
  43337. */
  43338. zGizmo: AxisDragGizmo;
  43339. /** Fires an event when any of it's sub gizmos are dragged */
  43340. onDragStartObservable: Observable<{}>;
  43341. /** Fires an event when any of it's sub gizmos are released from dragging */
  43342. onDragEndObservable: Observable<{}>;
  43343. attachedMesh: Nullable<AbstractMesh>;
  43344. /**
  43345. * Creates a PositionGizmo
  43346. * @param gizmoLayer The utility layer the gizmo will be added to
  43347. */
  43348. constructor(gizmoLayer?: UtilityLayerRenderer);
  43349. updateGizmoRotationToMatchAttachedMesh: boolean;
  43350. /**
  43351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43352. */
  43353. snapDistance: number;
  43354. /**
  43355. * Ratio for the scale of the gizmo (Default: 1)
  43356. */
  43357. scaleRatio: number;
  43358. /**
  43359. * Disposes of the gizmo
  43360. */
  43361. dispose(): void;
  43362. /**
  43363. * CustomMeshes are not supported by this gizmo
  43364. * @param mesh The mesh to replace the default mesh of the gizmo
  43365. */
  43366. setCustomMesh(mesh: Mesh): void;
  43367. }
  43368. }
  43369. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43370. import { Scene } from "babylonjs/scene";
  43371. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43372. import { Mesh } from "babylonjs/Meshes/mesh";
  43373. /**
  43374. * Class containing static functions to help procedurally build meshes
  43375. */
  43376. export class PolyhedronBuilder {
  43377. /**
  43378. * Creates a polyhedron mesh
  43379. * * 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
  43380. * * The parameter `size` (positive float, default 1) sets the polygon size
  43381. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43382. * * 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`
  43383. * * 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
  43384. * * 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)`)
  43385. * * 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
  43386. * * 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
  43387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43390. * @param name defines the name of the mesh
  43391. * @param options defines the options used to create the mesh
  43392. * @param scene defines the hosting scene
  43393. * @returns the polyhedron mesh
  43394. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43395. */
  43396. static CreatePolyhedron(name: string, options: {
  43397. type?: number;
  43398. size?: number;
  43399. sizeX?: number;
  43400. sizeY?: number;
  43401. sizeZ?: number;
  43402. custom?: any;
  43403. faceUV?: Vector4[];
  43404. faceColors?: Color4[];
  43405. flat?: boolean;
  43406. updatable?: boolean;
  43407. sideOrientation?: number;
  43408. frontUVs?: Vector4;
  43409. backUVs?: Vector4;
  43410. }, scene: Scene): Mesh;
  43411. }
  43412. }
  43413. declare module "babylonjs/Gizmos/scaleGizmo" {
  43414. import { Observable } from "babylonjs/Misc/observable";
  43415. import { Nullable } from "babylonjs/types";
  43416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43417. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43418. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43419. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43420. /**
  43421. * Gizmo that enables scaling a mesh along 3 axis
  43422. */
  43423. export class ScaleGizmo extends Gizmo {
  43424. /**
  43425. * Internal gizmo used for interactions on the x axis
  43426. */
  43427. xGizmo: AxisScaleGizmo;
  43428. /**
  43429. * Internal gizmo used for interactions on the y axis
  43430. */
  43431. yGizmo: AxisScaleGizmo;
  43432. /**
  43433. * Internal gizmo used for interactions on the z axis
  43434. */
  43435. zGizmo: AxisScaleGizmo;
  43436. /**
  43437. * Internal gizmo used to scale all axis equally
  43438. */
  43439. uniformScaleGizmo: AxisScaleGizmo;
  43440. /** Fires an event when any of it's sub gizmos are dragged */
  43441. onDragStartObservable: Observable<{}>;
  43442. /** Fires an event when any of it's sub gizmos are released from dragging */
  43443. onDragEndObservable: Observable<{}>;
  43444. attachedMesh: Nullable<AbstractMesh>;
  43445. /**
  43446. * Creates a ScaleGizmo
  43447. * @param gizmoLayer The utility layer the gizmo will be added to
  43448. */
  43449. constructor(gizmoLayer?: UtilityLayerRenderer);
  43450. updateGizmoRotationToMatchAttachedMesh: boolean;
  43451. /**
  43452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43453. */
  43454. snapDistance: number;
  43455. /**
  43456. * Ratio for the scale of the gizmo (Default: 1)
  43457. */
  43458. scaleRatio: number;
  43459. /**
  43460. * Disposes of the gizmo
  43461. */
  43462. dispose(): void;
  43463. }
  43464. }
  43465. declare module "babylonjs/Gizmos/gizmoManager" {
  43466. import { Observable } from "babylonjs/Misc/observable";
  43467. import { Nullable } from "babylonjs/types";
  43468. import { Scene, IDisposable } from "babylonjs/scene";
  43469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43470. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43471. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43472. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43473. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43474. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43475. /**
  43476. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43477. */
  43478. export class GizmoManager implements IDisposable {
  43479. private scene;
  43480. /**
  43481. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43482. */
  43483. gizmos: {
  43484. positionGizmo: Nullable<PositionGizmo>;
  43485. rotationGizmo: Nullable<RotationGizmo>;
  43486. scaleGizmo: Nullable<ScaleGizmo>;
  43487. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43488. };
  43489. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43490. clearGizmoOnEmptyPointerEvent: boolean;
  43491. /** Fires an event when the manager is attached to a mesh */
  43492. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43493. private _gizmosEnabled;
  43494. private _pointerObserver;
  43495. private _attachedMesh;
  43496. private _boundingBoxColor;
  43497. private _defaultUtilityLayer;
  43498. private _defaultKeepDepthUtilityLayer;
  43499. /**
  43500. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43501. */
  43502. boundingBoxDragBehavior: SixDofDragBehavior;
  43503. /**
  43504. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43505. */
  43506. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43507. /**
  43508. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43509. */
  43510. usePointerToAttachGizmos: boolean;
  43511. /**
  43512. * Instatiates a gizmo manager
  43513. * @param scene the scene to overlay the gizmos on top of
  43514. */
  43515. constructor(scene: Scene);
  43516. /**
  43517. * Attaches a set of gizmos to the specified mesh
  43518. * @param mesh The mesh the gizmo's should be attached to
  43519. */
  43520. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43521. /**
  43522. * If the position gizmo is enabled
  43523. */
  43524. positionGizmoEnabled: boolean;
  43525. /**
  43526. * If the rotation gizmo is enabled
  43527. */
  43528. rotationGizmoEnabled: boolean;
  43529. /**
  43530. * If the scale gizmo is enabled
  43531. */
  43532. scaleGizmoEnabled: boolean;
  43533. /**
  43534. * If the boundingBox gizmo is enabled
  43535. */
  43536. boundingBoxGizmoEnabled: boolean;
  43537. /**
  43538. * Disposes of the gizmo manager
  43539. */
  43540. dispose(): void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Gizmos/lightGizmo" {
  43544. import { Nullable } from "babylonjs/types";
  43545. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43546. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43547. import { Light } from "babylonjs/Lights/light";
  43548. /**
  43549. * Gizmo that enables viewing a light
  43550. */
  43551. export class LightGizmo extends Gizmo {
  43552. private _box;
  43553. /**
  43554. * Creates a LightGizmo
  43555. * @param gizmoLayer The utility layer the gizmo will be added to
  43556. */
  43557. constructor(gizmoLayer?: UtilityLayerRenderer);
  43558. private _light;
  43559. /**
  43560. * The light that the gizmo is attached to
  43561. */
  43562. light: Nullable<Light>;
  43563. /**
  43564. * @hidden
  43565. * Updates the gizmo to match the attached mesh's position/rotation
  43566. */
  43567. protected _update(): void;
  43568. }
  43569. }
  43570. declare module "babylonjs/Gizmos/index" {
  43571. export * from "babylonjs/Gizmos/axisDragGizmo";
  43572. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43573. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43574. export * from "babylonjs/Gizmos/gizmo";
  43575. export * from "babylonjs/Gizmos/gizmoManager";
  43576. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43577. export * from "babylonjs/Gizmos/positionGizmo";
  43578. export * from "babylonjs/Gizmos/rotationGizmo";
  43579. export * from "babylonjs/Gizmos/scaleGizmo";
  43580. export * from "babylonjs/Gizmos/lightGizmo";
  43581. }
  43582. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43583. /** @hidden */
  43584. export var backgroundFragmentDeclaration: {
  43585. name: string;
  43586. shader: string;
  43587. };
  43588. }
  43589. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43590. /** @hidden */
  43591. export var backgroundUboDeclaration: {
  43592. name: string;
  43593. shader: string;
  43594. };
  43595. }
  43596. declare module "babylonjs/Shaders/background.fragment" {
  43597. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43598. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43599. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43600. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43601. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43602. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43604. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43605. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43608. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43609. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43610. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43611. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43612. /** @hidden */
  43613. export var backgroundPixelShader: {
  43614. name: string;
  43615. shader: string;
  43616. };
  43617. }
  43618. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43619. /** @hidden */
  43620. export var backgroundVertexDeclaration: {
  43621. name: string;
  43622. shader: string;
  43623. };
  43624. }
  43625. declare module "babylonjs/Shaders/background.vertex" {
  43626. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43627. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43628. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43629. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43632. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43633. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43634. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43638. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43639. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43640. /** @hidden */
  43641. export var backgroundVertexShader: {
  43642. name: string;
  43643. shader: string;
  43644. };
  43645. }
  43646. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43647. import { Nullable, int, float } from "babylonjs/types";
  43648. import { Scene } from "babylonjs/scene";
  43649. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43652. import { Mesh } from "babylonjs/Meshes/mesh";
  43653. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43654. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43655. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43657. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43658. import "babylonjs/Shaders/background.fragment";
  43659. import "babylonjs/Shaders/background.vertex";
  43660. /**
  43661. * Background material used to create an efficient environement around your scene.
  43662. */
  43663. export class BackgroundMaterial extends PushMaterial {
  43664. /**
  43665. * Standard reflectance value at parallel view angle.
  43666. */
  43667. static StandardReflectance0: number;
  43668. /**
  43669. * Standard reflectance value at grazing angle.
  43670. */
  43671. static StandardReflectance90: number;
  43672. protected _primaryColor: Color3;
  43673. /**
  43674. * Key light Color (multiply against the environement texture)
  43675. */
  43676. primaryColor: Color3;
  43677. protected __perceptualColor: Nullable<Color3>;
  43678. /**
  43679. * Experimental Internal Use Only.
  43680. *
  43681. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43682. * This acts as a helper to set the primary color to a more "human friendly" value.
  43683. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43684. * output color as close as possible from the chosen value.
  43685. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43686. * part of lighting setup.)
  43687. */
  43688. _perceptualColor: Nullable<Color3>;
  43689. protected _primaryColorShadowLevel: float;
  43690. /**
  43691. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43692. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43693. */
  43694. primaryColorShadowLevel: float;
  43695. protected _primaryColorHighlightLevel: float;
  43696. /**
  43697. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43698. * The primary color is used at the level chosen to define what the white area would look.
  43699. */
  43700. primaryColorHighlightLevel: float;
  43701. protected _reflectionTexture: Nullable<BaseTexture>;
  43702. /**
  43703. * Reflection Texture used in the material.
  43704. * Should be author in a specific way for the best result (refer to the documentation).
  43705. */
  43706. reflectionTexture: Nullable<BaseTexture>;
  43707. protected _reflectionBlur: float;
  43708. /**
  43709. * Reflection Texture level of blur.
  43710. *
  43711. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43712. * texture twice.
  43713. */
  43714. reflectionBlur: float;
  43715. protected _diffuseTexture: Nullable<BaseTexture>;
  43716. /**
  43717. * Diffuse Texture used in the material.
  43718. * Should be author in a specific way for the best result (refer to the documentation).
  43719. */
  43720. diffuseTexture: Nullable<BaseTexture>;
  43721. protected _shadowLights: Nullable<IShadowLight[]>;
  43722. /**
  43723. * Specify the list of lights casting shadow on the material.
  43724. * All scene shadow lights will be included if null.
  43725. */
  43726. shadowLights: Nullable<IShadowLight[]>;
  43727. protected _shadowLevel: float;
  43728. /**
  43729. * Helps adjusting the shadow to a softer level if required.
  43730. * 0 means black shadows and 1 means no shadows.
  43731. */
  43732. shadowLevel: float;
  43733. protected _sceneCenter: Vector3;
  43734. /**
  43735. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43736. * It is usually zero but might be interesting to modify according to your setup.
  43737. */
  43738. sceneCenter: Vector3;
  43739. protected _opacityFresnel: boolean;
  43740. /**
  43741. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43742. * This helps ensuring a nice transition when the camera goes under the ground.
  43743. */
  43744. opacityFresnel: boolean;
  43745. protected _reflectionFresnel: boolean;
  43746. /**
  43747. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43748. * This helps adding a mirror texture on the ground.
  43749. */
  43750. reflectionFresnel: boolean;
  43751. protected _reflectionFalloffDistance: number;
  43752. /**
  43753. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43754. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43755. */
  43756. reflectionFalloffDistance: number;
  43757. protected _reflectionAmount: number;
  43758. /**
  43759. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43760. */
  43761. reflectionAmount: number;
  43762. protected _reflectionReflectance0: number;
  43763. /**
  43764. * This specifies the weight of the reflection at grazing angle.
  43765. */
  43766. reflectionReflectance0: number;
  43767. protected _reflectionReflectance90: number;
  43768. /**
  43769. * This specifies the weight of the reflection at a perpendicular point of view.
  43770. */
  43771. reflectionReflectance90: number;
  43772. /**
  43773. * Sets the reflection reflectance fresnel values according to the default standard
  43774. * empirically know to work well :-)
  43775. */
  43776. reflectionStandardFresnelWeight: number;
  43777. protected _useRGBColor: boolean;
  43778. /**
  43779. * Helps to directly use the maps channels instead of their level.
  43780. */
  43781. useRGBColor: boolean;
  43782. protected _enableNoise: boolean;
  43783. /**
  43784. * This helps reducing the banding effect that could occur on the background.
  43785. */
  43786. enableNoise: boolean;
  43787. /**
  43788. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43789. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43790. * Recommended to be keep at 1.0 except for special cases.
  43791. */
  43792. fovMultiplier: number;
  43793. private _fovMultiplier;
  43794. /**
  43795. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43796. */
  43797. useEquirectangularFOV: boolean;
  43798. private _maxSimultaneousLights;
  43799. /**
  43800. * Number of Simultaneous lights allowed on the material.
  43801. */
  43802. maxSimultaneousLights: int;
  43803. /**
  43804. * Default configuration related to image processing available in the Background Material.
  43805. */
  43806. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43807. /**
  43808. * Keep track of the image processing observer to allow dispose and replace.
  43809. */
  43810. private _imageProcessingObserver;
  43811. /**
  43812. * Attaches a new image processing configuration to the PBR Material.
  43813. * @param configuration (if null the scene configuration will be use)
  43814. */
  43815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43816. /**
  43817. * Gets the image processing configuration used either in this material.
  43818. */
  43819. /**
  43820. * Sets the Default image processing configuration used either in the this material.
  43821. *
  43822. * If sets to null, the scene one is in use.
  43823. */
  43824. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43825. /**
  43826. * Gets wether the color curves effect is enabled.
  43827. */
  43828. /**
  43829. * Sets wether the color curves effect is enabled.
  43830. */
  43831. cameraColorCurvesEnabled: boolean;
  43832. /**
  43833. * Gets wether the color grading effect is enabled.
  43834. */
  43835. /**
  43836. * Gets wether the color grading effect is enabled.
  43837. */
  43838. cameraColorGradingEnabled: boolean;
  43839. /**
  43840. * Gets wether tonemapping is enabled or not.
  43841. */
  43842. /**
  43843. * Sets wether tonemapping is enabled or not
  43844. */
  43845. cameraToneMappingEnabled: boolean;
  43846. /**
  43847. * The camera exposure used on this material.
  43848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43849. * This corresponds to a photographic exposure.
  43850. */
  43851. /**
  43852. * The camera exposure used on this material.
  43853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43854. * This corresponds to a photographic exposure.
  43855. */
  43856. cameraExposure: float;
  43857. /**
  43858. * Gets The camera contrast used on this material.
  43859. */
  43860. /**
  43861. * Sets The camera contrast used on this material.
  43862. */
  43863. cameraContrast: float;
  43864. /**
  43865. * Gets the Color Grading 2D Lookup Texture.
  43866. */
  43867. /**
  43868. * Sets the Color Grading 2D Lookup Texture.
  43869. */
  43870. cameraColorGradingTexture: Nullable<BaseTexture>;
  43871. /**
  43872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43874. * 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;
  43875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43876. */
  43877. /**
  43878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43880. * 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;
  43881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43882. */
  43883. cameraColorCurves: Nullable<ColorCurves>;
  43884. /**
  43885. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43886. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43887. */
  43888. switchToBGR: boolean;
  43889. private _renderTargets;
  43890. private _reflectionControls;
  43891. private _white;
  43892. private _primaryShadowColor;
  43893. private _primaryHighlightColor;
  43894. /**
  43895. * Instantiates a Background Material in the given scene
  43896. * @param name The friendly name of the material
  43897. * @param scene The scene to add the material to
  43898. */
  43899. constructor(name: string, scene: Scene);
  43900. /**
  43901. * Gets a boolean indicating that current material needs to register RTT
  43902. */
  43903. readonly hasRenderTargetTextures: boolean;
  43904. /**
  43905. * The entire material has been created in order to prevent overdraw.
  43906. * @returns false
  43907. */
  43908. needAlphaTesting(): boolean;
  43909. /**
  43910. * The entire material has been created in order to prevent overdraw.
  43911. * @returns true if blending is enable
  43912. */
  43913. needAlphaBlending(): boolean;
  43914. /**
  43915. * Checks wether the material is ready to be rendered for a given mesh.
  43916. * @param mesh The mesh to render
  43917. * @param subMesh The submesh to check against
  43918. * @param useInstances Specify wether or not the material is used with instances
  43919. * @returns true if all the dependencies are ready (Textures, Effects...)
  43920. */
  43921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43922. /**
  43923. * Compute the primary color according to the chosen perceptual color.
  43924. */
  43925. private _computePrimaryColorFromPerceptualColor;
  43926. /**
  43927. * Compute the highlights and shadow colors according to their chosen levels.
  43928. */
  43929. private _computePrimaryColors;
  43930. /**
  43931. * Build the uniform buffer used in the material.
  43932. */
  43933. buildUniformLayout(): void;
  43934. /**
  43935. * Unbind the material.
  43936. */
  43937. unbind(): void;
  43938. /**
  43939. * Bind only the world matrix to the material.
  43940. * @param world The world matrix to bind.
  43941. */
  43942. bindOnlyWorldMatrix(world: Matrix): void;
  43943. /**
  43944. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43945. * @param world The world matrix to bind.
  43946. * @param subMesh The submesh to bind for.
  43947. */
  43948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43949. /**
  43950. * Dispose the material.
  43951. * @param forceDisposeEffect Force disposal of the associated effect.
  43952. * @param forceDisposeTextures Force disposal of the associated textures.
  43953. */
  43954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43955. /**
  43956. * Clones the material.
  43957. * @param name The cloned name.
  43958. * @returns The cloned material.
  43959. */
  43960. clone(name: string): BackgroundMaterial;
  43961. /**
  43962. * Serializes the current material to its JSON representation.
  43963. * @returns The JSON representation.
  43964. */
  43965. serialize(): any;
  43966. /**
  43967. * Gets the class name of the material
  43968. * @returns "BackgroundMaterial"
  43969. */
  43970. getClassName(): string;
  43971. /**
  43972. * Parse a JSON input to create back a background material.
  43973. * @param source The JSON data to parse
  43974. * @param scene The scene to create the parsed material in
  43975. * @param rootUrl The root url of the assets the material depends upon
  43976. * @returns the instantiated BackgroundMaterial.
  43977. */
  43978. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43979. }
  43980. }
  43981. declare module "babylonjs/Helpers/environmentHelper" {
  43982. import { Observable } from "babylonjs/Misc/observable";
  43983. import { Nullable } from "babylonjs/types";
  43984. import { Scene } from "babylonjs/scene";
  43985. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43987. import { Mesh } from "babylonjs/Meshes/mesh";
  43988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43989. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43990. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43991. import "babylonjs/Meshes/Builders/planeBuilder";
  43992. import "babylonjs/Meshes/Builders/boxBuilder";
  43993. /**
  43994. * Represents the different options available during the creation of
  43995. * a Environment helper.
  43996. *
  43997. * This can control the default ground, skybox and image processing setup of your scene.
  43998. */
  43999. export interface IEnvironmentHelperOptions {
  44000. /**
  44001. * Specifies wether or not to create a ground.
  44002. * True by default.
  44003. */
  44004. createGround: boolean;
  44005. /**
  44006. * Specifies the ground size.
  44007. * 15 by default.
  44008. */
  44009. groundSize: number;
  44010. /**
  44011. * The texture used on the ground for the main color.
  44012. * Comes from the BabylonJS CDN by default.
  44013. *
  44014. * Remarks: Can be either a texture or a url.
  44015. */
  44016. groundTexture: string | BaseTexture;
  44017. /**
  44018. * The color mixed in the ground texture by default.
  44019. * BabylonJS clearColor by default.
  44020. */
  44021. groundColor: Color3;
  44022. /**
  44023. * Specifies the ground opacity.
  44024. * 1 by default.
  44025. */
  44026. groundOpacity: number;
  44027. /**
  44028. * Enables the ground to receive shadows.
  44029. * True by default.
  44030. */
  44031. enableGroundShadow: boolean;
  44032. /**
  44033. * Helps preventing the shadow to be fully black on the ground.
  44034. * 0.5 by default.
  44035. */
  44036. groundShadowLevel: number;
  44037. /**
  44038. * Creates a mirror texture attach to the ground.
  44039. * false by default.
  44040. */
  44041. enableGroundMirror: boolean;
  44042. /**
  44043. * Specifies the ground mirror size ratio.
  44044. * 0.3 by default as the default kernel is 64.
  44045. */
  44046. groundMirrorSizeRatio: number;
  44047. /**
  44048. * Specifies the ground mirror blur kernel size.
  44049. * 64 by default.
  44050. */
  44051. groundMirrorBlurKernel: number;
  44052. /**
  44053. * Specifies the ground mirror visibility amount.
  44054. * 1 by default
  44055. */
  44056. groundMirrorAmount: number;
  44057. /**
  44058. * Specifies the ground mirror reflectance weight.
  44059. * This uses the standard weight of the background material to setup the fresnel effect
  44060. * of the mirror.
  44061. * 1 by default.
  44062. */
  44063. groundMirrorFresnelWeight: number;
  44064. /**
  44065. * Specifies the ground mirror Falloff distance.
  44066. * This can helps reducing the size of the reflection.
  44067. * 0 by Default.
  44068. */
  44069. groundMirrorFallOffDistance: number;
  44070. /**
  44071. * Specifies the ground mirror texture type.
  44072. * Unsigned Int by Default.
  44073. */
  44074. groundMirrorTextureType: number;
  44075. /**
  44076. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44077. * the shown objects.
  44078. */
  44079. groundYBias: number;
  44080. /**
  44081. * Specifies wether or not to create a skybox.
  44082. * True by default.
  44083. */
  44084. createSkybox: boolean;
  44085. /**
  44086. * Specifies the skybox size.
  44087. * 20 by default.
  44088. */
  44089. skyboxSize: number;
  44090. /**
  44091. * The texture used on the skybox for the main color.
  44092. * Comes from the BabylonJS CDN by default.
  44093. *
  44094. * Remarks: Can be either a texture or a url.
  44095. */
  44096. skyboxTexture: string | BaseTexture;
  44097. /**
  44098. * The color mixed in the skybox texture by default.
  44099. * BabylonJS clearColor by default.
  44100. */
  44101. skyboxColor: Color3;
  44102. /**
  44103. * The background rotation around the Y axis of the scene.
  44104. * This helps aligning the key lights of your scene with the background.
  44105. * 0 by default.
  44106. */
  44107. backgroundYRotation: number;
  44108. /**
  44109. * Compute automatically the size of the elements to best fit with the scene.
  44110. */
  44111. sizeAuto: boolean;
  44112. /**
  44113. * Default position of the rootMesh if autoSize is not true.
  44114. */
  44115. rootPosition: Vector3;
  44116. /**
  44117. * Sets up the image processing in the scene.
  44118. * true by default.
  44119. */
  44120. setupImageProcessing: boolean;
  44121. /**
  44122. * The texture used as your environment texture in the scene.
  44123. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44124. *
  44125. * Remarks: Can be either a texture or a url.
  44126. */
  44127. environmentTexture: string | BaseTexture;
  44128. /**
  44129. * The value of the exposure to apply to the scene.
  44130. * 0.6 by default if setupImageProcessing is true.
  44131. */
  44132. cameraExposure: number;
  44133. /**
  44134. * The value of the contrast to apply to the scene.
  44135. * 1.6 by default if setupImageProcessing is true.
  44136. */
  44137. cameraContrast: number;
  44138. /**
  44139. * Specifies wether or not tonemapping should be enabled in the scene.
  44140. * true by default if setupImageProcessing is true.
  44141. */
  44142. toneMappingEnabled: boolean;
  44143. }
  44144. /**
  44145. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44146. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44147. * It also helps with the default setup of your imageProcessing configuration.
  44148. */
  44149. export class EnvironmentHelper {
  44150. /**
  44151. * Default ground texture URL.
  44152. */
  44153. private static _groundTextureCDNUrl;
  44154. /**
  44155. * Default skybox texture URL.
  44156. */
  44157. private static _skyboxTextureCDNUrl;
  44158. /**
  44159. * Default environment texture URL.
  44160. */
  44161. private static _environmentTextureCDNUrl;
  44162. /**
  44163. * Creates the default options for the helper.
  44164. */
  44165. private static _getDefaultOptions;
  44166. private _rootMesh;
  44167. /**
  44168. * Gets the root mesh created by the helper.
  44169. */
  44170. readonly rootMesh: Mesh;
  44171. private _skybox;
  44172. /**
  44173. * Gets the skybox created by the helper.
  44174. */
  44175. readonly skybox: Nullable<Mesh>;
  44176. private _skyboxTexture;
  44177. /**
  44178. * Gets the skybox texture created by the helper.
  44179. */
  44180. readonly skyboxTexture: Nullable<BaseTexture>;
  44181. private _skyboxMaterial;
  44182. /**
  44183. * Gets the skybox material created by the helper.
  44184. */
  44185. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44186. private _ground;
  44187. /**
  44188. * Gets the ground mesh created by the helper.
  44189. */
  44190. readonly ground: Nullable<Mesh>;
  44191. private _groundTexture;
  44192. /**
  44193. * Gets the ground texture created by the helper.
  44194. */
  44195. readonly groundTexture: Nullable<BaseTexture>;
  44196. private _groundMirror;
  44197. /**
  44198. * Gets the ground mirror created by the helper.
  44199. */
  44200. readonly groundMirror: Nullable<MirrorTexture>;
  44201. /**
  44202. * Gets the ground mirror render list to helps pushing the meshes
  44203. * you wish in the ground reflection.
  44204. */
  44205. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44206. private _groundMaterial;
  44207. /**
  44208. * Gets the ground material created by the helper.
  44209. */
  44210. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44211. /**
  44212. * Stores the creation options.
  44213. */
  44214. private readonly _scene;
  44215. private _options;
  44216. /**
  44217. * This observable will be notified with any error during the creation of the environment,
  44218. * mainly texture creation errors.
  44219. */
  44220. onErrorObservable: Observable<{
  44221. message?: string;
  44222. exception?: any;
  44223. }>;
  44224. /**
  44225. * constructor
  44226. * @param options Defines the options we want to customize the helper
  44227. * @param scene The scene to add the material to
  44228. */
  44229. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44230. /**
  44231. * Updates the background according to the new options
  44232. * @param options
  44233. */
  44234. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44235. /**
  44236. * Sets the primary color of all the available elements.
  44237. * @param color the main color to affect to the ground and the background
  44238. */
  44239. setMainColor(color: Color3): void;
  44240. /**
  44241. * Setup the image processing according to the specified options.
  44242. */
  44243. private _setupImageProcessing;
  44244. /**
  44245. * Setup the environment texture according to the specified options.
  44246. */
  44247. private _setupEnvironmentTexture;
  44248. /**
  44249. * Setup the background according to the specified options.
  44250. */
  44251. private _setupBackground;
  44252. /**
  44253. * Get the scene sizes according to the setup.
  44254. */
  44255. private _getSceneSize;
  44256. /**
  44257. * Setup the ground according to the specified options.
  44258. */
  44259. private _setupGround;
  44260. /**
  44261. * Setup the ground material according to the specified options.
  44262. */
  44263. private _setupGroundMaterial;
  44264. /**
  44265. * Setup the ground diffuse texture according to the specified options.
  44266. */
  44267. private _setupGroundDiffuseTexture;
  44268. /**
  44269. * Setup the ground mirror texture according to the specified options.
  44270. */
  44271. private _setupGroundMirrorTexture;
  44272. /**
  44273. * Setup the ground to receive the mirror texture.
  44274. */
  44275. private _setupMirrorInGroundMaterial;
  44276. /**
  44277. * Setup the skybox according to the specified options.
  44278. */
  44279. private _setupSkybox;
  44280. /**
  44281. * Setup the skybox material according to the specified options.
  44282. */
  44283. private _setupSkyboxMaterial;
  44284. /**
  44285. * Setup the skybox reflection texture according to the specified options.
  44286. */
  44287. private _setupSkyboxReflectionTexture;
  44288. private _errorHandler;
  44289. /**
  44290. * Dispose all the elements created by the Helper.
  44291. */
  44292. dispose(): void;
  44293. }
  44294. }
  44295. declare module "babylonjs/Helpers/photoDome" {
  44296. import { Observable } from "babylonjs/Misc/observable";
  44297. import { Nullable } from "babylonjs/types";
  44298. import { Scene } from "babylonjs/scene";
  44299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44300. import { Mesh } from "babylonjs/Meshes/mesh";
  44301. import { Texture } from "babylonjs/Materials/Textures/texture";
  44302. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44303. import "babylonjs/Meshes/Builders/sphereBuilder";
  44304. /**
  44305. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44306. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44307. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44308. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44309. */
  44310. export class PhotoDome extends TransformNode {
  44311. private _useDirectMapping;
  44312. /**
  44313. * The texture being displayed on the sphere
  44314. */
  44315. protected _photoTexture: Texture;
  44316. /**
  44317. * Gets or sets the texture being displayed on the sphere
  44318. */
  44319. photoTexture: Texture;
  44320. /**
  44321. * Observable raised when an error occured while loading the 360 image
  44322. */
  44323. onLoadErrorObservable: Observable<string>;
  44324. /**
  44325. * The skybox material
  44326. */
  44327. protected _material: BackgroundMaterial;
  44328. /**
  44329. * The surface used for the skybox
  44330. */
  44331. protected _mesh: Mesh;
  44332. /**
  44333. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44334. * Also see the options.resolution property.
  44335. */
  44336. fovMultiplier: number;
  44337. /**
  44338. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44339. * @param name Element's name, child elements will append suffixes for their own names.
  44340. * @param urlsOfPhoto defines the url of the photo to display
  44341. * @param options defines an object containing optional or exposed sub element properties
  44342. * @param onError defines a callback called when an error occured while loading the texture
  44343. */
  44344. constructor(name: string, urlOfPhoto: string, options: {
  44345. resolution?: number;
  44346. size?: number;
  44347. useDirectMapping?: boolean;
  44348. faceForward?: boolean;
  44349. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44350. /**
  44351. * Releases resources associated with this node.
  44352. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44353. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44354. */
  44355. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44356. }
  44357. }
  44358. declare module "babylonjs/Misc/textureTools" {
  44359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44360. import { Texture } from "babylonjs/Materials/Textures/texture";
  44361. import { Scene } from "babylonjs/scene";
  44362. /**
  44363. * Class used to host texture specific utilities
  44364. */
  44365. export class TextureTools {
  44366. /**
  44367. * Uses the GPU to create a copy texture rescaled at a given size
  44368. * @param texture Texture to copy from
  44369. * @param width defines the desired width
  44370. * @param height defines the desired height
  44371. * @param useBilinearMode defines if bilinear mode has to be used
  44372. * @return the generated texture
  44373. */
  44374. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44375. /**
  44376. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44377. * @param scene defines the hosting scene
  44378. * @returns the environment BRDF texture
  44379. */
  44380. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44381. private static _environmentBRDFBase64Texture;
  44382. }
  44383. }
  44384. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44385. import { Nullable } from "babylonjs/types";
  44386. import { IAnimatable } from "babylonjs/Misc/tools";
  44387. import { Color3 } from "babylonjs/Maths/math";
  44388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44389. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44390. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44391. import { Engine } from "babylonjs/Engines/engine";
  44392. import { Scene } from "babylonjs/scene";
  44393. /**
  44394. * @hidden
  44395. */
  44396. export interface IMaterialClearCoatDefines {
  44397. CLEARCOAT: boolean;
  44398. CLEARCOAT_DEFAULTIOR: boolean;
  44399. CLEARCOAT_TEXTURE: boolean;
  44400. CLEARCOAT_TEXTUREDIRECTUV: number;
  44401. CLEARCOAT_BUMP: boolean;
  44402. CLEARCOAT_BUMPDIRECTUV: number;
  44403. CLEARCOAT_TINT: boolean;
  44404. CLEARCOAT_TINT_TEXTURE: boolean;
  44405. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44406. /** @hidden */
  44407. _areTexturesDirty: boolean;
  44408. }
  44409. /**
  44410. * Define the code related to the clear coat parameters of the pbr material.
  44411. */
  44412. export class PBRClearCoatConfiguration {
  44413. /**
  44414. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44415. * The default fits with a polyurethane material.
  44416. */
  44417. private static readonly _DefaultIndiceOfRefraction;
  44418. private _isEnabled;
  44419. /**
  44420. * Defines if the clear coat is enabled in the material.
  44421. */
  44422. isEnabled: boolean;
  44423. /**
  44424. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44425. */
  44426. intensity: number;
  44427. /**
  44428. * Defines the clear coat layer roughness.
  44429. */
  44430. roughness: number;
  44431. private _indiceOfRefraction;
  44432. /**
  44433. * Defines the indice of refraction of the clear coat.
  44434. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44435. * The default fits with a polyurethane material.
  44436. * Changing the default value is more performance intensive.
  44437. */
  44438. indiceOfRefraction: number;
  44439. private _texture;
  44440. /**
  44441. * Stores the clear coat values in a texture.
  44442. */
  44443. texture: Nullable<BaseTexture>;
  44444. private _bumpTexture;
  44445. /**
  44446. * Define the clear coat specific bump texture.
  44447. */
  44448. bumpTexture: Nullable<BaseTexture>;
  44449. private _isTintEnabled;
  44450. /**
  44451. * Defines if the clear coat tint is enabled in the material.
  44452. */
  44453. isTintEnabled: boolean;
  44454. /**
  44455. * Defines if the clear coat tint is enabled in the material.
  44456. * This is only use if tint is enabled
  44457. */
  44458. tintColor: Color3;
  44459. /**
  44460. * Defines if the distance at which the tint color should be found in the
  44461. * clear coat media.
  44462. * This is only use if tint is enabled
  44463. */
  44464. tintColorAtDistance: number;
  44465. /**
  44466. * Defines the clear coat layer thickness.
  44467. * This is only use if tint is enabled
  44468. */
  44469. tintThickness: number;
  44470. private _tintTexture;
  44471. /**
  44472. * Stores the clear tint values in a texture.
  44473. * rgb is tint
  44474. * a is a thickness factor
  44475. */
  44476. tintTexture: Nullable<BaseTexture>;
  44477. /** @hidden */
  44478. private _internalMarkAllSubMeshesAsTexturesDirty;
  44479. /** @hidden */
  44480. _markAllSubMeshesAsTexturesDirty(): void;
  44481. /**
  44482. * Instantiate a new istance of clear coat configuration.
  44483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44484. */
  44485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44486. /**
  44487. * Specifies that the submesh is ready to be used.
  44488. * @param defines the list of "defines" to update.
  44489. * @param scene defines the scene the material belongs to.
  44490. * @param engine defines the engine the material belongs to.
  44491. * @param disableBumpMap defines wether the material disables bump or not.
  44492. * @returns - boolean indicating that the submesh is ready or not.
  44493. */
  44494. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44495. /**
  44496. * Checks to see if a texture is used in the material.
  44497. * @param defines the list of "defines" to update.
  44498. * @param scene defines the scene to the material belongs to.
  44499. */
  44500. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44501. /**
  44502. * Binds the material data.
  44503. * @param uniformBuffer defines the Uniform buffer to fill in.
  44504. * @param scene defines the scene the material belongs to.
  44505. * @param engine defines the engine the material belongs to.
  44506. * @param disableBumpMap defines wether the material disables bump or not.
  44507. * @param isFrozen defines wether the material is frozen or not.
  44508. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44509. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44510. */
  44511. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44512. /**
  44513. * Checks to see if a texture is used in the material.
  44514. * @param texture - Base texture to use.
  44515. * @returns - Boolean specifying if a texture is used in the material.
  44516. */
  44517. hasTexture(texture: BaseTexture): boolean;
  44518. /**
  44519. * Returns an array of the actively used textures.
  44520. * @param activeTextures Array of BaseTextures
  44521. */
  44522. getActiveTextures(activeTextures: BaseTexture[]): void;
  44523. /**
  44524. * Returns the animatable textures.
  44525. * @param animatables Array of animatable textures.
  44526. */
  44527. getAnimatables(animatables: IAnimatable[]): void;
  44528. /**
  44529. * Disposes the resources of the material.
  44530. * @param forceDisposeTextures - Forces the disposal of all textures.
  44531. */
  44532. dispose(forceDisposeTextures?: boolean): void;
  44533. /**
  44534. * Get the current class name of the texture useful for serialization or dynamic coding.
  44535. * @returns "PBRClearCoatConfiguration"
  44536. */
  44537. getClassName(): string;
  44538. /**
  44539. * Add fallbacks to the effect fallbacks list.
  44540. * @param defines defines the Base texture to use.
  44541. * @param fallbacks defines the current fallback list.
  44542. * @param currentRank defines the current fallback rank.
  44543. * @returns the new fallback rank.
  44544. */
  44545. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44546. /**
  44547. * Add the required uniforms to the current list.
  44548. * @param uniforms defines the current uniform list.
  44549. */
  44550. static AddUniforms(uniforms: string[]): void;
  44551. /**
  44552. * Add the required samplers to the current list.
  44553. * @param samplers defines the current sampler list.
  44554. */
  44555. static AddSamplers(samplers: string[]): void;
  44556. /**
  44557. * Add the required uniforms to the current buffer.
  44558. * @param uniformBuffer defines the current uniform buffer.
  44559. */
  44560. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44561. /**
  44562. * Makes a duplicate of the current configuration into another one.
  44563. * @param clearCoatConfiguration define the config where to copy the info
  44564. */
  44565. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44566. /**
  44567. * Serializes this clear coat configuration.
  44568. * @returns - An object with the serialized config.
  44569. */
  44570. serialize(): any;
  44571. /**
  44572. * Parses a Clear Coat Configuration from a serialized object.
  44573. * @param source - Serialized object.
  44574. */
  44575. parse(source: any): void;
  44576. }
  44577. }
  44578. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44579. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44580. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44582. import { Vector2 } from "babylonjs/Maths/math";
  44583. import { Scene } from "babylonjs/scene";
  44584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44585. import { IAnimatable } from "babylonjs/Misc/tools";
  44586. import { Nullable } from "babylonjs/types";
  44587. /**
  44588. * @hidden
  44589. */
  44590. export interface IMaterialAnisotropicDefines {
  44591. ANISOTROPIC: boolean;
  44592. ANISOTROPIC_TEXTURE: boolean;
  44593. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44594. MAINUV1: boolean;
  44595. _areTexturesDirty: boolean;
  44596. _needUVs: boolean;
  44597. }
  44598. /**
  44599. * Define the code related to the anisotropic parameters of the pbr material.
  44600. */
  44601. export class PBRAnisotropicConfiguration {
  44602. private _isEnabled;
  44603. /**
  44604. * Defines if the anisotropy is enabled in the material.
  44605. */
  44606. isEnabled: boolean;
  44607. /**
  44608. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44609. */
  44610. intensity: number;
  44611. /**
  44612. * Defines if the effect is along the tangents, bitangents or in between.
  44613. * By default, the effect is "strectching" the highlights along the tangents.
  44614. */
  44615. direction: Vector2;
  44616. private _texture;
  44617. /**
  44618. * Stores the anisotropy values in a texture.
  44619. * rg is direction (like normal from -1 to 1)
  44620. * b is a intensity
  44621. */
  44622. texture: Nullable<BaseTexture>;
  44623. /** @hidden */
  44624. private _internalMarkAllSubMeshesAsTexturesDirty;
  44625. /** @hidden */
  44626. _markAllSubMeshesAsTexturesDirty(): void;
  44627. /**
  44628. * Instantiate a new istance of anisotropy configuration.
  44629. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44630. */
  44631. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44632. /**
  44633. * Specifies that the submesh is ready to be used.
  44634. * @param defines the list of "defines" to update.
  44635. * @param scene defines the scene the material belongs to.
  44636. * @returns - boolean indicating that the submesh is ready or not.
  44637. */
  44638. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44639. /**
  44640. * Checks to see if a texture is used in the material.
  44641. * @param defines the list of "defines" to update.
  44642. * @param mesh the mesh we are preparing the defines for.
  44643. * @param scene defines the scene the material belongs to.
  44644. */
  44645. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44646. /**
  44647. * Binds the material data.
  44648. * @param uniformBuffer defines the Uniform buffer to fill in.
  44649. * @param scene defines the scene the material belongs to.
  44650. * @param isFrozen defines wether the material is frozen or not.
  44651. */
  44652. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44653. /**
  44654. * Checks to see if a texture is used in the material.
  44655. * @param texture - Base texture to use.
  44656. * @returns - Boolean specifying if a texture is used in the material.
  44657. */
  44658. hasTexture(texture: BaseTexture): boolean;
  44659. /**
  44660. * Returns an array of the actively used textures.
  44661. * @param activeTextures Array of BaseTextures
  44662. */
  44663. getActiveTextures(activeTextures: BaseTexture[]): void;
  44664. /**
  44665. * Returns the animatable textures.
  44666. * @param animatables Array of animatable textures.
  44667. */
  44668. getAnimatables(animatables: IAnimatable[]): void;
  44669. /**
  44670. * Disposes the resources of the material.
  44671. * @param forceDisposeTextures - Forces the disposal of all textures.
  44672. */
  44673. dispose(forceDisposeTextures?: boolean): void;
  44674. /**
  44675. * Get the current class name of the texture useful for serialization or dynamic coding.
  44676. * @returns "PBRAnisotropicConfiguration"
  44677. */
  44678. getClassName(): string;
  44679. /**
  44680. * Add fallbacks to the effect fallbacks list.
  44681. * @param defines defines the Base texture to use.
  44682. * @param fallbacks defines the current fallback list.
  44683. * @param currentRank defines the current fallback rank.
  44684. * @returns the new fallback rank.
  44685. */
  44686. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44687. /**
  44688. * Add the required uniforms to the current list.
  44689. * @param uniforms defines the current uniform list.
  44690. */
  44691. static AddUniforms(uniforms: string[]): void;
  44692. /**
  44693. * Add the required uniforms to the current buffer.
  44694. * @param uniformBuffer defines the current uniform buffer.
  44695. */
  44696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44697. /**
  44698. * Add the required samplers to the current list.
  44699. * @param samplers defines the current sampler list.
  44700. */
  44701. static AddSamplers(samplers: string[]): void;
  44702. /**
  44703. * Makes a duplicate of the current configuration into another one.
  44704. * @param anisotropicConfiguration define the config where to copy the info
  44705. */
  44706. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44707. /**
  44708. * Serializes this anisotropy configuration.
  44709. * @returns - An object with the serialized config.
  44710. */
  44711. serialize(): any;
  44712. /**
  44713. * Parses a anisotropy Configuration from a serialized object.
  44714. * @param source - Serialized object.
  44715. */
  44716. parse(source: any): void;
  44717. }
  44718. }
  44719. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44720. /**
  44721. * @hidden
  44722. */
  44723. export interface IMaterialBRDFDefines {
  44724. BRDF_V_HEIGHT_CORRELATED: boolean;
  44725. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44726. /** @hidden */
  44727. _areMiscDirty: boolean;
  44728. }
  44729. /**
  44730. * Define the code related to the BRDF parameters of the pbr material.
  44731. */
  44732. export class PBRBRDFConfiguration {
  44733. private _useEnergyConservation;
  44734. /**
  44735. * Defines if the material uses energy conservation.
  44736. */
  44737. useEnergyConservation: boolean;
  44738. private _useSmithVisibilityHeightCorrelated;
  44739. /**
  44740. * LEGACY Mode set to false
  44741. * Defines if the material uses height smith correlated visibility term.
  44742. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44743. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44744. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44745. * Not relying on height correlated will also disable energy conservation.
  44746. */
  44747. useSmithVisibilityHeightCorrelated: boolean;
  44748. /** @hidden */
  44749. private _internalMarkAllSubMeshesAsMiscDirty;
  44750. /** @hidden */
  44751. _markAllSubMeshesAsMiscDirty(): void;
  44752. /**
  44753. * Instantiate a new istance of clear coat configuration.
  44754. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44755. */
  44756. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44757. /**
  44758. * Checks to see if a texture is used in the material.
  44759. * @param defines the list of "defines" to update.
  44760. */
  44761. prepareDefines(defines: IMaterialBRDFDefines): void;
  44762. /**
  44763. * Get the current class name of the texture useful for serialization or dynamic coding.
  44764. * @returns "PBRClearCoatConfiguration"
  44765. */
  44766. getClassName(): string;
  44767. /**
  44768. * Makes a duplicate of the current configuration into another one.
  44769. * @param brdfConfiguration define the config where to copy the info
  44770. */
  44771. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44772. /**
  44773. * Serializes this BRDF configuration.
  44774. * @returns - An object with the serialized config.
  44775. */
  44776. serialize(): any;
  44777. /**
  44778. * Parses a BRDF Configuration from a serialized object.
  44779. * @param source - Serialized object.
  44780. */
  44781. parse(source: any): void;
  44782. }
  44783. }
  44784. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44785. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44786. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44787. import { Color3 } from "babylonjs/Maths/math";
  44788. import { Scene } from "babylonjs/scene";
  44789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44790. import { IAnimatable } from "babylonjs/Misc/tools";
  44791. import { Nullable } from "babylonjs/types";
  44792. /**
  44793. * @hidden
  44794. */
  44795. export interface IMaterialSheenDefines {
  44796. SHEEN: boolean;
  44797. SHEEN_TEXTURE: boolean;
  44798. SHEEN_TEXTUREDIRECTUV: number;
  44799. SHEEN_LINKWITHALBEDO: boolean;
  44800. /** @hidden */
  44801. _areTexturesDirty: boolean;
  44802. }
  44803. /**
  44804. * Define the code related to the Sheen parameters of the pbr material.
  44805. */
  44806. export class PBRSheenConfiguration {
  44807. private _isEnabled;
  44808. /**
  44809. * Defines if the material uses sheen.
  44810. */
  44811. isEnabled: boolean;
  44812. private _linkSheenWithAlbedo;
  44813. /**
  44814. * Defines if the sheen is linked to the sheen color.
  44815. */
  44816. linkSheenWithAlbedo: boolean;
  44817. /**
  44818. * Defines the sheen intensity.
  44819. */
  44820. intensity: number;
  44821. /**
  44822. * Defines the sheen color.
  44823. */
  44824. color: Color3;
  44825. private _texture;
  44826. /**
  44827. * Stores the sheen tint values in a texture.
  44828. * rgb is tint
  44829. * a is a intensity
  44830. */
  44831. texture: Nullable<BaseTexture>;
  44832. /** @hidden */
  44833. private _internalMarkAllSubMeshesAsTexturesDirty;
  44834. /** @hidden */
  44835. _markAllSubMeshesAsTexturesDirty(): void;
  44836. /**
  44837. * Instantiate a new istance of clear coat configuration.
  44838. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44839. */
  44840. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44841. /**
  44842. * Specifies that the submesh is ready to be used.
  44843. * @param defines the list of "defines" to update.
  44844. * @param scene defines the scene the material belongs to.
  44845. * @returns - boolean indicating that the submesh is ready or not.
  44846. */
  44847. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44848. /**
  44849. * Checks to see if a texture is used in the material.
  44850. * @param defines the list of "defines" to update.
  44851. * @param scene defines the scene the material belongs to.
  44852. */
  44853. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44854. /**
  44855. * Binds the material data.
  44856. * @param uniformBuffer defines the Uniform buffer to fill in.
  44857. * @param scene defines the scene the material belongs to.
  44858. * @param isFrozen defines wether the material is frozen or not.
  44859. */
  44860. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44861. /**
  44862. * Checks to see if a texture is used in the material.
  44863. * @param texture - Base texture to use.
  44864. * @returns - Boolean specifying if a texture is used in the material.
  44865. */
  44866. hasTexture(texture: BaseTexture): boolean;
  44867. /**
  44868. * Returns an array of the actively used textures.
  44869. * @param activeTextures Array of BaseTextures
  44870. */
  44871. getActiveTextures(activeTextures: BaseTexture[]): void;
  44872. /**
  44873. * Returns the animatable textures.
  44874. * @param animatables Array of animatable textures.
  44875. */
  44876. getAnimatables(animatables: IAnimatable[]): void;
  44877. /**
  44878. * Disposes the resources of the material.
  44879. * @param forceDisposeTextures - Forces the disposal of all textures.
  44880. */
  44881. dispose(forceDisposeTextures?: boolean): void;
  44882. /**
  44883. * Get the current class name of the texture useful for serialization or dynamic coding.
  44884. * @returns "PBRSheenConfiguration"
  44885. */
  44886. getClassName(): string;
  44887. /**
  44888. * Add fallbacks to the effect fallbacks list.
  44889. * @param defines defines the Base texture to use.
  44890. * @param fallbacks defines the current fallback list.
  44891. * @param currentRank defines the current fallback rank.
  44892. * @returns the new fallback rank.
  44893. */
  44894. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44895. /**
  44896. * Add the required uniforms to the current list.
  44897. * @param uniforms defines the current uniform list.
  44898. */
  44899. static AddUniforms(uniforms: string[]): void;
  44900. /**
  44901. * Add the required uniforms to the current buffer.
  44902. * @param uniformBuffer defines the current uniform buffer.
  44903. */
  44904. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44905. /**
  44906. * Add the required samplers to the current list.
  44907. * @param samplers defines the current sampler list.
  44908. */
  44909. static AddSamplers(samplers: string[]): void;
  44910. /**
  44911. * Makes a duplicate of the current configuration into another one.
  44912. * @param sheenConfiguration define the config where to copy the info
  44913. */
  44914. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44915. /**
  44916. * Serializes this BRDF configuration.
  44917. * @returns - An object with the serialized config.
  44918. */
  44919. serialize(): any;
  44920. /**
  44921. * Parses a Sheen Configuration from a serialized object.
  44922. * @param source - Serialized object.
  44923. */
  44924. parse(source: any): void;
  44925. }
  44926. }
  44927. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44928. /** @hidden */
  44929. export var pbrFragmentDeclaration: {
  44930. name: string;
  44931. shader: string;
  44932. };
  44933. }
  44934. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44935. /** @hidden */
  44936. export var pbrUboDeclaration: {
  44937. name: string;
  44938. shader: string;
  44939. };
  44940. }
  44941. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44942. /** @hidden */
  44943. export var pbrFunctions: {
  44944. name: string;
  44945. shader: string;
  44946. };
  44947. }
  44948. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44949. /** @hidden */
  44950. export var harmonicsFunctions: {
  44951. name: string;
  44952. shader: string;
  44953. };
  44954. }
  44955. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44956. /** @hidden */
  44957. export var pbrPreLightingFunctions: {
  44958. name: string;
  44959. shader: string;
  44960. };
  44961. }
  44962. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44963. /** @hidden */
  44964. export var pbrFalloffLightingFunctions: {
  44965. name: string;
  44966. shader: string;
  44967. };
  44968. }
  44969. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44970. /** @hidden */
  44971. export var pbrLightingFunctions: {
  44972. name: string;
  44973. shader: string;
  44974. };
  44975. }
  44976. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44977. /** @hidden */
  44978. export var pbrDebug: {
  44979. name: string;
  44980. shader: string;
  44981. };
  44982. }
  44983. declare module "babylonjs/Shaders/pbr.fragment" {
  44984. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44985. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44986. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44987. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44988. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44989. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44990. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44991. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44992. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44993. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44994. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44995. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44996. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44997. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44998. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45000. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45001. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45002. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45003. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45004. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45005. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45006. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45007. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45008. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45009. /** @hidden */
  45010. export var pbrPixelShader: {
  45011. name: string;
  45012. shader: string;
  45013. };
  45014. }
  45015. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45016. /** @hidden */
  45017. export var pbrVertexDeclaration: {
  45018. name: string;
  45019. shader: string;
  45020. };
  45021. }
  45022. declare module "babylonjs/Shaders/pbr.vertex" {
  45023. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45026. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45029. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45031. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45032. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45033. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45036. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45038. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45039. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45040. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45041. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45042. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45043. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45044. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45045. /** @hidden */
  45046. export var pbrVertexShader: {
  45047. name: string;
  45048. shader: string;
  45049. };
  45050. }
  45051. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45052. import { IAnimatable } from "babylonjs/Misc/tools";
  45053. import { Nullable } from "babylonjs/types";
  45054. import { Scene } from "babylonjs/scene";
  45055. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45056. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45058. import { Mesh } from "babylonjs/Meshes/mesh";
  45059. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45060. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45061. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45062. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45063. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45064. import { Material } from "babylonjs/Materials/material";
  45065. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45067. import "babylonjs/Shaders/pbr.fragment";
  45068. import "babylonjs/Shaders/pbr.vertex";
  45069. /**
  45070. * The Physically based material base class of BJS.
  45071. *
  45072. * This offers the main features of a standard PBR material.
  45073. * For more information, please refer to the documentation :
  45074. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45075. */
  45076. export abstract class PBRBaseMaterial extends PushMaterial {
  45077. /**
  45078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45079. */
  45080. static readonly PBRMATERIAL_OPAQUE: number;
  45081. /**
  45082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45083. */
  45084. static readonly PBRMATERIAL_ALPHATEST: number;
  45085. /**
  45086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45087. */
  45088. static readonly PBRMATERIAL_ALPHABLEND: number;
  45089. /**
  45090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45091. * They are also discarded below the alpha cutoff threshold to improve performances.
  45092. */
  45093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45094. /**
  45095. * Defines the default value of how much AO map is occluding the analytical lights
  45096. * (point spot...).
  45097. */
  45098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45099. /**
  45100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45101. */
  45102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45103. /**
  45104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45105. * to enhance interoperability with other engines.
  45106. */
  45107. static readonly LIGHTFALLOFF_GLTF: number;
  45108. /**
  45109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45110. * to enhance interoperability with other materials.
  45111. */
  45112. static readonly LIGHTFALLOFF_STANDARD: number;
  45113. /**
  45114. * Intensity of the direct lights e.g. the four lights available in your scene.
  45115. * This impacts both the direct diffuse and specular highlights.
  45116. */
  45117. protected _directIntensity: number;
  45118. /**
  45119. * Intensity of the emissive part of the material.
  45120. * This helps controlling the emissive effect without modifying the emissive color.
  45121. */
  45122. protected _emissiveIntensity: number;
  45123. /**
  45124. * Intensity of the environment e.g. how much the environment will light the object
  45125. * either through harmonics for rough material or through the refelction for shiny ones.
  45126. */
  45127. protected _environmentIntensity: number;
  45128. /**
  45129. * This is a special control allowing the reduction of the specular highlights coming from the
  45130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45131. */
  45132. protected _specularIntensity: number;
  45133. /**
  45134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45135. */
  45136. private _lightingInfos;
  45137. /**
  45138. * Debug Control allowing disabling the bump map on this material.
  45139. */
  45140. protected _disableBumpMap: boolean;
  45141. /**
  45142. * AKA Diffuse Texture in standard nomenclature.
  45143. */
  45144. protected _albedoTexture: BaseTexture;
  45145. /**
  45146. * AKA Occlusion Texture in other nomenclature.
  45147. */
  45148. protected _ambientTexture: BaseTexture;
  45149. /**
  45150. * AKA Occlusion Texture Intensity in other nomenclature.
  45151. */
  45152. protected _ambientTextureStrength: number;
  45153. /**
  45154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45155. * 1 means it completely occludes it
  45156. * 0 mean it has no impact
  45157. */
  45158. protected _ambientTextureImpactOnAnalyticalLights: number;
  45159. /**
  45160. * Stores the alpha values in a texture.
  45161. */
  45162. protected _opacityTexture: BaseTexture;
  45163. /**
  45164. * Stores the reflection values in a texture.
  45165. */
  45166. protected _reflectionTexture: BaseTexture;
  45167. /**
  45168. * Stores the refraction values in a texture.
  45169. */
  45170. protected _refractionTexture: BaseTexture;
  45171. /**
  45172. * Stores the emissive values in a texture.
  45173. */
  45174. protected _emissiveTexture: BaseTexture;
  45175. /**
  45176. * AKA Specular texture in other nomenclature.
  45177. */
  45178. protected _reflectivityTexture: BaseTexture;
  45179. /**
  45180. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45181. */
  45182. protected _metallicTexture: BaseTexture;
  45183. /**
  45184. * Specifies the metallic scalar of the metallic/roughness workflow.
  45185. * Can also be used to scale the metalness values of the metallic texture.
  45186. */
  45187. protected _metallic: Nullable<number>;
  45188. /**
  45189. * Specifies the roughness scalar of the metallic/roughness workflow.
  45190. * Can also be used to scale the roughness values of the metallic texture.
  45191. */
  45192. protected _roughness: Nullable<number>;
  45193. /**
  45194. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45195. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45196. */
  45197. protected _microSurfaceTexture: BaseTexture;
  45198. /**
  45199. * Stores surface normal data used to displace a mesh in a texture.
  45200. */
  45201. protected _bumpTexture: BaseTexture;
  45202. /**
  45203. * Stores the pre-calculated light information of a mesh in a texture.
  45204. */
  45205. protected _lightmapTexture: BaseTexture;
  45206. /**
  45207. * The color of a material in ambient lighting.
  45208. */
  45209. protected _ambientColor: Color3;
  45210. /**
  45211. * AKA Diffuse Color in other nomenclature.
  45212. */
  45213. protected _albedoColor: Color3;
  45214. /**
  45215. * AKA Specular Color in other nomenclature.
  45216. */
  45217. protected _reflectivityColor: Color3;
  45218. /**
  45219. * The color applied when light is reflected from a material.
  45220. */
  45221. protected _reflectionColor: Color3;
  45222. /**
  45223. * The color applied when light is emitted from a material.
  45224. */
  45225. protected _emissiveColor: Color3;
  45226. /**
  45227. * AKA Glossiness in other nomenclature.
  45228. */
  45229. protected _microSurface: number;
  45230. /**
  45231. * source material index of refraction (IOR)' / 'destination material IOR.
  45232. */
  45233. protected _indexOfRefraction: number;
  45234. /**
  45235. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45236. */
  45237. protected _invertRefractionY: boolean;
  45238. /**
  45239. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45240. * Materials half opaque for instance using refraction could benefit from this control.
  45241. */
  45242. protected _linkRefractionWithTransparency: boolean;
  45243. /**
  45244. * Specifies that the material will use the light map as a show map.
  45245. */
  45246. protected _useLightmapAsShadowmap: boolean;
  45247. /**
  45248. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45249. * makes the reflect vector face the model (under horizon).
  45250. */
  45251. protected _useHorizonOcclusion: boolean;
  45252. /**
  45253. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45254. * too much the area relying on ambient texture to define their ambient occlusion.
  45255. */
  45256. protected _useRadianceOcclusion: boolean;
  45257. /**
  45258. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45259. */
  45260. protected _useAlphaFromAlbedoTexture: boolean;
  45261. /**
  45262. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45263. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45264. */
  45265. protected _useSpecularOverAlpha: boolean;
  45266. /**
  45267. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45268. */
  45269. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45270. /**
  45271. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45272. */
  45273. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45274. /**
  45275. * Specifies if the metallic texture contains the roughness information in its green channel.
  45276. */
  45277. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45278. /**
  45279. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45280. */
  45281. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45282. /**
  45283. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45284. */
  45285. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45286. /**
  45287. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45288. */
  45289. protected _useAmbientInGrayScale: boolean;
  45290. /**
  45291. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45292. * The material will try to infer what glossiness each pixel should be.
  45293. */
  45294. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45295. /**
  45296. * Defines the falloff type used in this material.
  45297. * It by default is Physical.
  45298. */
  45299. protected _lightFalloff: number;
  45300. /**
  45301. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45302. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45303. */
  45304. protected _useRadianceOverAlpha: boolean;
  45305. /**
  45306. * Allows using an object space normal map (instead of tangent space).
  45307. */
  45308. protected _useObjectSpaceNormalMap: boolean;
  45309. /**
  45310. * Allows using the bump map in parallax mode.
  45311. */
  45312. protected _useParallax: boolean;
  45313. /**
  45314. * Allows using the bump map in parallax occlusion mode.
  45315. */
  45316. protected _useParallaxOcclusion: boolean;
  45317. /**
  45318. * Controls the scale bias of the parallax mode.
  45319. */
  45320. protected _parallaxScaleBias: number;
  45321. /**
  45322. * If sets to true, disables all the lights affecting the material.
  45323. */
  45324. protected _disableLighting: boolean;
  45325. /**
  45326. * Number of Simultaneous lights allowed on the material.
  45327. */
  45328. protected _maxSimultaneousLights: number;
  45329. /**
  45330. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45331. */
  45332. protected _invertNormalMapX: boolean;
  45333. /**
  45334. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45335. */
  45336. protected _invertNormalMapY: boolean;
  45337. /**
  45338. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45339. */
  45340. protected _twoSidedLighting: boolean;
  45341. /**
  45342. * Defines the alpha limits in alpha test mode.
  45343. */
  45344. protected _alphaCutOff: number;
  45345. /**
  45346. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45347. */
  45348. protected _forceAlphaTest: boolean;
  45349. /**
  45350. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45351. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45352. */
  45353. protected _useAlphaFresnel: boolean;
  45354. /**
  45355. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45356. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45357. */
  45358. protected _useLinearAlphaFresnel: boolean;
  45359. /**
  45360. * The transparency mode of the material.
  45361. */
  45362. protected _transparencyMode: Nullable<number>;
  45363. /**
  45364. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45365. * from cos thetav and roughness:
  45366. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45367. */
  45368. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45369. /**
  45370. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45371. */
  45372. protected _forceIrradianceInFragment: boolean;
  45373. /**
  45374. * Force normal to face away from face.
  45375. */
  45376. protected _forceNormalForward: boolean;
  45377. /**
  45378. * Enables specular anti aliasing in the PBR shader.
  45379. * It will both interacts on the Geometry for analytical and IBL lighting.
  45380. * It also prefilter the roughness map based on the bump values.
  45381. */
  45382. protected _enableSpecularAntiAliasing: boolean;
  45383. /**
  45384. * Default configuration related to image processing available in the PBR Material.
  45385. */
  45386. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45387. /**
  45388. * Keep track of the image processing observer to allow dispose and replace.
  45389. */
  45390. private _imageProcessingObserver;
  45391. /**
  45392. * Attaches a new image processing configuration to the PBR Material.
  45393. * @param configuration
  45394. */
  45395. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45396. /**
  45397. * Stores the available render targets.
  45398. */
  45399. private _renderTargets;
  45400. /**
  45401. * Sets the global ambient color for the material used in lighting calculations.
  45402. */
  45403. private _globalAmbientColor;
  45404. /**
  45405. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45406. */
  45407. private _useLogarithmicDepth;
  45408. /**
  45409. * If set to true, no lighting calculations will be applied.
  45410. */
  45411. private _unlit;
  45412. private _debugMode;
  45413. /**
  45414. * @hidden
  45415. * This is reserved for the inspector.
  45416. * Defines the material debug mode.
  45417. * It helps seeing only some components of the material while troubleshooting.
  45418. */
  45419. debugMode: number;
  45420. /**
  45421. * @hidden
  45422. * This is reserved for the inspector.
  45423. * Specify from where on screen the debug mode should start.
  45424. * The value goes from -1 (full screen) to 1 (not visible)
  45425. * It helps with side by side comparison against the final render
  45426. * This defaults to -1
  45427. */
  45428. private debugLimit;
  45429. /**
  45430. * @hidden
  45431. * This is reserved for the inspector.
  45432. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45433. * You can use the factor to better multiply the final value.
  45434. */
  45435. private debugFactor;
  45436. /**
  45437. * Defines the clear coat layer parameters for the material.
  45438. */
  45439. readonly clearCoat: PBRClearCoatConfiguration;
  45440. /**
  45441. * Defines the anisotropic parameters for the material.
  45442. */
  45443. readonly anisotropy: PBRAnisotropicConfiguration;
  45444. /**
  45445. * Defines the BRDF parameters for the material.
  45446. */
  45447. readonly brdf: PBRBRDFConfiguration;
  45448. /**
  45449. * Defines the Sheen parameters for the material.
  45450. */
  45451. readonly sheen: PBRSheenConfiguration;
  45452. /**
  45453. * Instantiates a new PBRMaterial instance.
  45454. *
  45455. * @param name The material name
  45456. * @param scene The scene the material will be use in.
  45457. */
  45458. constructor(name: string, scene: Scene);
  45459. /**
  45460. * Gets a boolean indicating that current material needs to register RTT
  45461. */
  45462. readonly hasRenderTargetTextures: boolean;
  45463. /**
  45464. * Gets the name of the material class.
  45465. */
  45466. getClassName(): string;
  45467. /**
  45468. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45469. */
  45470. /**
  45471. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45472. */
  45473. useLogarithmicDepth: boolean;
  45474. /**
  45475. * Gets the current transparency mode.
  45476. */
  45477. /**
  45478. * Sets the transparency mode of the material.
  45479. *
  45480. * | Value | Type | Description |
  45481. * | ----- | ----------------------------------- | ----------- |
  45482. * | 0 | OPAQUE | |
  45483. * | 1 | ALPHATEST | |
  45484. * | 2 | ALPHABLEND | |
  45485. * | 3 | ALPHATESTANDBLEND | |
  45486. *
  45487. */
  45488. transparencyMode: Nullable<number>;
  45489. /**
  45490. * Returns true if alpha blending should be disabled.
  45491. */
  45492. private readonly _disableAlphaBlending;
  45493. /**
  45494. * Specifies whether or not this material should be rendered in alpha blend mode.
  45495. */
  45496. needAlphaBlending(): boolean;
  45497. /**
  45498. * Specifies if the mesh will require alpha blending.
  45499. * @param mesh - BJS mesh.
  45500. */
  45501. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45502. /**
  45503. * Specifies whether or not this material should be rendered in alpha test mode.
  45504. */
  45505. needAlphaTesting(): boolean;
  45506. /**
  45507. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45508. */
  45509. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45510. /**
  45511. * Gets the texture used for the alpha test.
  45512. */
  45513. getAlphaTestTexture(): BaseTexture;
  45514. /**
  45515. * Specifies that the submesh is ready to be used.
  45516. * @param mesh - BJS mesh.
  45517. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45518. * @param useInstances - Specifies that instances should be used.
  45519. * @returns - boolean indicating that the submesh is ready or not.
  45520. */
  45521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45522. /**
  45523. * Specifies if the material uses metallic roughness workflow.
  45524. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45525. */
  45526. isMetallicWorkflow(): boolean;
  45527. private _prepareEffect;
  45528. private _prepareDefines;
  45529. /**
  45530. * Force shader compilation
  45531. */
  45532. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45533. clipPlane: boolean;
  45534. }>): void;
  45535. /**
  45536. * Initializes the uniform buffer layout for the shader.
  45537. */
  45538. buildUniformLayout(): void;
  45539. /**
  45540. * Unbinds the textures.
  45541. */
  45542. unbind(): void;
  45543. /**
  45544. * Binds the submesh data.
  45545. * @param world - The world matrix.
  45546. * @param mesh - The BJS mesh.
  45547. * @param subMesh - A submesh of the BJS mesh.
  45548. */
  45549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45550. /**
  45551. * Returns the animatable textures.
  45552. * @returns - Array of animatable textures.
  45553. */
  45554. getAnimatables(): IAnimatable[];
  45555. /**
  45556. * Returns the texture used for reflections.
  45557. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45558. */
  45559. private _getReflectionTexture;
  45560. /**
  45561. * Returns the texture used for refraction or null if none is used.
  45562. * @returns - Refection texture if present. If no refraction texture and refraction
  45563. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45564. */
  45565. private _getRefractionTexture;
  45566. /**
  45567. * Returns an array of the actively used textures.
  45568. * @returns - Array of BaseTextures
  45569. */
  45570. getActiveTextures(): BaseTexture[];
  45571. /**
  45572. * Checks to see if a texture is used in the material.
  45573. * @param texture - Base texture to use.
  45574. * @returns - Boolean specifying if a texture is used in the material.
  45575. */
  45576. hasTexture(texture: BaseTexture): boolean;
  45577. /**
  45578. * Disposes the resources of the material.
  45579. * @param forceDisposeEffect - Forces the disposal of effects.
  45580. * @param forceDisposeTextures - Forces the disposal of all textures.
  45581. */
  45582. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45583. }
  45584. }
  45585. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45586. import { Nullable } from "babylonjs/types";
  45587. import { Scene } from "babylonjs/scene";
  45588. import { Color3 } from "babylonjs/Maths/math";
  45589. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45590. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45592. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45593. /**
  45594. * The Physically based material of BJS.
  45595. *
  45596. * This offers the main features of a standard PBR material.
  45597. * For more information, please refer to the documentation :
  45598. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45599. */
  45600. export class PBRMaterial extends PBRBaseMaterial {
  45601. /**
  45602. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45603. */
  45604. static readonly PBRMATERIAL_OPAQUE: number;
  45605. /**
  45606. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45607. */
  45608. static readonly PBRMATERIAL_ALPHATEST: number;
  45609. /**
  45610. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45611. */
  45612. static readonly PBRMATERIAL_ALPHABLEND: number;
  45613. /**
  45614. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45615. * They are also discarded below the alpha cutoff threshold to improve performances.
  45616. */
  45617. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45618. /**
  45619. * Defines the default value of how much AO map is occluding the analytical lights
  45620. * (point spot...).
  45621. */
  45622. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45623. /**
  45624. * Intensity of the direct lights e.g. the four lights available in your scene.
  45625. * This impacts both the direct diffuse and specular highlights.
  45626. */
  45627. directIntensity: number;
  45628. /**
  45629. * Intensity of the emissive part of the material.
  45630. * This helps controlling the emissive effect without modifying the emissive color.
  45631. */
  45632. emissiveIntensity: number;
  45633. /**
  45634. * Intensity of the environment e.g. how much the environment will light the object
  45635. * either through harmonics for rough material or through the refelction for shiny ones.
  45636. */
  45637. environmentIntensity: number;
  45638. /**
  45639. * This is a special control allowing the reduction of the specular highlights coming from the
  45640. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45641. */
  45642. specularIntensity: number;
  45643. /**
  45644. * Debug Control allowing disabling the bump map on this material.
  45645. */
  45646. disableBumpMap: boolean;
  45647. /**
  45648. * AKA Diffuse Texture in standard nomenclature.
  45649. */
  45650. albedoTexture: BaseTexture;
  45651. /**
  45652. * AKA Occlusion Texture in other nomenclature.
  45653. */
  45654. ambientTexture: BaseTexture;
  45655. /**
  45656. * AKA Occlusion Texture Intensity in other nomenclature.
  45657. */
  45658. ambientTextureStrength: number;
  45659. /**
  45660. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45661. * 1 means it completely occludes it
  45662. * 0 mean it has no impact
  45663. */
  45664. ambientTextureImpactOnAnalyticalLights: number;
  45665. /**
  45666. * Stores the alpha values in a texture.
  45667. */
  45668. opacityTexture: BaseTexture;
  45669. /**
  45670. * Stores the reflection values in a texture.
  45671. */
  45672. reflectionTexture: Nullable<BaseTexture>;
  45673. /**
  45674. * Stores the emissive values in a texture.
  45675. */
  45676. emissiveTexture: BaseTexture;
  45677. /**
  45678. * AKA Specular texture in other nomenclature.
  45679. */
  45680. reflectivityTexture: BaseTexture;
  45681. /**
  45682. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45683. */
  45684. metallicTexture: BaseTexture;
  45685. /**
  45686. * Specifies the metallic scalar of the metallic/roughness workflow.
  45687. * Can also be used to scale the metalness values of the metallic texture.
  45688. */
  45689. metallic: Nullable<number>;
  45690. /**
  45691. * Specifies the roughness scalar of the metallic/roughness workflow.
  45692. * Can also be used to scale the roughness values of the metallic texture.
  45693. */
  45694. roughness: Nullable<number>;
  45695. /**
  45696. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45697. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45698. */
  45699. microSurfaceTexture: BaseTexture;
  45700. /**
  45701. * Stores surface normal data used to displace a mesh in a texture.
  45702. */
  45703. bumpTexture: BaseTexture;
  45704. /**
  45705. * Stores the pre-calculated light information of a mesh in a texture.
  45706. */
  45707. lightmapTexture: BaseTexture;
  45708. /**
  45709. * Stores the refracted light information in a texture.
  45710. */
  45711. refractionTexture: BaseTexture;
  45712. /**
  45713. * The color of a material in ambient lighting.
  45714. */
  45715. ambientColor: Color3;
  45716. /**
  45717. * AKA Diffuse Color in other nomenclature.
  45718. */
  45719. albedoColor: Color3;
  45720. /**
  45721. * AKA Specular Color in other nomenclature.
  45722. */
  45723. reflectivityColor: Color3;
  45724. /**
  45725. * The color reflected from the material.
  45726. */
  45727. reflectionColor: Color3;
  45728. /**
  45729. * The color emitted from the material.
  45730. */
  45731. emissiveColor: Color3;
  45732. /**
  45733. * AKA Glossiness in other nomenclature.
  45734. */
  45735. microSurface: number;
  45736. /**
  45737. * source material index of refraction (IOR)' / 'destination material IOR.
  45738. */
  45739. indexOfRefraction: number;
  45740. /**
  45741. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45742. */
  45743. invertRefractionY: boolean;
  45744. /**
  45745. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45746. * Materials half opaque for instance using refraction could benefit from this control.
  45747. */
  45748. linkRefractionWithTransparency: boolean;
  45749. /**
  45750. * If true, the light map contains occlusion information instead of lighting info.
  45751. */
  45752. useLightmapAsShadowmap: boolean;
  45753. /**
  45754. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45755. */
  45756. useAlphaFromAlbedoTexture: boolean;
  45757. /**
  45758. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45759. */
  45760. forceAlphaTest: boolean;
  45761. /**
  45762. * Defines the alpha limits in alpha test mode.
  45763. */
  45764. alphaCutOff: number;
  45765. /**
  45766. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45767. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45768. */
  45769. useSpecularOverAlpha: boolean;
  45770. /**
  45771. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45772. */
  45773. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45774. /**
  45775. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45776. */
  45777. useRoughnessFromMetallicTextureAlpha: boolean;
  45778. /**
  45779. * Specifies if the metallic texture contains the roughness information in its green channel.
  45780. */
  45781. useRoughnessFromMetallicTextureGreen: boolean;
  45782. /**
  45783. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45784. */
  45785. useMetallnessFromMetallicTextureBlue: boolean;
  45786. /**
  45787. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45788. */
  45789. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45790. /**
  45791. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45792. */
  45793. useAmbientInGrayScale: boolean;
  45794. /**
  45795. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45796. * The material will try to infer what glossiness each pixel should be.
  45797. */
  45798. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45799. /**
  45800. * BJS is using an harcoded light falloff based on a manually sets up range.
  45801. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45802. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45803. */
  45804. /**
  45805. * BJS is using an harcoded light falloff based on a manually sets up range.
  45806. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45807. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45808. */
  45809. usePhysicalLightFalloff: boolean;
  45810. /**
  45811. * In order to support the falloff compatibility with gltf, a special mode has been added
  45812. * to reproduce the gltf light falloff.
  45813. */
  45814. /**
  45815. * In order to support the falloff compatibility with gltf, a special mode has been added
  45816. * to reproduce the gltf light falloff.
  45817. */
  45818. useGLTFLightFalloff: boolean;
  45819. /**
  45820. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45821. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45822. */
  45823. useRadianceOverAlpha: boolean;
  45824. /**
  45825. * Allows using an object space normal map (instead of tangent space).
  45826. */
  45827. useObjectSpaceNormalMap: boolean;
  45828. /**
  45829. * Allows using the bump map in parallax mode.
  45830. */
  45831. useParallax: boolean;
  45832. /**
  45833. * Allows using the bump map in parallax occlusion mode.
  45834. */
  45835. useParallaxOcclusion: boolean;
  45836. /**
  45837. * Controls the scale bias of the parallax mode.
  45838. */
  45839. parallaxScaleBias: number;
  45840. /**
  45841. * If sets to true, disables all the lights affecting the material.
  45842. */
  45843. disableLighting: boolean;
  45844. /**
  45845. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45846. */
  45847. forceIrradianceInFragment: boolean;
  45848. /**
  45849. * Number of Simultaneous lights allowed on the material.
  45850. */
  45851. maxSimultaneousLights: number;
  45852. /**
  45853. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45854. */
  45855. invertNormalMapX: boolean;
  45856. /**
  45857. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45858. */
  45859. invertNormalMapY: boolean;
  45860. /**
  45861. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45862. */
  45863. twoSidedLighting: boolean;
  45864. /**
  45865. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45866. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45867. */
  45868. useAlphaFresnel: boolean;
  45869. /**
  45870. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45871. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45872. */
  45873. useLinearAlphaFresnel: boolean;
  45874. /**
  45875. * Let user defines the brdf lookup texture used for IBL.
  45876. * A default 8bit version is embedded but you could point at :
  45877. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45878. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45879. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45880. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45881. */
  45882. environmentBRDFTexture: Nullable<BaseTexture>;
  45883. /**
  45884. * Force normal to face away from face.
  45885. */
  45886. forceNormalForward: boolean;
  45887. /**
  45888. * Enables specular anti aliasing in the PBR shader.
  45889. * It will both interacts on the Geometry for analytical and IBL lighting.
  45890. * It also prefilter the roughness map based on the bump values.
  45891. */
  45892. enableSpecularAntiAliasing: boolean;
  45893. /**
  45894. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45895. * makes the reflect vector face the model (under horizon).
  45896. */
  45897. useHorizonOcclusion: boolean;
  45898. /**
  45899. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45900. * too much the area relying on ambient texture to define their ambient occlusion.
  45901. */
  45902. useRadianceOcclusion: boolean;
  45903. /**
  45904. * If set to true, no lighting calculations will be applied.
  45905. */
  45906. unlit: boolean;
  45907. /**
  45908. * Gets the image processing configuration used either in this material.
  45909. */
  45910. /**
  45911. * Sets the Default image processing configuration used either in the this material.
  45912. *
  45913. * If sets to null, the scene one is in use.
  45914. */
  45915. imageProcessingConfiguration: ImageProcessingConfiguration;
  45916. /**
  45917. * Gets wether the color curves effect is enabled.
  45918. */
  45919. /**
  45920. * Sets wether the color curves effect is enabled.
  45921. */
  45922. cameraColorCurvesEnabled: boolean;
  45923. /**
  45924. * Gets wether the color grading effect is enabled.
  45925. */
  45926. /**
  45927. * Gets wether the color grading effect is enabled.
  45928. */
  45929. cameraColorGradingEnabled: boolean;
  45930. /**
  45931. * Gets wether tonemapping is enabled or not.
  45932. */
  45933. /**
  45934. * Sets wether tonemapping is enabled or not
  45935. */
  45936. cameraToneMappingEnabled: boolean;
  45937. /**
  45938. * The camera exposure used on this material.
  45939. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45940. * This corresponds to a photographic exposure.
  45941. */
  45942. /**
  45943. * The camera exposure used on this material.
  45944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45945. * This corresponds to a photographic exposure.
  45946. */
  45947. cameraExposure: number;
  45948. /**
  45949. * Gets The camera contrast used on this material.
  45950. */
  45951. /**
  45952. * Sets The camera contrast used on this material.
  45953. */
  45954. cameraContrast: number;
  45955. /**
  45956. * Gets the Color Grading 2D Lookup Texture.
  45957. */
  45958. /**
  45959. * Sets the Color Grading 2D Lookup Texture.
  45960. */
  45961. cameraColorGradingTexture: Nullable<BaseTexture>;
  45962. /**
  45963. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45964. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45965. * 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;
  45966. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45967. */
  45968. /**
  45969. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45970. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45971. * 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;
  45972. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45973. */
  45974. cameraColorCurves: Nullable<ColorCurves>;
  45975. /**
  45976. * Instantiates a new PBRMaterial instance.
  45977. *
  45978. * @param name The material name
  45979. * @param scene The scene the material will be use in.
  45980. */
  45981. constructor(name: string, scene: Scene);
  45982. /**
  45983. * Returns the name of this material class.
  45984. */
  45985. getClassName(): string;
  45986. /**
  45987. * Makes a duplicate of the current material.
  45988. * @param name - name to use for the new material.
  45989. */
  45990. clone(name: string): PBRMaterial;
  45991. /**
  45992. * Serializes this PBR Material.
  45993. * @returns - An object with the serialized material.
  45994. */
  45995. serialize(): any;
  45996. /**
  45997. * Parses a PBR Material from a serialized object.
  45998. * @param source - Serialized object.
  45999. * @param scene - BJS scene instance.
  46000. * @param rootUrl - url for the scene object
  46001. * @returns - PBRMaterial
  46002. */
  46003. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46004. }
  46005. }
  46006. declare module "babylonjs/Misc/dds" {
  46007. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46008. import { Engine } from "babylonjs/Engines/engine";
  46009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46010. import { Nullable } from "babylonjs/types";
  46011. import { Scene } from "babylonjs/scene";
  46012. /**
  46013. * Direct draw surface info
  46014. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46015. */
  46016. export interface DDSInfo {
  46017. /**
  46018. * Width of the texture
  46019. */
  46020. width: number;
  46021. /**
  46022. * Width of the texture
  46023. */
  46024. height: number;
  46025. /**
  46026. * Number of Mipmaps for the texture
  46027. * @see https://en.wikipedia.org/wiki/Mipmap
  46028. */
  46029. mipmapCount: number;
  46030. /**
  46031. * If the textures format is a known fourCC format
  46032. * @see https://www.fourcc.org/
  46033. */
  46034. isFourCC: boolean;
  46035. /**
  46036. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46037. */
  46038. isRGB: boolean;
  46039. /**
  46040. * If the texture is a lumincance format
  46041. */
  46042. isLuminance: boolean;
  46043. /**
  46044. * If this is a cube texture
  46045. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46046. */
  46047. isCube: boolean;
  46048. /**
  46049. * If the texture is a compressed format eg. FOURCC_DXT1
  46050. */
  46051. isCompressed: boolean;
  46052. /**
  46053. * The dxgiFormat of the texture
  46054. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46055. */
  46056. dxgiFormat: number;
  46057. /**
  46058. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46059. */
  46060. textureType: number;
  46061. /**
  46062. * Sphericle polynomial created for the dds texture
  46063. */
  46064. sphericalPolynomial?: SphericalPolynomial;
  46065. }
  46066. /**
  46067. * Class used to provide DDS decompression tools
  46068. */
  46069. export class DDSTools {
  46070. /**
  46071. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46072. */
  46073. static StoreLODInAlphaChannel: boolean;
  46074. /**
  46075. * Gets DDS information from an array buffer
  46076. * @param arrayBuffer defines the array buffer to read data from
  46077. * @returns the DDS information
  46078. */
  46079. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46080. private static _FloatView;
  46081. private static _Int32View;
  46082. private static _ToHalfFloat;
  46083. private static _FromHalfFloat;
  46084. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46085. private static _GetHalfFloatRGBAArrayBuffer;
  46086. private static _GetFloatRGBAArrayBuffer;
  46087. private static _GetFloatAsUIntRGBAArrayBuffer;
  46088. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46089. private static _GetRGBAArrayBuffer;
  46090. private static _ExtractLongWordOrder;
  46091. private static _GetRGBArrayBuffer;
  46092. private static _GetLuminanceArrayBuffer;
  46093. /**
  46094. * Uploads DDS Levels to a Babylon Texture
  46095. * @hidden
  46096. */
  46097. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46098. }
  46099. module "babylonjs/Engines/engine" {
  46100. interface Engine {
  46101. /**
  46102. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46103. * @param rootUrl defines the url where the file to load is located
  46104. * @param scene defines the current scene
  46105. * @param lodScale defines scale to apply to the mip map selection
  46106. * @param lodOffset defines offset to apply to the mip map selection
  46107. * @param onLoad defines an optional callback raised when the texture is loaded
  46108. * @param onError defines an optional callback raised if there is an issue to load the texture
  46109. * @param format defines the format of the data
  46110. * @param forcedExtension defines the extension to use to pick the right loader
  46111. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46112. * @returns the cube texture as an InternalTexture
  46113. */
  46114. 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;
  46115. }
  46116. }
  46117. }
  46118. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46119. import { Nullable } from "babylonjs/types";
  46120. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46121. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46122. /**
  46123. * Implementation of the DDS Texture Loader.
  46124. * @hidden
  46125. */
  46126. export class _DDSTextureLoader implements IInternalTextureLoader {
  46127. /**
  46128. * Defines wether the loader supports cascade loading the different faces.
  46129. */
  46130. readonly supportCascades: boolean;
  46131. /**
  46132. * This returns if the loader support the current file information.
  46133. * @param extension defines the file extension of the file being loaded
  46134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46135. * @param fallback defines the fallback internal texture if any
  46136. * @param isBase64 defines whether the texture is encoded as a base64
  46137. * @param isBuffer defines whether the texture data are stored as a buffer
  46138. * @returns true if the loader can load the specified file
  46139. */
  46140. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46141. /**
  46142. * Transform the url before loading if required.
  46143. * @param rootUrl the url of the texture
  46144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46145. * @returns the transformed texture
  46146. */
  46147. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46148. /**
  46149. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46150. * @param rootUrl the url of the texture
  46151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46152. * @returns the fallback texture
  46153. */
  46154. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46155. /**
  46156. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46157. * @param data contains the texture data
  46158. * @param texture defines the BabylonJS internal texture
  46159. * @param createPolynomials will be true if polynomials have been requested
  46160. * @param onLoad defines the callback to trigger once the texture is ready
  46161. * @param onError defines the callback to trigger in case of error
  46162. */
  46163. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46164. /**
  46165. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46166. * @param data contains the texture data
  46167. * @param texture defines the BabylonJS internal texture
  46168. * @param callback defines the method to call once ready to upload
  46169. */
  46170. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46171. }
  46172. }
  46173. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46174. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46175. /** @hidden */
  46176. export var rgbdEncodePixelShader: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46182. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46183. /** @hidden */
  46184. export var rgbdDecodePixelShader: {
  46185. name: string;
  46186. shader: string;
  46187. };
  46188. }
  46189. declare module "babylonjs/Misc/environmentTextureTools" {
  46190. import { Nullable } from "babylonjs/types";
  46191. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46193. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46194. import "babylonjs/Shaders/rgbdEncode.fragment";
  46195. import "babylonjs/Shaders/rgbdDecode.fragment";
  46196. /**
  46197. * Raw texture data and descriptor sufficient for WebGL texture upload
  46198. */
  46199. export interface EnvironmentTextureInfo {
  46200. /**
  46201. * Version of the environment map
  46202. */
  46203. version: number;
  46204. /**
  46205. * Width of image
  46206. */
  46207. width: number;
  46208. /**
  46209. * Irradiance information stored in the file.
  46210. */
  46211. irradiance: any;
  46212. /**
  46213. * Specular information stored in the file.
  46214. */
  46215. specular: any;
  46216. }
  46217. /**
  46218. * Sets of helpers addressing the serialization and deserialization of environment texture
  46219. * stored in a BabylonJS env file.
  46220. * Those files are usually stored as .env files.
  46221. */
  46222. export class EnvironmentTextureTools {
  46223. /**
  46224. * Magic number identifying the env file.
  46225. */
  46226. private static _MagicBytes;
  46227. /**
  46228. * Gets the environment info from an env file.
  46229. * @param data The array buffer containing the .env bytes.
  46230. * @returns the environment file info (the json header) if successfully parsed.
  46231. */
  46232. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46233. /**
  46234. * Creates an environment texture from a loaded cube texture.
  46235. * @param texture defines the cube texture to convert in env file
  46236. * @return a promise containing the environment data if succesfull.
  46237. */
  46238. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46239. /**
  46240. * Creates a JSON representation of the spherical data.
  46241. * @param texture defines the texture containing the polynomials
  46242. * @return the JSON representation of the spherical info
  46243. */
  46244. private static _CreateEnvTextureIrradiance;
  46245. /**
  46246. * Uploads the texture info contained in the env file to the GPU.
  46247. * @param texture defines the internal texture to upload to
  46248. * @param arrayBuffer defines the buffer cotaining the data to load
  46249. * @param info defines the texture info retrieved through the GetEnvInfo method
  46250. * @returns a promise
  46251. */
  46252. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46253. /**
  46254. * Uploads the levels of image data to the GPU.
  46255. * @param texture defines the internal texture to upload to
  46256. * @param imageData defines the array buffer views of image data [mipmap][face]
  46257. * @returns a promise
  46258. */
  46259. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46260. /**
  46261. * Uploads spherical polynomials information to the texture.
  46262. * @param texture defines the texture we are trying to upload the information to
  46263. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46264. */
  46265. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46266. /** @hidden */
  46267. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46268. }
  46269. }
  46270. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46271. import { Nullable } from "babylonjs/types";
  46272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46273. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46274. /**
  46275. * Implementation of the ENV Texture Loader.
  46276. * @hidden
  46277. */
  46278. export class _ENVTextureLoader implements IInternalTextureLoader {
  46279. /**
  46280. * Defines wether the loader supports cascade loading the different faces.
  46281. */
  46282. readonly supportCascades: boolean;
  46283. /**
  46284. * This returns if the loader support the current file information.
  46285. * @param extension defines the file extension of the file being loaded
  46286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46287. * @param fallback defines the fallback internal texture if any
  46288. * @param isBase64 defines whether the texture is encoded as a base64
  46289. * @param isBuffer defines whether the texture data are stored as a buffer
  46290. * @returns true if the loader can load the specified file
  46291. */
  46292. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46293. /**
  46294. * Transform the url before loading if required.
  46295. * @param rootUrl the url of the texture
  46296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46297. * @returns the transformed texture
  46298. */
  46299. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46300. /**
  46301. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46302. * @param rootUrl the url of the texture
  46303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46304. * @returns the fallback texture
  46305. */
  46306. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46307. /**
  46308. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46309. * @param data contains the texture data
  46310. * @param texture defines the BabylonJS internal texture
  46311. * @param createPolynomials will be true if polynomials have been requested
  46312. * @param onLoad defines the callback to trigger once the texture is ready
  46313. * @param onError defines the callback to trigger in case of error
  46314. */
  46315. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46316. /**
  46317. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46318. * @param data contains the texture data
  46319. * @param texture defines the BabylonJS internal texture
  46320. * @param callback defines the method to call once ready to upload
  46321. */
  46322. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46323. }
  46324. }
  46325. declare module "babylonjs/Misc/khronosTextureContainer" {
  46326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46327. /**
  46328. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46329. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46330. */
  46331. export class KhronosTextureContainer {
  46332. /** contents of the KTX container file */
  46333. arrayBuffer: any;
  46334. private static HEADER_LEN;
  46335. private static COMPRESSED_2D;
  46336. private static COMPRESSED_3D;
  46337. private static TEX_2D;
  46338. private static TEX_3D;
  46339. /**
  46340. * Gets the openGL type
  46341. */
  46342. glType: number;
  46343. /**
  46344. * Gets the openGL type size
  46345. */
  46346. glTypeSize: number;
  46347. /**
  46348. * Gets the openGL format
  46349. */
  46350. glFormat: number;
  46351. /**
  46352. * Gets the openGL internal format
  46353. */
  46354. glInternalFormat: number;
  46355. /**
  46356. * Gets the base internal format
  46357. */
  46358. glBaseInternalFormat: number;
  46359. /**
  46360. * Gets image width in pixel
  46361. */
  46362. pixelWidth: number;
  46363. /**
  46364. * Gets image height in pixel
  46365. */
  46366. pixelHeight: number;
  46367. /**
  46368. * Gets image depth in pixels
  46369. */
  46370. pixelDepth: number;
  46371. /**
  46372. * Gets the number of array elements
  46373. */
  46374. numberOfArrayElements: number;
  46375. /**
  46376. * Gets the number of faces
  46377. */
  46378. numberOfFaces: number;
  46379. /**
  46380. * Gets the number of mipmap levels
  46381. */
  46382. numberOfMipmapLevels: number;
  46383. /**
  46384. * Gets the bytes of key value data
  46385. */
  46386. bytesOfKeyValueData: number;
  46387. /**
  46388. * Gets the load type
  46389. */
  46390. loadType: number;
  46391. /**
  46392. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46393. */
  46394. isInvalid: boolean;
  46395. /**
  46396. * Creates a new KhronosTextureContainer
  46397. * @param arrayBuffer contents of the KTX container file
  46398. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46399. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46400. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46401. */
  46402. constructor(
  46403. /** contents of the KTX container file */
  46404. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46405. /**
  46406. * Uploads KTX content to a Babylon Texture.
  46407. * It is assumed that the texture has already been created & is currently bound
  46408. * @hidden
  46409. */
  46410. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46411. private _upload2DCompressedLevels;
  46412. }
  46413. }
  46414. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46415. import { Nullable } from "babylonjs/types";
  46416. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46417. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46418. /**
  46419. * Implementation of the KTX Texture Loader.
  46420. * @hidden
  46421. */
  46422. export class _KTXTextureLoader implements IInternalTextureLoader {
  46423. /**
  46424. * Defines wether the loader supports cascade loading the different faces.
  46425. */
  46426. readonly supportCascades: boolean;
  46427. /**
  46428. * This returns if the loader support the current file information.
  46429. * @param extension defines the file extension of the file being loaded
  46430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46431. * @param fallback defines the fallback internal texture if any
  46432. * @param isBase64 defines whether the texture is encoded as a base64
  46433. * @param isBuffer defines whether the texture data are stored as a buffer
  46434. * @returns true if the loader can load the specified file
  46435. */
  46436. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46437. /**
  46438. * Transform the url before loading if required.
  46439. * @param rootUrl the url of the texture
  46440. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46441. * @returns the transformed texture
  46442. */
  46443. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46444. /**
  46445. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46446. * @param rootUrl the url of the texture
  46447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46448. * @returns the fallback texture
  46449. */
  46450. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46451. /**
  46452. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46453. * @param data contains the texture data
  46454. * @param texture defines the BabylonJS internal texture
  46455. * @param createPolynomials will be true if polynomials have been requested
  46456. * @param onLoad defines the callback to trigger once the texture is ready
  46457. * @param onError defines the callback to trigger in case of error
  46458. */
  46459. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46460. /**
  46461. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46462. * @param data contains the texture data
  46463. * @param texture defines the BabylonJS internal texture
  46464. * @param callback defines the method to call once ready to upload
  46465. */
  46466. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46467. }
  46468. }
  46469. declare module "babylonjs/Helpers/sceneHelpers" {
  46470. import { Nullable } from "babylonjs/types";
  46471. import { Mesh } from "babylonjs/Meshes/mesh";
  46472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46473. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46474. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46475. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46476. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46477. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46478. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46479. import "babylonjs/Meshes/Builders/boxBuilder";
  46480. /** @hidden */
  46481. export var _forceSceneHelpersToBundle: boolean;
  46482. module "babylonjs/scene" {
  46483. interface Scene {
  46484. /**
  46485. * Creates a default light for the scene.
  46486. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46487. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46488. */
  46489. createDefaultLight(replace?: boolean): void;
  46490. /**
  46491. * Creates a default camera for the scene.
  46492. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46493. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46494. * @param replace has default false, when true replaces the active camera in the scene
  46495. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46496. */
  46497. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46498. /**
  46499. * Creates a default camera and a default light.
  46500. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46501. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46502. * @param replace has the default false, when true replaces the active camera/light in the scene
  46503. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46504. */
  46505. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46506. /**
  46507. * Creates a new sky box
  46508. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46509. * @param environmentTexture defines the texture to use as environment texture
  46510. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46511. * @param scale defines the overall scale of the skybox
  46512. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46513. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46514. * @returns a new mesh holding the sky box
  46515. */
  46516. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46517. /**
  46518. * Creates a new environment
  46519. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46520. * @param options defines the options you can use to configure the environment
  46521. * @returns the new EnvironmentHelper
  46522. */
  46523. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46524. /**
  46525. * Creates a new VREXperienceHelper
  46526. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46527. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46528. * @returns a new VREXperienceHelper
  46529. */
  46530. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46531. /**
  46532. * Creates a new XREXperienceHelper
  46533. * @see http://doc.babylonjs.com/how_to/webxr
  46534. * @returns a promise for a new XREXperienceHelper
  46535. */
  46536. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46537. }
  46538. }
  46539. }
  46540. declare module "babylonjs/Helpers/videoDome" {
  46541. import { Scene } from "babylonjs/scene";
  46542. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46543. import { Mesh } from "babylonjs/Meshes/mesh";
  46544. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46545. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46546. import "babylonjs/Meshes/Builders/sphereBuilder";
  46547. /**
  46548. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46549. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46550. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46551. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46552. */
  46553. export class VideoDome extends TransformNode {
  46554. /**
  46555. * Define the video source as a Monoscopic panoramic 360 video.
  46556. */
  46557. static readonly MODE_MONOSCOPIC: number;
  46558. /**
  46559. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46560. */
  46561. static readonly MODE_TOPBOTTOM: number;
  46562. /**
  46563. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46564. */
  46565. static readonly MODE_SIDEBYSIDE: number;
  46566. private _useDirectMapping;
  46567. /**
  46568. * The video texture being displayed on the sphere
  46569. */
  46570. protected _videoTexture: VideoTexture;
  46571. /**
  46572. * Gets the video texture being displayed on the sphere
  46573. */
  46574. readonly videoTexture: VideoTexture;
  46575. /**
  46576. * The skybox material
  46577. */
  46578. protected _material: BackgroundMaterial;
  46579. /**
  46580. * The surface used for the skybox
  46581. */
  46582. protected _mesh: Mesh;
  46583. /**
  46584. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46585. * Also see the options.resolution property.
  46586. */
  46587. fovMultiplier: number;
  46588. private _videoMode;
  46589. /**
  46590. * Gets or set the current video mode for the video. It can be:
  46591. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46592. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46593. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46594. */
  46595. videoMode: number;
  46596. /**
  46597. * Oberserver used in Stereoscopic VR Mode.
  46598. */
  46599. private _onBeforeCameraRenderObserver;
  46600. /**
  46601. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46602. * @param name Element's name, child elements will append suffixes for their own names.
  46603. * @param urlsOrVideo defines the url(s) or the video element to use
  46604. * @param options An object containing optional or exposed sub element properties
  46605. */
  46606. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46607. resolution?: number;
  46608. clickToPlay?: boolean;
  46609. autoPlay?: boolean;
  46610. loop?: boolean;
  46611. size?: number;
  46612. poster?: string;
  46613. faceForward?: boolean;
  46614. useDirectMapping?: boolean;
  46615. }, scene: Scene);
  46616. private _changeVideoMode;
  46617. /**
  46618. * Releases resources associated with this node.
  46619. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46620. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46621. */
  46622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46623. }
  46624. }
  46625. declare module "babylonjs/Helpers/index" {
  46626. export * from "babylonjs/Helpers/environmentHelper";
  46627. export * from "babylonjs/Helpers/photoDome";
  46628. export * from "babylonjs/Helpers/sceneHelpers";
  46629. export * from "babylonjs/Helpers/videoDome";
  46630. }
  46631. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46632. import { PerfCounter } from "babylonjs/Misc/tools";
  46633. import { IDisposable } from "babylonjs/scene";
  46634. import { Engine } from "babylonjs/Engines/engine";
  46635. /**
  46636. * This class can be used to get instrumentation data from a Babylon engine
  46637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46638. */
  46639. export class EngineInstrumentation implements IDisposable {
  46640. /**
  46641. * Define the instrumented engine.
  46642. */
  46643. engine: Engine;
  46644. private _captureGPUFrameTime;
  46645. private _gpuFrameTimeToken;
  46646. private _gpuFrameTime;
  46647. private _captureShaderCompilationTime;
  46648. private _shaderCompilationTime;
  46649. private _onBeginFrameObserver;
  46650. private _onEndFrameObserver;
  46651. private _onBeforeShaderCompilationObserver;
  46652. private _onAfterShaderCompilationObserver;
  46653. /**
  46654. * Gets the perf counter used for GPU frame time
  46655. */
  46656. readonly gpuFrameTimeCounter: PerfCounter;
  46657. /**
  46658. * Gets the GPU frame time capture status
  46659. */
  46660. /**
  46661. * Enable or disable the GPU frame time capture
  46662. */
  46663. captureGPUFrameTime: boolean;
  46664. /**
  46665. * Gets the perf counter used for shader compilation time
  46666. */
  46667. readonly shaderCompilationTimeCounter: PerfCounter;
  46668. /**
  46669. * Gets the shader compilation time capture status
  46670. */
  46671. /**
  46672. * Enable or disable the shader compilation time capture
  46673. */
  46674. captureShaderCompilationTime: boolean;
  46675. /**
  46676. * Instantiates a new engine instrumentation.
  46677. * This class can be used to get instrumentation data from a Babylon engine
  46678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46679. * @param engine Defines the engine to instrument
  46680. */
  46681. constructor(
  46682. /**
  46683. * Define the instrumented engine.
  46684. */
  46685. engine: Engine);
  46686. /**
  46687. * Dispose and release associated resources.
  46688. */
  46689. dispose(): void;
  46690. }
  46691. }
  46692. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46693. import { PerfCounter } from "babylonjs/Misc/tools";
  46694. import { Scene, IDisposable } from "babylonjs/scene";
  46695. /**
  46696. * This class can be used to get instrumentation data from a Babylon engine
  46697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46698. */
  46699. export class SceneInstrumentation implements IDisposable {
  46700. /**
  46701. * Defines the scene to instrument
  46702. */
  46703. scene: Scene;
  46704. private _captureActiveMeshesEvaluationTime;
  46705. private _activeMeshesEvaluationTime;
  46706. private _captureRenderTargetsRenderTime;
  46707. private _renderTargetsRenderTime;
  46708. private _captureFrameTime;
  46709. private _frameTime;
  46710. private _captureRenderTime;
  46711. private _renderTime;
  46712. private _captureInterFrameTime;
  46713. private _interFrameTime;
  46714. private _captureParticlesRenderTime;
  46715. private _particlesRenderTime;
  46716. private _captureSpritesRenderTime;
  46717. private _spritesRenderTime;
  46718. private _capturePhysicsTime;
  46719. private _physicsTime;
  46720. private _captureAnimationsTime;
  46721. private _animationsTime;
  46722. private _captureCameraRenderTime;
  46723. private _cameraRenderTime;
  46724. private _onBeforeActiveMeshesEvaluationObserver;
  46725. private _onAfterActiveMeshesEvaluationObserver;
  46726. private _onBeforeRenderTargetsRenderObserver;
  46727. private _onAfterRenderTargetsRenderObserver;
  46728. private _onAfterRenderObserver;
  46729. private _onBeforeDrawPhaseObserver;
  46730. private _onAfterDrawPhaseObserver;
  46731. private _onBeforeAnimationsObserver;
  46732. private _onBeforeParticlesRenderingObserver;
  46733. private _onAfterParticlesRenderingObserver;
  46734. private _onBeforeSpritesRenderingObserver;
  46735. private _onAfterSpritesRenderingObserver;
  46736. private _onBeforePhysicsObserver;
  46737. private _onAfterPhysicsObserver;
  46738. private _onAfterAnimationsObserver;
  46739. private _onBeforeCameraRenderObserver;
  46740. private _onAfterCameraRenderObserver;
  46741. /**
  46742. * Gets the perf counter used for active meshes evaluation time
  46743. */
  46744. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46745. /**
  46746. * Gets the active meshes evaluation time capture status
  46747. */
  46748. /**
  46749. * Enable or disable the active meshes evaluation time capture
  46750. */
  46751. captureActiveMeshesEvaluationTime: boolean;
  46752. /**
  46753. * Gets the perf counter used for render targets render time
  46754. */
  46755. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46756. /**
  46757. * Gets the render targets render time capture status
  46758. */
  46759. /**
  46760. * Enable or disable the render targets render time capture
  46761. */
  46762. captureRenderTargetsRenderTime: boolean;
  46763. /**
  46764. * Gets the perf counter used for particles render time
  46765. */
  46766. readonly particlesRenderTimeCounter: PerfCounter;
  46767. /**
  46768. * Gets the particles render time capture status
  46769. */
  46770. /**
  46771. * Enable or disable the particles render time capture
  46772. */
  46773. captureParticlesRenderTime: boolean;
  46774. /**
  46775. * Gets the perf counter used for sprites render time
  46776. */
  46777. readonly spritesRenderTimeCounter: PerfCounter;
  46778. /**
  46779. * Gets the sprites render time capture status
  46780. */
  46781. /**
  46782. * Enable or disable the sprites render time capture
  46783. */
  46784. captureSpritesRenderTime: boolean;
  46785. /**
  46786. * Gets the perf counter used for physics time
  46787. */
  46788. readonly physicsTimeCounter: PerfCounter;
  46789. /**
  46790. * Gets the physics time capture status
  46791. */
  46792. /**
  46793. * Enable or disable the physics time capture
  46794. */
  46795. capturePhysicsTime: boolean;
  46796. /**
  46797. * Gets the perf counter used for animations time
  46798. */
  46799. readonly animationsTimeCounter: PerfCounter;
  46800. /**
  46801. * Gets the animations time capture status
  46802. */
  46803. /**
  46804. * Enable or disable the animations time capture
  46805. */
  46806. captureAnimationsTime: boolean;
  46807. /**
  46808. * Gets the perf counter used for frame time capture
  46809. */
  46810. readonly frameTimeCounter: PerfCounter;
  46811. /**
  46812. * Gets the frame time capture status
  46813. */
  46814. /**
  46815. * Enable or disable the frame time capture
  46816. */
  46817. captureFrameTime: boolean;
  46818. /**
  46819. * Gets the perf counter used for inter-frames time capture
  46820. */
  46821. readonly interFrameTimeCounter: PerfCounter;
  46822. /**
  46823. * Gets the inter-frames time capture status
  46824. */
  46825. /**
  46826. * Enable or disable the inter-frames time capture
  46827. */
  46828. captureInterFrameTime: boolean;
  46829. /**
  46830. * Gets the perf counter used for render time capture
  46831. */
  46832. readonly renderTimeCounter: PerfCounter;
  46833. /**
  46834. * Gets the render time capture status
  46835. */
  46836. /**
  46837. * Enable or disable the render time capture
  46838. */
  46839. captureRenderTime: boolean;
  46840. /**
  46841. * Gets the perf counter used for camera render time capture
  46842. */
  46843. readonly cameraRenderTimeCounter: PerfCounter;
  46844. /**
  46845. * Gets the camera render time capture status
  46846. */
  46847. /**
  46848. * Enable or disable the camera render time capture
  46849. */
  46850. captureCameraRenderTime: boolean;
  46851. /**
  46852. * Gets the perf counter used for draw calls
  46853. */
  46854. readonly drawCallsCounter: PerfCounter;
  46855. /**
  46856. * Gets the perf counter used for texture collisions
  46857. */
  46858. readonly textureCollisionsCounter: PerfCounter;
  46859. /**
  46860. * Instantiates a new scene instrumentation.
  46861. * This class can be used to get instrumentation data from a Babylon engine
  46862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46863. * @param scene Defines the scene to instrument
  46864. */
  46865. constructor(
  46866. /**
  46867. * Defines the scene to instrument
  46868. */
  46869. scene: Scene);
  46870. /**
  46871. * Dispose and release associated resources.
  46872. */
  46873. dispose(): void;
  46874. }
  46875. }
  46876. declare module "babylonjs/Instrumentation/index" {
  46877. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46878. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46879. export * from "babylonjs/Instrumentation/timeToken";
  46880. }
  46881. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46882. /** @hidden */
  46883. export var glowMapGenerationPixelShader: {
  46884. name: string;
  46885. shader: string;
  46886. };
  46887. }
  46888. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46889. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46894. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46895. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46896. /** @hidden */
  46897. export var glowMapGenerationVertexShader: {
  46898. name: string;
  46899. shader: string;
  46900. };
  46901. }
  46902. declare module "babylonjs/Layers/effectLayer" {
  46903. import { Observable } from "babylonjs/Misc/observable";
  46904. import { Nullable } from "babylonjs/types";
  46905. import { Camera } from "babylonjs/Cameras/camera";
  46906. import { Scene } from "babylonjs/scene";
  46907. import { Color4, ISize } from "babylonjs/Maths/math";
  46908. import { Engine } from "babylonjs/Engines/engine";
  46909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46911. import { Mesh } from "babylonjs/Meshes/mesh";
  46912. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46914. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46915. import { Effect } from "babylonjs/Materials/effect";
  46916. import { Material } from "babylonjs/Materials/material";
  46917. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46918. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46919. /**
  46920. * Effect layer options. This helps customizing the behaviour
  46921. * of the effect layer.
  46922. */
  46923. export interface IEffectLayerOptions {
  46924. /**
  46925. * Multiplication factor apply to the canvas size to compute the render target size
  46926. * used to generated the objects (the smaller the faster).
  46927. */
  46928. mainTextureRatio: number;
  46929. /**
  46930. * Enforces a fixed size texture to ensure effect stability across devices.
  46931. */
  46932. mainTextureFixedSize?: number;
  46933. /**
  46934. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46935. */
  46936. alphaBlendingMode: number;
  46937. /**
  46938. * The camera attached to the layer.
  46939. */
  46940. camera: Nullable<Camera>;
  46941. /**
  46942. * The rendering group to draw the layer in.
  46943. */
  46944. renderingGroupId: number;
  46945. }
  46946. /**
  46947. * The effect layer Helps adding post process effect blended with the main pass.
  46948. *
  46949. * This can be for instance use to generate glow or higlight effects on the scene.
  46950. *
  46951. * The effect layer class can not be used directly and is intented to inherited from to be
  46952. * customized per effects.
  46953. */
  46954. export abstract class EffectLayer {
  46955. private _vertexBuffers;
  46956. private _indexBuffer;
  46957. private _cachedDefines;
  46958. private _effectLayerMapGenerationEffect;
  46959. private _effectLayerOptions;
  46960. private _mergeEffect;
  46961. protected _scene: Scene;
  46962. protected _engine: Engine;
  46963. protected _maxSize: number;
  46964. protected _mainTextureDesiredSize: ISize;
  46965. protected _mainTexture: RenderTargetTexture;
  46966. protected _shouldRender: boolean;
  46967. protected _postProcesses: PostProcess[];
  46968. protected _textures: BaseTexture[];
  46969. protected _emissiveTextureAndColor: {
  46970. texture: Nullable<BaseTexture>;
  46971. color: Color4;
  46972. };
  46973. /**
  46974. * The name of the layer
  46975. */
  46976. name: string;
  46977. /**
  46978. * The clear color of the texture used to generate the glow map.
  46979. */
  46980. neutralColor: Color4;
  46981. /**
  46982. * Specifies wether the highlight layer is enabled or not.
  46983. */
  46984. isEnabled: boolean;
  46985. /**
  46986. * Gets the camera attached to the layer.
  46987. */
  46988. readonly camera: Nullable<Camera>;
  46989. /**
  46990. * Gets the rendering group id the layer should render in.
  46991. */
  46992. readonly renderingGroupId: number;
  46993. /**
  46994. * An event triggered when the effect layer has been disposed.
  46995. */
  46996. onDisposeObservable: Observable<EffectLayer>;
  46997. /**
  46998. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46999. */
  47000. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47001. /**
  47002. * An event triggered when the generated texture is being merged in the scene.
  47003. */
  47004. onBeforeComposeObservable: Observable<EffectLayer>;
  47005. /**
  47006. * An event triggered when the generated texture has been merged in the scene.
  47007. */
  47008. onAfterComposeObservable: Observable<EffectLayer>;
  47009. /**
  47010. * An event triggered when the efffect layer changes its size.
  47011. */
  47012. onSizeChangedObservable: Observable<EffectLayer>;
  47013. /** @hidden */
  47014. static _SceneComponentInitialization: (scene: Scene) => void;
  47015. /**
  47016. * Instantiates a new effect Layer and references it in the scene.
  47017. * @param name The name of the layer
  47018. * @param scene The scene to use the layer in
  47019. */
  47020. constructor(
  47021. /** The Friendly of the effect in the scene */
  47022. name: string, scene: Scene);
  47023. /**
  47024. * Get the effect name of the layer.
  47025. * @return The effect name
  47026. */
  47027. abstract getEffectName(): string;
  47028. /**
  47029. * Checks for the readiness of the element composing the layer.
  47030. * @param subMesh the mesh to check for
  47031. * @param useInstances specify wether or not to use instances to render the mesh
  47032. * @return true if ready otherwise, false
  47033. */
  47034. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47035. /**
  47036. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47037. * @returns true if the effect requires stencil during the main canvas render pass.
  47038. */
  47039. abstract needStencil(): boolean;
  47040. /**
  47041. * Create the merge effect. This is the shader use to blit the information back
  47042. * to the main canvas at the end of the scene rendering.
  47043. * @returns The effect containing the shader used to merge the effect on the main canvas
  47044. */
  47045. protected abstract _createMergeEffect(): Effect;
  47046. /**
  47047. * Creates the render target textures and post processes used in the effect layer.
  47048. */
  47049. protected abstract _createTextureAndPostProcesses(): void;
  47050. /**
  47051. * Implementation specific of rendering the generating effect on the main canvas.
  47052. * @param effect The effect used to render through
  47053. */
  47054. protected abstract _internalRender(effect: Effect): void;
  47055. /**
  47056. * Sets the required values for both the emissive texture and and the main color.
  47057. */
  47058. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47059. /**
  47060. * Free any resources and references associated to a mesh.
  47061. * Internal use
  47062. * @param mesh The mesh to free.
  47063. */
  47064. abstract _disposeMesh(mesh: Mesh): void;
  47065. /**
  47066. * Serializes this layer (Glow or Highlight for example)
  47067. * @returns a serialized layer object
  47068. */
  47069. abstract serialize?(): any;
  47070. /**
  47071. * Initializes the effect layer with the required options.
  47072. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47073. */
  47074. protected _init(options: Partial<IEffectLayerOptions>): void;
  47075. /**
  47076. * Generates the index buffer of the full screen quad blending to the main canvas.
  47077. */
  47078. private _generateIndexBuffer;
  47079. /**
  47080. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47081. */
  47082. private _genrateVertexBuffer;
  47083. /**
  47084. * Sets the main texture desired size which is the closest power of two
  47085. * of the engine canvas size.
  47086. */
  47087. private _setMainTextureSize;
  47088. /**
  47089. * Creates the main texture for the effect layer.
  47090. */
  47091. protected _createMainTexture(): void;
  47092. /**
  47093. * Adds specific effects defines.
  47094. * @param defines The defines to add specifics to.
  47095. */
  47096. protected _addCustomEffectDefines(defines: string[]): void;
  47097. /**
  47098. * Checks for the readiness of the element composing the layer.
  47099. * @param subMesh the mesh to check for
  47100. * @param useInstances specify wether or not to use instances to render the mesh
  47101. * @param emissiveTexture the associated emissive texture used to generate the glow
  47102. * @return true if ready otherwise, false
  47103. */
  47104. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47105. /**
  47106. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47107. */
  47108. render(): void;
  47109. /**
  47110. * Determine if a given mesh will be used in the current effect.
  47111. * @param mesh mesh to test
  47112. * @returns true if the mesh will be used
  47113. */
  47114. hasMesh(mesh: AbstractMesh): boolean;
  47115. /**
  47116. * Returns true if the layer contains information to display, otherwise false.
  47117. * @returns true if the glow layer should be rendered
  47118. */
  47119. shouldRender(): boolean;
  47120. /**
  47121. * Returns true if the mesh should render, otherwise false.
  47122. * @param mesh The mesh to render
  47123. * @returns true if it should render otherwise false
  47124. */
  47125. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47126. /**
  47127. * Returns true if the mesh can be rendered, otherwise false.
  47128. * @param mesh The mesh to render
  47129. * @param material The material used on the mesh
  47130. * @returns true if it can be rendered otherwise false
  47131. */
  47132. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47133. /**
  47134. * Returns true if the mesh should render, otherwise false.
  47135. * @param mesh The mesh to render
  47136. * @returns true if it should render otherwise false
  47137. */
  47138. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47139. /**
  47140. * Renders the submesh passed in parameter to the generation map.
  47141. */
  47142. protected _renderSubMesh(subMesh: SubMesh): void;
  47143. /**
  47144. * Rebuild the required buffers.
  47145. * @hidden Internal use only.
  47146. */
  47147. _rebuild(): void;
  47148. /**
  47149. * Dispose only the render target textures and post process.
  47150. */
  47151. private _disposeTextureAndPostProcesses;
  47152. /**
  47153. * Dispose the highlight layer and free resources.
  47154. */
  47155. dispose(): void;
  47156. /**
  47157. * Gets the class name of the effect layer
  47158. * @returns the string with the class name of the effect layer
  47159. */
  47160. getClassName(): string;
  47161. /**
  47162. * Creates an effect layer from parsed effect layer data
  47163. * @param parsedEffectLayer defines effect layer data
  47164. * @param scene defines the current scene
  47165. * @param rootUrl defines the root URL containing the effect layer information
  47166. * @returns a parsed effect Layer
  47167. */
  47168. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47169. }
  47170. }
  47171. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47172. import { Scene } from "babylonjs/scene";
  47173. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47174. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47175. import { AbstractScene } from "babylonjs/abstractScene";
  47176. module "babylonjs/abstractScene" {
  47177. interface AbstractScene {
  47178. /**
  47179. * The list of effect layers (highlights/glow) added to the scene
  47180. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47181. * @see http://doc.babylonjs.com/how_to/glow_layer
  47182. */
  47183. effectLayers: Array<EffectLayer>;
  47184. /**
  47185. * Removes the given effect layer from this scene.
  47186. * @param toRemove defines the effect layer to remove
  47187. * @returns the index of the removed effect layer
  47188. */
  47189. removeEffectLayer(toRemove: EffectLayer): number;
  47190. /**
  47191. * Adds the given effect layer to this scene
  47192. * @param newEffectLayer defines the effect layer to add
  47193. */
  47194. addEffectLayer(newEffectLayer: EffectLayer): void;
  47195. }
  47196. }
  47197. /**
  47198. * Defines the layer scene component responsible to manage any effect layers
  47199. * in a given scene.
  47200. */
  47201. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47202. /**
  47203. * The component name helpfull to identify the component in the list of scene components.
  47204. */
  47205. readonly name: string;
  47206. /**
  47207. * The scene the component belongs to.
  47208. */
  47209. scene: Scene;
  47210. private _engine;
  47211. private _renderEffects;
  47212. private _needStencil;
  47213. private _previousStencilState;
  47214. /**
  47215. * Creates a new instance of the component for the given scene
  47216. * @param scene Defines the scene to register the component in
  47217. */
  47218. constructor(scene: Scene);
  47219. /**
  47220. * Registers the component in a given scene
  47221. */
  47222. register(): void;
  47223. /**
  47224. * Rebuilds the elements related to this component in case of
  47225. * context lost for instance.
  47226. */
  47227. rebuild(): void;
  47228. /**
  47229. * Serializes the component data to the specified json object
  47230. * @param serializationObject The object to serialize to
  47231. */
  47232. serialize(serializationObject: any): void;
  47233. /**
  47234. * Adds all the element from the container to the scene
  47235. * @param container the container holding the elements
  47236. */
  47237. addFromContainer(container: AbstractScene): void;
  47238. /**
  47239. * Removes all the elements in the container from the scene
  47240. * @param container contains the elements to remove
  47241. */
  47242. removeFromContainer(container: AbstractScene): void;
  47243. /**
  47244. * Disposes the component and the associated ressources.
  47245. */
  47246. dispose(): void;
  47247. private _isReadyForMesh;
  47248. private _renderMainTexture;
  47249. private _setStencil;
  47250. private _setStencilBack;
  47251. private _draw;
  47252. private _drawCamera;
  47253. private _drawRenderingGroup;
  47254. }
  47255. }
  47256. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47257. /** @hidden */
  47258. export var glowMapMergePixelShader: {
  47259. name: string;
  47260. shader: string;
  47261. };
  47262. }
  47263. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47264. /** @hidden */
  47265. export var glowMapMergeVertexShader: {
  47266. name: string;
  47267. shader: string;
  47268. };
  47269. }
  47270. declare module "babylonjs/Layers/glowLayer" {
  47271. import { Nullable } from "babylonjs/types";
  47272. import { Camera } from "babylonjs/Cameras/camera";
  47273. import { Scene } from "babylonjs/scene";
  47274. import { Color4 } from "babylonjs/Maths/math";
  47275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47277. import { Mesh } from "babylonjs/Meshes/mesh";
  47278. import { Texture } from "babylonjs/Materials/Textures/texture";
  47279. import { Effect } from "babylonjs/Materials/effect";
  47280. import { Material } from "babylonjs/Materials/material";
  47281. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47282. import "babylonjs/Shaders/glowMapMerge.fragment";
  47283. import "babylonjs/Shaders/glowMapMerge.vertex";
  47284. import "babylonjs/Layers/effectLayerSceneComponent";
  47285. module "babylonjs/abstractScene" {
  47286. interface AbstractScene {
  47287. /**
  47288. * Return a the first highlight layer of the scene with a given name.
  47289. * @param name The name of the highlight layer to look for.
  47290. * @return The highlight layer if found otherwise null.
  47291. */
  47292. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47293. }
  47294. }
  47295. /**
  47296. * Glow layer options. This helps customizing the behaviour
  47297. * of the glow layer.
  47298. */
  47299. export interface IGlowLayerOptions {
  47300. /**
  47301. * Multiplication factor apply to the canvas size to compute the render target size
  47302. * used to generated the glowing objects (the smaller the faster).
  47303. */
  47304. mainTextureRatio: number;
  47305. /**
  47306. * Enforces a fixed size texture to ensure resize independant blur.
  47307. */
  47308. mainTextureFixedSize?: number;
  47309. /**
  47310. * How big is the kernel of the blur texture.
  47311. */
  47312. blurKernelSize: number;
  47313. /**
  47314. * The camera attached to the layer.
  47315. */
  47316. camera: Nullable<Camera>;
  47317. /**
  47318. * Enable MSAA by chosing the number of samples.
  47319. */
  47320. mainTextureSamples?: number;
  47321. /**
  47322. * The rendering group to draw the layer in.
  47323. */
  47324. renderingGroupId: number;
  47325. }
  47326. /**
  47327. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47328. *
  47329. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47330. * glowy meshes to your scene.
  47331. *
  47332. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47333. */
  47334. export class GlowLayer extends EffectLayer {
  47335. /**
  47336. * Effect Name of the layer.
  47337. */
  47338. static readonly EffectName: string;
  47339. /**
  47340. * The default blur kernel size used for the glow.
  47341. */
  47342. static DefaultBlurKernelSize: number;
  47343. /**
  47344. * The default texture size ratio used for the glow.
  47345. */
  47346. static DefaultTextureRatio: number;
  47347. /**
  47348. * Sets the kernel size of the blur.
  47349. */
  47350. /**
  47351. * Gets the kernel size of the blur.
  47352. */
  47353. blurKernelSize: number;
  47354. /**
  47355. * Sets the glow intensity.
  47356. */
  47357. /**
  47358. * Gets the glow intensity.
  47359. */
  47360. intensity: number;
  47361. private _options;
  47362. private _intensity;
  47363. private _horizontalBlurPostprocess1;
  47364. private _verticalBlurPostprocess1;
  47365. private _horizontalBlurPostprocess2;
  47366. private _verticalBlurPostprocess2;
  47367. private _blurTexture1;
  47368. private _blurTexture2;
  47369. private _postProcesses1;
  47370. private _postProcesses2;
  47371. private _includedOnlyMeshes;
  47372. private _excludedMeshes;
  47373. /**
  47374. * Callback used to let the user override the color selection on a per mesh basis
  47375. */
  47376. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47377. /**
  47378. * Callback used to let the user override the texture selection on a per mesh basis
  47379. */
  47380. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47381. /**
  47382. * Instantiates a new glow Layer and references it to the scene.
  47383. * @param name The name of the layer
  47384. * @param scene The scene to use the layer in
  47385. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47386. */
  47387. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47388. /**
  47389. * Get the effect name of the layer.
  47390. * @return The effect name
  47391. */
  47392. getEffectName(): string;
  47393. /**
  47394. * Create the merge effect. This is the shader use to blit the information back
  47395. * to the main canvas at the end of the scene rendering.
  47396. */
  47397. protected _createMergeEffect(): Effect;
  47398. /**
  47399. * Creates the render target textures and post processes used in the glow layer.
  47400. */
  47401. protected _createTextureAndPostProcesses(): void;
  47402. /**
  47403. * Checks for the readiness of the element composing the layer.
  47404. * @param subMesh the mesh to check for
  47405. * @param useInstances specify wether or not to use instances to render the mesh
  47406. * @param emissiveTexture the associated emissive texture used to generate the glow
  47407. * @return true if ready otherwise, false
  47408. */
  47409. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47410. /**
  47411. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47412. */
  47413. needStencil(): boolean;
  47414. /**
  47415. * Returns true if the mesh can be rendered, otherwise false.
  47416. * @param mesh The mesh to render
  47417. * @param material The material used on the mesh
  47418. * @returns true if it can be rendered otherwise false
  47419. */
  47420. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47421. /**
  47422. * Implementation specific of rendering the generating effect on the main canvas.
  47423. * @param effect The effect used to render through
  47424. */
  47425. protected _internalRender(effect: Effect): void;
  47426. /**
  47427. * Sets the required values for both the emissive texture and and the main color.
  47428. */
  47429. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47430. /**
  47431. * Returns true if the mesh should render, otherwise false.
  47432. * @param mesh The mesh to render
  47433. * @returns true if it should render otherwise false
  47434. */
  47435. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47436. /**
  47437. * Adds specific effects defines.
  47438. * @param defines The defines to add specifics to.
  47439. */
  47440. protected _addCustomEffectDefines(defines: string[]): void;
  47441. /**
  47442. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47443. * @param mesh The mesh to exclude from the glow layer
  47444. */
  47445. addExcludedMesh(mesh: Mesh): void;
  47446. /**
  47447. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47448. * @param mesh The mesh to remove
  47449. */
  47450. removeExcludedMesh(mesh: Mesh): void;
  47451. /**
  47452. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47453. * @param mesh The mesh to include in the glow layer
  47454. */
  47455. addIncludedOnlyMesh(mesh: Mesh): void;
  47456. /**
  47457. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47458. * @param mesh The mesh to remove
  47459. */
  47460. removeIncludedOnlyMesh(mesh: Mesh): void;
  47461. /**
  47462. * Determine if a given mesh will be used in the glow layer
  47463. * @param mesh The mesh to test
  47464. * @returns true if the mesh will be highlighted by the current glow layer
  47465. */
  47466. hasMesh(mesh: AbstractMesh): boolean;
  47467. /**
  47468. * Free any resources and references associated to a mesh.
  47469. * Internal use
  47470. * @param mesh The mesh to free.
  47471. * @hidden
  47472. */
  47473. _disposeMesh(mesh: Mesh): void;
  47474. /**
  47475. * Gets the class name of the effect layer
  47476. * @returns the string with the class name of the effect layer
  47477. */
  47478. getClassName(): string;
  47479. /**
  47480. * Serializes this glow layer
  47481. * @returns a serialized glow layer object
  47482. */
  47483. serialize(): any;
  47484. /**
  47485. * Creates a Glow Layer from parsed glow layer data
  47486. * @param parsedGlowLayer defines glow layer data
  47487. * @param scene defines the current scene
  47488. * @param rootUrl defines the root URL containing the glow layer information
  47489. * @returns a parsed Glow Layer
  47490. */
  47491. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47492. }
  47493. }
  47494. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47495. /** @hidden */
  47496. export var glowBlurPostProcessPixelShader: {
  47497. name: string;
  47498. shader: string;
  47499. };
  47500. }
  47501. declare module "babylonjs/Layers/highlightLayer" {
  47502. import { Observable } from "babylonjs/Misc/observable";
  47503. import { Nullable } from "babylonjs/types";
  47504. import { Camera } from "babylonjs/Cameras/camera";
  47505. import { Scene } from "babylonjs/scene";
  47506. import { Color3, Color4 } from "babylonjs/Maths/math";
  47507. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47509. import { Mesh } from "babylonjs/Meshes/mesh";
  47510. import { Effect } from "babylonjs/Materials/effect";
  47511. import { Material } from "babylonjs/Materials/material";
  47512. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47513. import "babylonjs/Shaders/glowMapMerge.fragment";
  47514. import "babylonjs/Shaders/glowMapMerge.vertex";
  47515. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47516. module "babylonjs/abstractScene" {
  47517. interface AbstractScene {
  47518. /**
  47519. * Return a the first highlight layer of the scene with a given name.
  47520. * @param name The name of the highlight layer to look for.
  47521. * @return The highlight layer if found otherwise null.
  47522. */
  47523. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47524. }
  47525. }
  47526. /**
  47527. * Highlight layer options. This helps customizing the behaviour
  47528. * of the highlight layer.
  47529. */
  47530. export interface IHighlightLayerOptions {
  47531. /**
  47532. * Multiplication factor apply to the canvas size to compute the render target size
  47533. * used to generated the glowing objects (the smaller the faster).
  47534. */
  47535. mainTextureRatio: number;
  47536. /**
  47537. * Enforces a fixed size texture to ensure resize independant blur.
  47538. */
  47539. mainTextureFixedSize?: number;
  47540. /**
  47541. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47542. * of the picture to blur (the smaller the faster).
  47543. */
  47544. blurTextureSizeRatio: number;
  47545. /**
  47546. * How big in texel of the blur texture is the vertical blur.
  47547. */
  47548. blurVerticalSize: number;
  47549. /**
  47550. * How big in texel of the blur texture is the horizontal blur.
  47551. */
  47552. blurHorizontalSize: number;
  47553. /**
  47554. * Alpha blending mode used to apply the blur. Default is combine.
  47555. */
  47556. alphaBlendingMode: number;
  47557. /**
  47558. * The camera attached to the layer.
  47559. */
  47560. camera: Nullable<Camera>;
  47561. /**
  47562. * Should we display highlight as a solid stroke?
  47563. */
  47564. isStroke?: boolean;
  47565. /**
  47566. * The rendering group to draw the layer in.
  47567. */
  47568. renderingGroupId: number;
  47569. }
  47570. /**
  47571. * The highlight layer Helps adding a glow effect around a mesh.
  47572. *
  47573. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47574. * glowy meshes to your scene.
  47575. *
  47576. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47577. */
  47578. export class HighlightLayer extends EffectLayer {
  47579. name: string;
  47580. /**
  47581. * Effect Name of the highlight layer.
  47582. */
  47583. static readonly EffectName: string;
  47584. /**
  47585. * The neutral color used during the preparation of the glow effect.
  47586. * This is black by default as the blend operation is a blend operation.
  47587. */
  47588. static NeutralColor: Color4;
  47589. /**
  47590. * Stencil value used for glowing meshes.
  47591. */
  47592. static GlowingMeshStencilReference: number;
  47593. /**
  47594. * Stencil value used for the other meshes in the scene.
  47595. */
  47596. static NormalMeshStencilReference: number;
  47597. /**
  47598. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47599. */
  47600. innerGlow: boolean;
  47601. /**
  47602. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47603. */
  47604. outerGlow: boolean;
  47605. /**
  47606. * Specifies the horizontal size of the blur.
  47607. */
  47608. /**
  47609. * Gets the horizontal size of the blur.
  47610. */
  47611. blurHorizontalSize: number;
  47612. /**
  47613. * Specifies the vertical size of the blur.
  47614. */
  47615. /**
  47616. * Gets the vertical size of the blur.
  47617. */
  47618. blurVerticalSize: number;
  47619. /**
  47620. * An event triggered when the highlight layer is being blurred.
  47621. */
  47622. onBeforeBlurObservable: Observable<HighlightLayer>;
  47623. /**
  47624. * An event triggered when the highlight layer has been blurred.
  47625. */
  47626. onAfterBlurObservable: Observable<HighlightLayer>;
  47627. private _instanceGlowingMeshStencilReference;
  47628. private _options;
  47629. private _downSamplePostprocess;
  47630. private _horizontalBlurPostprocess;
  47631. private _verticalBlurPostprocess;
  47632. private _blurTexture;
  47633. private _meshes;
  47634. private _excludedMeshes;
  47635. /**
  47636. * Instantiates a new highlight Layer and references it to the scene..
  47637. * @param name The name of the layer
  47638. * @param scene The scene to use the layer in
  47639. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47640. */
  47641. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47642. /**
  47643. * Get the effect name of the layer.
  47644. * @return The effect name
  47645. */
  47646. getEffectName(): string;
  47647. /**
  47648. * Create the merge effect. This is the shader use to blit the information back
  47649. * to the main canvas at the end of the scene rendering.
  47650. */
  47651. protected _createMergeEffect(): Effect;
  47652. /**
  47653. * Creates the render target textures and post processes used in the highlight layer.
  47654. */
  47655. protected _createTextureAndPostProcesses(): void;
  47656. /**
  47657. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47658. */
  47659. needStencil(): boolean;
  47660. /**
  47661. * Checks for the readiness of the element composing the layer.
  47662. * @param subMesh the mesh to check for
  47663. * @param useInstances specify wether or not to use instances to render the mesh
  47664. * @param emissiveTexture the associated emissive texture used to generate the glow
  47665. * @return true if ready otherwise, false
  47666. */
  47667. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47668. /**
  47669. * Implementation specific of rendering the generating effect on the main canvas.
  47670. * @param effect The effect used to render through
  47671. */
  47672. protected _internalRender(effect: Effect): void;
  47673. /**
  47674. * Returns true if the layer contains information to display, otherwise false.
  47675. */
  47676. shouldRender(): boolean;
  47677. /**
  47678. * Returns true if the mesh should render, otherwise false.
  47679. * @param mesh The mesh to render
  47680. * @returns true if it should render otherwise false
  47681. */
  47682. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47683. /**
  47684. * Sets the required values for both the emissive texture and and the main color.
  47685. */
  47686. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47687. /**
  47688. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47689. * @param mesh The mesh to exclude from the highlight layer
  47690. */
  47691. addExcludedMesh(mesh: Mesh): void;
  47692. /**
  47693. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47694. * @param mesh The mesh to highlight
  47695. */
  47696. removeExcludedMesh(mesh: Mesh): void;
  47697. /**
  47698. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47699. * @param mesh mesh to test
  47700. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47701. */
  47702. hasMesh(mesh: AbstractMesh): boolean;
  47703. /**
  47704. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47705. * @param mesh The mesh to highlight
  47706. * @param color The color of the highlight
  47707. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47708. */
  47709. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47710. /**
  47711. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47712. * @param mesh The mesh to highlight
  47713. */
  47714. removeMesh(mesh: Mesh): void;
  47715. /**
  47716. * Force the stencil to the normal expected value for none glowing parts
  47717. */
  47718. private _defaultStencilReference;
  47719. /**
  47720. * Free any resources and references associated to a mesh.
  47721. * Internal use
  47722. * @param mesh The mesh to free.
  47723. * @hidden
  47724. */
  47725. _disposeMesh(mesh: Mesh): void;
  47726. /**
  47727. * Dispose the highlight layer and free resources.
  47728. */
  47729. dispose(): void;
  47730. /**
  47731. * Gets the class name of the effect layer
  47732. * @returns the string with the class name of the effect layer
  47733. */
  47734. getClassName(): string;
  47735. /**
  47736. * Serializes this Highlight layer
  47737. * @returns a serialized Highlight layer object
  47738. */
  47739. serialize(): any;
  47740. /**
  47741. * Creates a Highlight layer from parsed Highlight layer data
  47742. * @param parsedHightlightLayer defines the Highlight layer data
  47743. * @param scene defines the current scene
  47744. * @param rootUrl defines the root URL containing the Highlight layer information
  47745. * @returns a parsed Highlight layer
  47746. */
  47747. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47748. }
  47749. }
  47750. declare module "babylonjs/Layers/index" {
  47751. export * from "babylonjs/Layers/effectLayer";
  47752. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47753. export * from "babylonjs/Layers/glowLayer";
  47754. export * from "babylonjs/Layers/highlightLayer";
  47755. export * from "babylonjs/Layers/layer";
  47756. export * from "babylonjs/Layers/layerSceneComponent";
  47757. }
  47758. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47759. /** @hidden */
  47760. export var lensFlarePixelShader: {
  47761. name: string;
  47762. shader: string;
  47763. };
  47764. }
  47765. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47766. /** @hidden */
  47767. export var lensFlareVertexShader: {
  47768. name: string;
  47769. shader: string;
  47770. };
  47771. }
  47772. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47773. import { Scene } from "babylonjs/scene";
  47774. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47776. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47777. import "babylonjs/Shaders/lensFlare.fragment";
  47778. import "babylonjs/Shaders/lensFlare.vertex";
  47779. /**
  47780. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47781. * It is usually composed of several `lensFlare`.
  47782. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47783. */
  47784. export class LensFlareSystem {
  47785. /**
  47786. * Define the name of the lens flare system
  47787. */
  47788. name: string;
  47789. /**
  47790. * List of lens flares used in this system.
  47791. */
  47792. lensFlares: LensFlare[];
  47793. /**
  47794. * Define a limit from the border the lens flare can be visible.
  47795. */
  47796. borderLimit: number;
  47797. /**
  47798. * Define a viewport border we do not want to see the lens flare in.
  47799. */
  47800. viewportBorder: number;
  47801. /**
  47802. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47803. */
  47804. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47805. /**
  47806. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47807. */
  47808. layerMask: number;
  47809. /**
  47810. * Define the id of the lens flare system in the scene.
  47811. * (equal to name by default)
  47812. */
  47813. id: string;
  47814. private _scene;
  47815. private _emitter;
  47816. private _vertexBuffers;
  47817. private _indexBuffer;
  47818. private _effect;
  47819. private _positionX;
  47820. private _positionY;
  47821. private _isEnabled;
  47822. /** @hidden */
  47823. static _SceneComponentInitialization: (scene: Scene) => void;
  47824. /**
  47825. * Instantiates a lens flare system.
  47826. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47827. * It is usually composed of several `lensFlare`.
  47828. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47829. * @param name Define the name of the lens flare system in the scene
  47830. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47831. * @param scene Define the scene the lens flare system belongs to
  47832. */
  47833. constructor(
  47834. /**
  47835. * Define the name of the lens flare system
  47836. */
  47837. name: string, emitter: any, scene: Scene);
  47838. /**
  47839. * Define if the lens flare system is enabled.
  47840. */
  47841. isEnabled: boolean;
  47842. /**
  47843. * Get the scene the effects belongs to.
  47844. * @returns the scene holding the lens flare system
  47845. */
  47846. getScene(): Scene;
  47847. /**
  47848. * Get the emitter of the lens flare system.
  47849. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47850. * @returns the emitter of the lens flare system
  47851. */
  47852. getEmitter(): any;
  47853. /**
  47854. * Set the emitter of the lens flare system.
  47855. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47856. * @param newEmitter Define the new emitter of the system
  47857. */
  47858. setEmitter(newEmitter: any): void;
  47859. /**
  47860. * Get the lens flare system emitter position.
  47861. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47862. * @returns the position
  47863. */
  47864. getEmitterPosition(): Vector3;
  47865. /**
  47866. * @hidden
  47867. */
  47868. computeEffectivePosition(globalViewport: Viewport): boolean;
  47869. /** @hidden */
  47870. _isVisible(): boolean;
  47871. /**
  47872. * @hidden
  47873. */
  47874. render(): boolean;
  47875. /**
  47876. * Dispose and release the lens flare with its associated resources.
  47877. */
  47878. dispose(): void;
  47879. /**
  47880. * Parse a lens flare system from a JSON repressentation
  47881. * @param parsedLensFlareSystem Define the JSON to parse
  47882. * @param scene Define the scene the parsed system should be instantiated in
  47883. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47884. * @returns the parsed system
  47885. */
  47886. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47887. /**
  47888. * Serialize the current Lens Flare System into a JSON representation.
  47889. * @returns the serialized JSON
  47890. */
  47891. serialize(): any;
  47892. }
  47893. }
  47894. declare module "babylonjs/LensFlares/lensFlare" {
  47895. import { Nullable } from "babylonjs/types";
  47896. import { Color3 } from "babylonjs/Maths/math";
  47897. import { Texture } from "babylonjs/Materials/Textures/texture";
  47898. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47899. /**
  47900. * This represents one of the lens effect in a `lensFlareSystem`.
  47901. * It controls one of the indiviual texture used in the effect.
  47902. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47903. */
  47904. export class LensFlare {
  47905. /**
  47906. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47907. */
  47908. size: number;
  47909. /**
  47910. * 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.
  47911. */
  47912. position: number;
  47913. /**
  47914. * Define the lens color.
  47915. */
  47916. color: Color3;
  47917. /**
  47918. * Define the lens texture.
  47919. */
  47920. texture: Nullable<Texture>;
  47921. /**
  47922. * Define the alpha mode to render this particular lens.
  47923. */
  47924. alphaMode: number;
  47925. private _system;
  47926. /**
  47927. * Creates a new Lens Flare.
  47928. * This represents one of the lens effect in a `lensFlareSystem`.
  47929. * It controls one of the indiviual texture used in the effect.
  47930. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47931. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47932. * @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.
  47933. * @param color Define the lens color
  47934. * @param imgUrl Define the lens texture url
  47935. * @param system Define the `lensFlareSystem` this flare is part of
  47936. * @returns The newly created Lens Flare
  47937. */
  47938. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47939. /**
  47940. * Instantiates a new Lens Flare.
  47941. * This represents one of the lens effect in a `lensFlareSystem`.
  47942. * It controls one of the indiviual texture used in the effect.
  47943. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47944. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47945. * @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.
  47946. * @param color Define the lens color
  47947. * @param imgUrl Define the lens texture url
  47948. * @param system Define the `lensFlareSystem` this flare is part of
  47949. */
  47950. constructor(
  47951. /**
  47952. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47953. */
  47954. size: number,
  47955. /**
  47956. * 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.
  47957. */
  47958. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47959. /**
  47960. * Dispose and release the lens flare with its associated resources.
  47961. */
  47962. dispose(): void;
  47963. }
  47964. }
  47965. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47966. import { Nullable } from "babylonjs/types";
  47967. import { Scene } from "babylonjs/scene";
  47968. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47969. import { AbstractScene } from "babylonjs/abstractScene";
  47970. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47971. module "babylonjs/abstractScene" {
  47972. interface AbstractScene {
  47973. /**
  47974. * The list of lens flare system added to the scene
  47975. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47976. */
  47977. lensFlareSystems: Array<LensFlareSystem>;
  47978. /**
  47979. * Removes the given lens flare system from this scene.
  47980. * @param toRemove The lens flare system to remove
  47981. * @returns The index of the removed lens flare system
  47982. */
  47983. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47984. /**
  47985. * Adds the given lens flare system to this scene
  47986. * @param newLensFlareSystem The lens flare system to add
  47987. */
  47988. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47989. /**
  47990. * Gets a lens flare system using its name
  47991. * @param name defines the name to look for
  47992. * @returns the lens flare system or null if not found
  47993. */
  47994. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47995. /**
  47996. * Gets a lens flare system using its id
  47997. * @param id defines the id to look for
  47998. * @returns the lens flare system or null if not found
  47999. */
  48000. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48001. }
  48002. }
  48003. /**
  48004. * Defines the lens flare scene component responsible to manage any lens flares
  48005. * in a given scene.
  48006. */
  48007. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48008. /**
  48009. * The component name helpfull to identify the component in the list of scene components.
  48010. */
  48011. readonly name: string;
  48012. /**
  48013. * The scene the component belongs to.
  48014. */
  48015. scene: Scene;
  48016. /**
  48017. * Creates a new instance of the component for the given scene
  48018. * @param scene Defines the scene to register the component in
  48019. */
  48020. constructor(scene: Scene);
  48021. /**
  48022. * Registers the component in a given scene
  48023. */
  48024. register(): void;
  48025. /**
  48026. * Rebuilds the elements related to this component in case of
  48027. * context lost for instance.
  48028. */
  48029. rebuild(): void;
  48030. /**
  48031. * Adds all the element from the container to the scene
  48032. * @param container the container holding the elements
  48033. */
  48034. addFromContainer(container: AbstractScene): void;
  48035. /**
  48036. * Removes all the elements in the container from the scene
  48037. * @param container contains the elements to remove
  48038. */
  48039. removeFromContainer(container: AbstractScene): void;
  48040. /**
  48041. * Serializes the component data to the specified json object
  48042. * @param serializationObject The object to serialize to
  48043. */
  48044. serialize(serializationObject: any): void;
  48045. /**
  48046. * Disposes the component and the associated ressources.
  48047. */
  48048. dispose(): void;
  48049. private _draw;
  48050. }
  48051. }
  48052. declare module "babylonjs/LensFlares/index" {
  48053. export * from "babylonjs/LensFlares/lensFlare";
  48054. export * from "babylonjs/LensFlares/lensFlareSystem";
  48055. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48056. }
  48057. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48058. import { Scene } from "babylonjs/scene";
  48059. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48060. import { AbstractScene } from "babylonjs/abstractScene";
  48061. /**
  48062. * Defines the shadow generator component responsible to manage any shadow generators
  48063. * in a given scene.
  48064. */
  48065. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48066. /**
  48067. * The component name helpfull to identify the component in the list of scene components.
  48068. */
  48069. readonly name: string;
  48070. /**
  48071. * The scene the component belongs to.
  48072. */
  48073. scene: Scene;
  48074. /**
  48075. * Creates a new instance of the component for the given scene
  48076. * @param scene Defines the scene to register the component in
  48077. */
  48078. constructor(scene: Scene);
  48079. /**
  48080. * Registers the component in a given scene
  48081. */
  48082. register(): void;
  48083. /**
  48084. * Rebuilds the elements related to this component in case of
  48085. * context lost for instance.
  48086. */
  48087. rebuild(): void;
  48088. /**
  48089. * Serializes the component data to the specified json object
  48090. * @param serializationObject The object to serialize to
  48091. */
  48092. serialize(serializationObject: any): void;
  48093. /**
  48094. * Adds all the element from the container to the scene
  48095. * @param container the container holding the elements
  48096. */
  48097. addFromContainer(container: AbstractScene): void;
  48098. /**
  48099. * Removes all the elements in the container from the scene
  48100. * @param container contains the elements to remove
  48101. */
  48102. removeFromContainer(container: AbstractScene): void;
  48103. /**
  48104. * Rebuilds the elements related to this component in case of
  48105. * context lost for instance.
  48106. */
  48107. dispose(): void;
  48108. private _gatherRenderTargets;
  48109. }
  48110. }
  48111. declare module "babylonjs/Lights/Shadows/index" {
  48112. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48113. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48114. }
  48115. declare module "babylonjs/Lights/directionalLight" {
  48116. import { Camera } from "babylonjs/Cameras/camera";
  48117. import { Scene } from "babylonjs/scene";
  48118. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48120. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48121. import { Effect } from "babylonjs/Materials/effect";
  48122. /**
  48123. * A directional light is defined by a direction (what a surprise!).
  48124. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48125. * 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.
  48126. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48127. */
  48128. export class DirectionalLight extends ShadowLight {
  48129. private _shadowFrustumSize;
  48130. /**
  48131. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48132. */
  48133. /**
  48134. * Specifies a fix frustum size for the shadow generation.
  48135. */
  48136. shadowFrustumSize: number;
  48137. private _shadowOrthoScale;
  48138. /**
  48139. * Gets the shadow projection scale against the optimal computed one.
  48140. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48141. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48142. */
  48143. /**
  48144. * Sets the shadow projection scale against the optimal computed one.
  48145. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48146. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48147. */
  48148. shadowOrthoScale: number;
  48149. /**
  48150. * Automatically compute the projection matrix to best fit (including all the casters)
  48151. * on each frame.
  48152. */
  48153. autoUpdateExtends: boolean;
  48154. private _orthoLeft;
  48155. private _orthoRight;
  48156. private _orthoTop;
  48157. private _orthoBottom;
  48158. /**
  48159. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48160. * The directional light is emitted from everywhere in the given direction.
  48161. * It can cast shadows.
  48162. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48163. * @param name The friendly name of the light
  48164. * @param direction The direction of the light
  48165. * @param scene The scene the light belongs to
  48166. */
  48167. constructor(name: string, direction: Vector3, scene: Scene);
  48168. /**
  48169. * Returns the string "DirectionalLight".
  48170. * @return The class name
  48171. */
  48172. getClassName(): string;
  48173. /**
  48174. * Returns the integer 1.
  48175. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48176. */
  48177. getTypeID(): number;
  48178. /**
  48179. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48180. * Returns the DirectionalLight Shadow projection matrix.
  48181. */
  48182. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48183. /**
  48184. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48185. * Returns the DirectionalLight Shadow projection matrix.
  48186. */
  48187. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48188. /**
  48189. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48190. * Returns the DirectionalLight Shadow projection matrix.
  48191. */
  48192. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48193. protected _buildUniformLayout(): void;
  48194. /**
  48195. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48196. * @param effect The effect to update
  48197. * @param lightIndex The index of the light in the effect to update
  48198. * @returns The directional light
  48199. */
  48200. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48201. /**
  48202. * Gets the minZ used for shadow according to both the scene and the light.
  48203. *
  48204. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48205. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48206. * @param activeCamera The camera we are returning the min for
  48207. * @returns the depth min z
  48208. */
  48209. getDepthMinZ(activeCamera: Camera): number;
  48210. /**
  48211. * Gets the maxZ used for shadow according to both the scene and the light.
  48212. *
  48213. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48214. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48215. * @param activeCamera The camera we are returning the max for
  48216. * @returns the depth max z
  48217. */
  48218. getDepthMaxZ(activeCamera: Camera): number;
  48219. /**
  48220. * Prepares the list of defines specific to the light type.
  48221. * @param defines the list of defines
  48222. * @param lightIndex defines the index of the light for the effect
  48223. */
  48224. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48225. }
  48226. }
  48227. declare module "babylonjs/Lights/pointLight" {
  48228. import { Scene } from "babylonjs/scene";
  48229. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48231. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48232. import { Effect } from "babylonjs/Materials/effect";
  48233. /**
  48234. * A point light is a light defined by an unique point in world space.
  48235. * The light is emitted in every direction from this point.
  48236. * A good example of a point light is a standard light bulb.
  48237. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48238. */
  48239. export class PointLight extends ShadowLight {
  48240. private _shadowAngle;
  48241. /**
  48242. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48243. * This specifies what angle the shadow will use to be created.
  48244. *
  48245. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48246. */
  48247. /**
  48248. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48249. * This specifies what angle the shadow will use to be created.
  48250. *
  48251. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48252. */
  48253. shadowAngle: number;
  48254. /**
  48255. * Gets the direction if it has been set.
  48256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48257. */
  48258. /**
  48259. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48260. */
  48261. direction: Vector3;
  48262. /**
  48263. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48264. * A PointLight emits the light in every direction.
  48265. * It can cast shadows.
  48266. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48267. * ```javascript
  48268. * var pointLight = new PointLight("pl", camera.position, scene);
  48269. * ```
  48270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48271. * @param name The light friendly name
  48272. * @param position The position of the point light in the scene
  48273. * @param scene The scene the lights belongs to
  48274. */
  48275. constructor(name: string, position: Vector3, scene: Scene);
  48276. /**
  48277. * Returns the string "PointLight"
  48278. * @returns the class name
  48279. */
  48280. getClassName(): string;
  48281. /**
  48282. * Returns the integer 0.
  48283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48284. */
  48285. getTypeID(): number;
  48286. /**
  48287. * Specifies wether or not the shadowmap should be a cube texture.
  48288. * @returns true if the shadowmap needs to be a cube texture.
  48289. */
  48290. needCube(): boolean;
  48291. /**
  48292. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48293. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48294. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48295. */
  48296. getShadowDirection(faceIndex?: number): Vector3;
  48297. /**
  48298. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48299. * - fov = PI / 2
  48300. * - aspect ratio : 1.0
  48301. * - z-near and far equal to the active camera minZ and maxZ.
  48302. * Returns the PointLight.
  48303. */
  48304. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48305. protected _buildUniformLayout(): void;
  48306. /**
  48307. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48308. * @param effect The effect to update
  48309. * @param lightIndex The index of the light in the effect to update
  48310. * @returns The point light
  48311. */
  48312. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48313. /**
  48314. * Prepares the list of defines specific to the light type.
  48315. * @param defines the list of defines
  48316. * @param lightIndex defines the index of the light for the effect
  48317. */
  48318. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48319. }
  48320. }
  48321. declare module "babylonjs/Lights/spotLight" {
  48322. import { Nullable } from "babylonjs/types";
  48323. import { Scene } from "babylonjs/scene";
  48324. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48326. import { Effect } from "babylonjs/Materials/effect";
  48327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48328. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48329. /**
  48330. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48331. * These values define a cone of light starting from the position, emitting toward the direction.
  48332. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48333. * and the exponent defines the speed of the decay of the light with distance (reach).
  48334. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48335. */
  48336. export class SpotLight extends ShadowLight {
  48337. private _angle;
  48338. private _innerAngle;
  48339. private _cosHalfAngle;
  48340. private _lightAngleScale;
  48341. private _lightAngleOffset;
  48342. /**
  48343. * Gets the cone angle of the spot light in Radians.
  48344. */
  48345. /**
  48346. * Sets the cone angle of the spot light in Radians.
  48347. */
  48348. angle: number;
  48349. /**
  48350. * Only used in gltf falloff mode, this defines the angle where
  48351. * the directional falloff will start before cutting at angle which could be seen
  48352. * as outer angle.
  48353. */
  48354. /**
  48355. * Only used in gltf falloff mode, this defines the angle where
  48356. * the directional falloff will start before cutting at angle which could be seen
  48357. * as outer angle.
  48358. */
  48359. innerAngle: number;
  48360. private _shadowAngleScale;
  48361. /**
  48362. * Allows scaling the angle of the light for shadow generation only.
  48363. */
  48364. /**
  48365. * Allows scaling the angle of the light for shadow generation only.
  48366. */
  48367. shadowAngleScale: number;
  48368. /**
  48369. * The light decay speed with the distance from the emission spot.
  48370. */
  48371. exponent: number;
  48372. private _projectionTextureMatrix;
  48373. /**
  48374. * Allows reading the projecton texture
  48375. */
  48376. readonly projectionTextureMatrix: Matrix;
  48377. protected _projectionTextureLightNear: number;
  48378. /**
  48379. * Gets the near clip of the Spotlight for texture projection.
  48380. */
  48381. /**
  48382. * Sets the near clip of the Spotlight for texture projection.
  48383. */
  48384. projectionTextureLightNear: number;
  48385. protected _projectionTextureLightFar: number;
  48386. /**
  48387. * Gets the far clip of the Spotlight for texture projection.
  48388. */
  48389. /**
  48390. * Sets the far clip of the Spotlight for texture projection.
  48391. */
  48392. projectionTextureLightFar: number;
  48393. protected _projectionTextureUpDirection: Vector3;
  48394. /**
  48395. * Gets the Up vector of the Spotlight for texture projection.
  48396. */
  48397. /**
  48398. * Sets the Up vector of the Spotlight for texture projection.
  48399. */
  48400. projectionTextureUpDirection: Vector3;
  48401. private _projectionTexture;
  48402. /**
  48403. * Gets the projection texture of the light.
  48404. */
  48405. /**
  48406. * Sets the projection texture of the light.
  48407. */
  48408. projectionTexture: Nullable<BaseTexture>;
  48409. private _projectionTextureViewLightDirty;
  48410. private _projectionTextureProjectionLightDirty;
  48411. private _projectionTextureDirty;
  48412. private _projectionTextureViewTargetVector;
  48413. private _projectionTextureViewLightMatrix;
  48414. private _projectionTextureProjectionLightMatrix;
  48415. private _projectionTextureScalingMatrix;
  48416. /**
  48417. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48418. * It can cast shadows.
  48419. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48420. * @param name The light friendly name
  48421. * @param position The position of the spot light in the scene
  48422. * @param direction The direction of the light in the scene
  48423. * @param angle The cone angle of the light in Radians
  48424. * @param exponent The light decay speed with the distance from the emission spot
  48425. * @param scene The scene the lights belongs to
  48426. */
  48427. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48428. /**
  48429. * Returns the string "SpotLight".
  48430. * @returns the class name
  48431. */
  48432. getClassName(): string;
  48433. /**
  48434. * Returns the integer 2.
  48435. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48436. */
  48437. getTypeID(): number;
  48438. /**
  48439. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48440. */
  48441. protected _setDirection(value: Vector3): void;
  48442. /**
  48443. * Overrides the position setter to recompute the projection texture view light Matrix.
  48444. */
  48445. protected _setPosition(value: Vector3): void;
  48446. /**
  48447. * 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.
  48448. * Returns the SpotLight.
  48449. */
  48450. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48451. protected _computeProjectionTextureViewLightMatrix(): void;
  48452. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48453. /**
  48454. * Main function for light texture projection matrix computing.
  48455. */
  48456. protected _computeProjectionTextureMatrix(): void;
  48457. protected _buildUniformLayout(): void;
  48458. private _computeAngleValues;
  48459. /**
  48460. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48461. * @param effect The effect to update
  48462. * @param lightIndex The index of the light in the effect to update
  48463. * @returns The spot light
  48464. */
  48465. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48466. /**
  48467. * Disposes the light and the associated resources.
  48468. */
  48469. dispose(): void;
  48470. /**
  48471. * Prepares the list of defines specific to the light type.
  48472. * @param defines the list of defines
  48473. * @param lightIndex defines the index of the light for the effect
  48474. */
  48475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48476. }
  48477. }
  48478. declare module "babylonjs/Lights/index" {
  48479. export * from "babylonjs/Lights/light";
  48480. export * from "babylonjs/Lights/shadowLight";
  48481. export * from "babylonjs/Lights/Shadows/index";
  48482. export * from "babylonjs/Lights/directionalLight";
  48483. export * from "babylonjs/Lights/hemisphericLight";
  48484. export * from "babylonjs/Lights/pointLight";
  48485. export * from "babylonjs/Lights/spotLight";
  48486. }
  48487. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48488. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48489. /**
  48490. * Header information of HDR texture files.
  48491. */
  48492. export interface HDRInfo {
  48493. /**
  48494. * The height of the texture in pixels.
  48495. */
  48496. height: number;
  48497. /**
  48498. * The width of the texture in pixels.
  48499. */
  48500. width: number;
  48501. /**
  48502. * The index of the beginning of the data in the binary file.
  48503. */
  48504. dataPosition: number;
  48505. }
  48506. /**
  48507. * This groups tools to convert HDR texture to native colors array.
  48508. */
  48509. export class HDRTools {
  48510. private static Ldexp;
  48511. private static Rgbe2float;
  48512. private static readStringLine;
  48513. /**
  48514. * Reads header information from an RGBE texture stored in a native array.
  48515. * More information on this format are available here:
  48516. * https://en.wikipedia.org/wiki/RGBE_image_format
  48517. *
  48518. * @param uint8array The binary file stored in native array.
  48519. * @return The header information.
  48520. */
  48521. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48522. /**
  48523. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48524. * This RGBE texture needs to store the information as a panorama.
  48525. *
  48526. * More information on this format are available here:
  48527. * https://en.wikipedia.org/wiki/RGBE_image_format
  48528. *
  48529. * @param buffer The binary file stored in an array buffer.
  48530. * @param size The expected size of the extracted cubemap.
  48531. * @return The Cube Map information.
  48532. */
  48533. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48534. /**
  48535. * Returns the pixels data extracted from an RGBE texture.
  48536. * This pixels will be stored left to right up to down in the R G B order in one array.
  48537. *
  48538. * More information on this format are available here:
  48539. * https://en.wikipedia.org/wiki/RGBE_image_format
  48540. *
  48541. * @param uint8array The binary file stored in an array buffer.
  48542. * @param hdrInfo The header information of the file.
  48543. * @return The pixels data in RGB right to left up to down order.
  48544. */
  48545. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48546. private static RGBE_ReadPixels_RLE;
  48547. }
  48548. }
  48549. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48550. import { Nullable } from "babylonjs/types";
  48551. import { Scene } from "babylonjs/scene";
  48552. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48554. /**
  48555. * This represents a texture coming from an HDR input.
  48556. *
  48557. * The only supported format is currently panorama picture stored in RGBE format.
  48558. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48559. */
  48560. export class HDRCubeTexture extends BaseTexture {
  48561. private static _facesMapping;
  48562. private _generateHarmonics;
  48563. private _noMipmap;
  48564. private _textureMatrix;
  48565. private _size;
  48566. private _onLoad;
  48567. private _onError;
  48568. /**
  48569. * The texture URL.
  48570. */
  48571. url: string;
  48572. /**
  48573. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48574. */
  48575. coordinatesMode: number;
  48576. protected _isBlocking: boolean;
  48577. /**
  48578. * Sets wether or not the texture is blocking during loading.
  48579. */
  48580. /**
  48581. * Gets wether or not the texture is blocking during loading.
  48582. */
  48583. isBlocking: boolean;
  48584. protected _rotationY: number;
  48585. /**
  48586. * Sets texture matrix rotation angle around Y axis in radians.
  48587. */
  48588. /**
  48589. * Gets texture matrix rotation angle around Y axis radians.
  48590. */
  48591. rotationY: number;
  48592. /**
  48593. * Gets or sets the center of the bounding box associated with the cube texture
  48594. * It must define where the camera used to render the texture was set
  48595. */
  48596. boundingBoxPosition: Vector3;
  48597. private _boundingBoxSize;
  48598. /**
  48599. * Gets or sets the size of the bounding box associated with the cube texture
  48600. * When defined, the cubemap will switch to local mode
  48601. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48602. * @example https://www.babylonjs-playground.com/#RNASML
  48603. */
  48604. boundingBoxSize: Vector3;
  48605. /**
  48606. * Instantiates an HDRTexture from the following parameters.
  48607. *
  48608. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48609. * @param scene The scene the texture will be used in
  48610. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48611. * @param noMipmap Forces to not generate the mipmap if true
  48612. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48613. * @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)
  48614. * @param reserved Reserved flag for internal use.
  48615. */
  48616. 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>);
  48617. /**
  48618. * Get the current class name of the texture useful for serialization or dynamic coding.
  48619. * @returns "HDRCubeTexture"
  48620. */
  48621. getClassName(): string;
  48622. /**
  48623. * Occurs when the file is raw .hdr file.
  48624. */
  48625. private loadTexture;
  48626. clone(): HDRCubeTexture;
  48627. delayLoad(): void;
  48628. /**
  48629. * Get the texture reflection matrix used to rotate/transform the reflection.
  48630. * @returns the reflection matrix
  48631. */
  48632. getReflectionTextureMatrix(): Matrix;
  48633. /**
  48634. * Set the texture reflection matrix used to rotate/transform the reflection.
  48635. * @param value Define the reflection matrix to set
  48636. */
  48637. setReflectionTextureMatrix(value: Matrix): void;
  48638. /**
  48639. * Parses a JSON representation of an HDR Texture in order to create the texture
  48640. * @param parsedTexture Define the JSON representation
  48641. * @param scene Define the scene the texture should be created in
  48642. * @param rootUrl Define the root url in case we need to load relative dependencies
  48643. * @returns the newly created texture after parsing
  48644. */
  48645. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48646. serialize(): any;
  48647. }
  48648. }
  48649. declare module "babylonjs/Physics/physicsEngine" {
  48650. import { Nullable } from "babylonjs/types";
  48651. import { Vector3 } from "babylonjs/Maths/math";
  48652. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48653. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48654. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48655. /**
  48656. * Class used to control physics engine
  48657. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48658. */
  48659. export class PhysicsEngine implements IPhysicsEngine {
  48660. private _physicsPlugin;
  48661. /**
  48662. * Global value used to control the smallest number supported by the simulation
  48663. */
  48664. static Epsilon: number;
  48665. private _impostors;
  48666. private _joints;
  48667. /**
  48668. * Gets the gravity vector used by the simulation
  48669. */
  48670. gravity: Vector3;
  48671. /**
  48672. * Factory used to create the default physics plugin.
  48673. * @returns The default physics plugin
  48674. */
  48675. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48676. /**
  48677. * Creates a new Physics Engine
  48678. * @param gravity defines the gravity vector used by the simulation
  48679. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48680. */
  48681. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48682. /**
  48683. * Sets the gravity vector used by the simulation
  48684. * @param gravity defines the gravity vector to use
  48685. */
  48686. setGravity(gravity: Vector3): void;
  48687. /**
  48688. * Set the time step of the physics engine.
  48689. * Default is 1/60.
  48690. * To slow it down, enter 1/600 for example.
  48691. * To speed it up, 1/30
  48692. * @param newTimeStep defines the new timestep to apply to this world.
  48693. */
  48694. setTimeStep(newTimeStep?: number): void;
  48695. /**
  48696. * Get the time step of the physics engine.
  48697. * @returns the current time step
  48698. */
  48699. getTimeStep(): number;
  48700. /**
  48701. * Release all resources
  48702. */
  48703. dispose(): void;
  48704. /**
  48705. * Gets the name of the current physics plugin
  48706. * @returns the name of the plugin
  48707. */
  48708. getPhysicsPluginName(): string;
  48709. /**
  48710. * Adding a new impostor for the impostor tracking.
  48711. * This will be done by the impostor itself.
  48712. * @param impostor the impostor to add
  48713. */
  48714. addImpostor(impostor: PhysicsImpostor): void;
  48715. /**
  48716. * Remove an impostor from the engine.
  48717. * This impostor and its mesh will not longer be updated by the physics engine.
  48718. * @param impostor the impostor to remove
  48719. */
  48720. removeImpostor(impostor: PhysicsImpostor): void;
  48721. /**
  48722. * Add a joint to the physics engine
  48723. * @param mainImpostor defines the main impostor to which the joint is added.
  48724. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48725. * @param joint defines the joint that will connect both impostors.
  48726. */
  48727. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48728. /**
  48729. * Removes a joint from the simulation
  48730. * @param mainImpostor defines the impostor used with the joint
  48731. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48732. * @param joint defines the joint to remove
  48733. */
  48734. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48735. /**
  48736. * Called by the scene. No need to call it.
  48737. * @param delta defines the timespam between frames
  48738. */
  48739. _step(delta: number): void;
  48740. /**
  48741. * Gets the current plugin used to run the simulation
  48742. * @returns current plugin
  48743. */
  48744. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48745. /**
  48746. * Gets the list of physic impostors
  48747. * @returns an array of PhysicsImpostor
  48748. */
  48749. getImpostors(): Array<PhysicsImpostor>;
  48750. /**
  48751. * Gets the impostor for a physics enabled object
  48752. * @param object defines the object impersonated by the impostor
  48753. * @returns the PhysicsImpostor or null if not found
  48754. */
  48755. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48756. /**
  48757. * Gets the impostor for a physics body object
  48758. * @param body defines physics body used by the impostor
  48759. * @returns the PhysicsImpostor or null if not found
  48760. */
  48761. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48762. }
  48763. }
  48764. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48765. import { Nullable } from "babylonjs/types";
  48766. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48768. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48769. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48770. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48771. /** @hidden */
  48772. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48773. private _useDeltaForWorldStep;
  48774. world: any;
  48775. name: string;
  48776. private _physicsMaterials;
  48777. private _fixedTimeStep;
  48778. BJSCANNON: any;
  48779. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48780. setGravity(gravity: Vector3): void;
  48781. setTimeStep(timeStep: number): void;
  48782. getTimeStep(): number;
  48783. executeStep(delta: number): void;
  48784. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48785. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48786. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48787. private _processChildMeshes;
  48788. removePhysicsBody(impostor: PhysicsImpostor): void;
  48789. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48790. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48791. private _addMaterial;
  48792. private _checkWithEpsilon;
  48793. private _createShape;
  48794. private _createHeightmap;
  48795. private _minus90X;
  48796. private _plus90X;
  48797. private _tmpPosition;
  48798. private _tmpDeltaPosition;
  48799. private _tmpUnityRotation;
  48800. private _updatePhysicsBodyTransformation;
  48801. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48802. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48803. isSupported(): boolean;
  48804. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48805. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48806. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48807. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48808. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48809. getBodyMass(impostor: PhysicsImpostor): number;
  48810. getBodyFriction(impostor: PhysicsImpostor): number;
  48811. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48812. getBodyRestitution(impostor: PhysicsImpostor): number;
  48813. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48814. sleepBody(impostor: PhysicsImpostor): void;
  48815. wakeUpBody(impostor: PhysicsImpostor): void;
  48816. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48817. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48818. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48819. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48820. getRadius(impostor: PhysicsImpostor): number;
  48821. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48822. dispose(): void;
  48823. private _extendNamespace;
  48824. }
  48825. }
  48826. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48827. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48828. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48829. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48831. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48832. import { Nullable } from "babylonjs/types";
  48833. /** @hidden */
  48834. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48835. world: any;
  48836. name: string;
  48837. BJSOIMO: any;
  48838. constructor(iterations?: number, oimoInjection?: any);
  48839. setGravity(gravity: Vector3): void;
  48840. setTimeStep(timeStep: number): void;
  48841. getTimeStep(): number;
  48842. private _tmpImpostorsArray;
  48843. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48844. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48845. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48846. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48847. private _tmpPositionVector;
  48848. removePhysicsBody(impostor: PhysicsImpostor): void;
  48849. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48850. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48851. isSupported(): boolean;
  48852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48854. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48855. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48856. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48857. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48858. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48859. getBodyMass(impostor: PhysicsImpostor): number;
  48860. getBodyFriction(impostor: PhysicsImpostor): number;
  48861. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48862. getBodyRestitution(impostor: PhysicsImpostor): number;
  48863. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48864. sleepBody(impostor: PhysicsImpostor): void;
  48865. wakeUpBody(impostor: PhysicsImpostor): void;
  48866. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48867. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48870. getRadius(impostor: PhysicsImpostor): number;
  48871. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48872. dispose(): void;
  48873. }
  48874. }
  48875. declare module "babylonjs/Probes/reflectionProbe" {
  48876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48877. import { Vector3 } from "babylonjs/Maths/math";
  48878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48879. import { Nullable } from "babylonjs/types";
  48880. import { Scene } from "babylonjs/scene";
  48881. module "babylonjs/abstractScene" {
  48882. interface AbstractScene {
  48883. /**
  48884. * The list of reflection probes added to the scene
  48885. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48886. */
  48887. reflectionProbes: Array<ReflectionProbe>;
  48888. /**
  48889. * Removes the given reflection probe from this scene.
  48890. * @param toRemove The reflection probe to remove
  48891. * @returns The index of the removed reflection probe
  48892. */
  48893. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48894. /**
  48895. * Adds the given reflection probe to this scene.
  48896. * @param newReflectionProbe The reflection probe to add
  48897. */
  48898. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48899. }
  48900. }
  48901. /**
  48902. * Class used to generate realtime reflection / refraction cube textures
  48903. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48904. */
  48905. export class ReflectionProbe {
  48906. /** defines the name of the probe */
  48907. name: string;
  48908. private _scene;
  48909. private _renderTargetTexture;
  48910. private _projectionMatrix;
  48911. private _viewMatrix;
  48912. private _target;
  48913. private _add;
  48914. private _attachedMesh;
  48915. private _invertYAxis;
  48916. /** Gets or sets probe position (center of the cube map) */
  48917. position: Vector3;
  48918. /**
  48919. * Creates a new reflection probe
  48920. * @param name defines the name of the probe
  48921. * @param size defines the texture resolution (for each face)
  48922. * @param scene defines the hosting scene
  48923. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48924. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48925. */
  48926. constructor(
  48927. /** defines the name of the probe */
  48928. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48929. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48930. samples: number;
  48931. /** Gets or sets the refresh rate to use (on every frame by default) */
  48932. refreshRate: number;
  48933. /**
  48934. * Gets the hosting scene
  48935. * @returns a Scene
  48936. */
  48937. getScene(): Scene;
  48938. /** Gets the internal CubeTexture used to render to */
  48939. readonly cubeTexture: RenderTargetTexture;
  48940. /** Gets the list of meshes to render */
  48941. readonly renderList: Nullable<AbstractMesh[]>;
  48942. /**
  48943. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48944. * @param mesh defines the mesh to attach to
  48945. */
  48946. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48947. /**
  48948. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48949. * @param renderingGroupId The rendering group id corresponding to its index
  48950. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48951. */
  48952. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48953. /**
  48954. * Clean all associated resources
  48955. */
  48956. dispose(): void;
  48957. /**
  48958. * Converts the reflection probe information to a readable string for debug purpose.
  48959. * @param fullDetails Supports for multiple levels of logging within scene loading
  48960. * @returns the human readable reflection probe info
  48961. */
  48962. toString(fullDetails?: boolean): string;
  48963. /**
  48964. * Get the class name of the relfection probe.
  48965. * @returns "ReflectionProbe"
  48966. */
  48967. getClassName(): string;
  48968. /**
  48969. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48970. * @returns The JSON representation of the texture
  48971. */
  48972. serialize(): any;
  48973. /**
  48974. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48975. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48976. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48977. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48978. * @returns The parsed reflection probe if successful
  48979. */
  48980. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48981. }
  48982. }
  48983. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48984. /** @hidden */
  48985. export var _BabylonLoaderRegistered: boolean;
  48986. }
  48987. declare module "babylonjs/Loading/Plugins/index" {
  48988. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48989. }
  48990. declare module "babylonjs/Loading/index" {
  48991. export * from "babylonjs/Loading/loadingScreen";
  48992. export * from "babylonjs/Loading/Plugins/index";
  48993. export * from "babylonjs/Loading/sceneLoader";
  48994. export * from "babylonjs/Loading/sceneLoaderFlags";
  48995. }
  48996. declare module "babylonjs/Materials/Background/index" {
  48997. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48998. }
  48999. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49000. import { Scene } from "babylonjs/scene";
  49001. import { Color3 } from "babylonjs/Maths/math";
  49002. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49004. /**
  49005. * The Physically based simple base material of BJS.
  49006. *
  49007. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49008. * It is used as the base class for both the specGloss and metalRough conventions.
  49009. */
  49010. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49011. /**
  49012. * Number of Simultaneous lights allowed on the material.
  49013. */
  49014. maxSimultaneousLights: number;
  49015. /**
  49016. * If sets to true, disables all the lights affecting the material.
  49017. */
  49018. disableLighting: boolean;
  49019. /**
  49020. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49021. */
  49022. environmentTexture: BaseTexture;
  49023. /**
  49024. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49025. */
  49026. invertNormalMapX: boolean;
  49027. /**
  49028. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49029. */
  49030. invertNormalMapY: boolean;
  49031. /**
  49032. * Normal map used in the model.
  49033. */
  49034. normalTexture: BaseTexture;
  49035. /**
  49036. * Emissivie color used to self-illuminate the model.
  49037. */
  49038. emissiveColor: Color3;
  49039. /**
  49040. * Emissivie texture used to self-illuminate the model.
  49041. */
  49042. emissiveTexture: BaseTexture;
  49043. /**
  49044. * Occlusion Channel Strenght.
  49045. */
  49046. occlusionStrength: number;
  49047. /**
  49048. * Occlusion Texture of the material (adding extra occlusion effects).
  49049. */
  49050. occlusionTexture: BaseTexture;
  49051. /**
  49052. * Defines the alpha limits in alpha test mode.
  49053. */
  49054. alphaCutOff: number;
  49055. /**
  49056. * Gets the current double sided mode.
  49057. */
  49058. /**
  49059. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49060. */
  49061. doubleSided: boolean;
  49062. /**
  49063. * Stores the pre-calculated light information of a mesh in a texture.
  49064. */
  49065. lightmapTexture: BaseTexture;
  49066. /**
  49067. * If true, the light map contains occlusion information instead of lighting info.
  49068. */
  49069. useLightmapAsShadowmap: boolean;
  49070. /**
  49071. * Instantiates a new PBRMaterial instance.
  49072. *
  49073. * @param name The material name
  49074. * @param scene The scene the material will be use in.
  49075. */
  49076. constructor(name: string, scene: Scene);
  49077. getClassName(): string;
  49078. }
  49079. }
  49080. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49081. import { Scene } from "babylonjs/scene";
  49082. import { Color3 } from "babylonjs/Maths/math";
  49083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49084. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49085. /**
  49086. * The PBR material of BJS following the metal roughness convention.
  49087. *
  49088. * This fits to the PBR convention in the GLTF definition:
  49089. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49090. */
  49091. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49092. /**
  49093. * The base color has two different interpretations depending on the value of metalness.
  49094. * When the material is a metal, the base color is the specific measured reflectance value
  49095. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49096. * of the material.
  49097. */
  49098. baseColor: Color3;
  49099. /**
  49100. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49101. * well as opacity information in the alpha channel.
  49102. */
  49103. baseTexture: BaseTexture;
  49104. /**
  49105. * Specifies the metallic scalar value of the material.
  49106. * Can also be used to scale the metalness values of the metallic texture.
  49107. */
  49108. metallic: number;
  49109. /**
  49110. * Specifies the roughness scalar value of the material.
  49111. * Can also be used to scale the roughness values of the metallic texture.
  49112. */
  49113. roughness: number;
  49114. /**
  49115. * Texture containing both the metallic value in the B channel and the
  49116. * roughness value in the G channel to keep better precision.
  49117. */
  49118. metallicRoughnessTexture: BaseTexture;
  49119. /**
  49120. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49121. *
  49122. * @param name The material name
  49123. * @param scene The scene the material will be use in.
  49124. */
  49125. constructor(name: string, scene: Scene);
  49126. /**
  49127. * Return the currrent class name of the material.
  49128. */
  49129. getClassName(): string;
  49130. /**
  49131. * Makes a duplicate of the current material.
  49132. * @param name - name to use for the new material.
  49133. */
  49134. clone(name: string): PBRMetallicRoughnessMaterial;
  49135. /**
  49136. * Serialize the material to a parsable JSON object.
  49137. */
  49138. serialize(): any;
  49139. /**
  49140. * Parses a JSON object correponding to the serialize function.
  49141. */
  49142. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49143. }
  49144. }
  49145. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49146. import { Scene } from "babylonjs/scene";
  49147. import { Color3 } from "babylonjs/Maths/math";
  49148. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49149. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49150. /**
  49151. * The PBR material of BJS following the specular glossiness convention.
  49152. *
  49153. * This fits to the PBR convention in the GLTF definition:
  49154. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49155. */
  49156. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49157. /**
  49158. * Specifies the diffuse color of the material.
  49159. */
  49160. diffuseColor: Color3;
  49161. /**
  49162. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49163. * channel.
  49164. */
  49165. diffuseTexture: BaseTexture;
  49166. /**
  49167. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49168. */
  49169. specularColor: Color3;
  49170. /**
  49171. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49172. */
  49173. glossiness: number;
  49174. /**
  49175. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49176. */
  49177. specularGlossinessTexture: BaseTexture;
  49178. /**
  49179. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49180. *
  49181. * @param name The material name
  49182. * @param scene The scene the material will be use in.
  49183. */
  49184. constructor(name: string, scene: Scene);
  49185. /**
  49186. * Return the currrent class name of the material.
  49187. */
  49188. getClassName(): string;
  49189. /**
  49190. * Makes a duplicate of the current material.
  49191. * @param name - name to use for the new material.
  49192. */
  49193. clone(name: string): PBRSpecularGlossinessMaterial;
  49194. /**
  49195. * Serialize the material to a parsable JSON object.
  49196. */
  49197. serialize(): any;
  49198. /**
  49199. * Parses a JSON object correponding to the serialize function.
  49200. */
  49201. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49202. }
  49203. }
  49204. declare module "babylonjs/Materials/PBR/index" {
  49205. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49206. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49207. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49208. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49209. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49210. }
  49211. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49212. import { Nullable } from "babylonjs/types";
  49213. import { Scene } from "babylonjs/scene";
  49214. import { Matrix } from "babylonjs/Maths/math";
  49215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49216. /**
  49217. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49218. * It can help converting any input color in a desired output one. This can then be used to create effects
  49219. * from sepia, black and white to sixties or futuristic rendering...
  49220. *
  49221. * The only supported format is currently 3dl.
  49222. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49223. */
  49224. export class ColorGradingTexture extends BaseTexture {
  49225. /**
  49226. * The current texture matrix. (will always be identity in color grading texture)
  49227. */
  49228. private _textureMatrix;
  49229. /**
  49230. * The texture URL.
  49231. */
  49232. url: string;
  49233. /**
  49234. * Empty line regex stored for GC.
  49235. */
  49236. private static _noneEmptyLineRegex;
  49237. private _engine;
  49238. /**
  49239. * Instantiates a ColorGradingTexture from the following parameters.
  49240. *
  49241. * @param url The location of the color gradind data (currently only supporting 3dl)
  49242. * @param scene The scene the texture will be used in
  49243. */
  49244. constructor(url: string, scene: Scene);
  49245. /**
  49246. * Returns the texture matrix used in most of the material.
  49247. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49248. */
  49249. getTextureMatrix(): Matrix;
  49250. /**
  49251. * Occurs when the file being loaded is a .3dl LUT file.
  49252. */
  49253. private load3dlTexture;
  49254. /**
  49255. * Starts the loading process of the texture.
  49256. */
  49257. private loadTexture;
  49258. /**
  49259. * Clones the color gradind texture.
  49260. */
  49261. clone(): ColorGradingTexture;
  49262. /**
  49263. * Called during delayed load for textures.
  49264. */
  49265. delayLoad(): void;
  49266. /**
  49267. * Parses a color grading texture serialized by Babylon.
  49268. * @param parsedTexture The texture information being parsedTexture
  49269. * @param scene The scene to load the texture in
  49270. * @param rootUrl The root url of the data assets to load
  49271. * @return A color gradind texture
  49272. */
  49273. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49274. /**
  49275. * Serializes the LUT texture to json format.
  49276. */
  49277. serialize(): any;
  49278. }
  49279. }
  49280. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49282. import { Scene } from "babylonjs/scene";
  49283. import { Nullable } from "babylonjs/types";
  49284. /**
  49285. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49286. */
  49287. export class EquiRectangularCubeTexture extends BaseTexture {
  49288. /** The six faces of the cube. */
  49289. private static _FacesMapping;
  49290. private _noMipmap;
  49291. private _onLoad;
  49292. private _onError;
  49293. /** The size of the cubemap. */
  49294. private _size;
  49295. /** The buffer of the image. */
  49296. private _buffer;
  49297. /** The width of the input image. */
  49298. private _width;
  49299. /** The height of the input image. */
  49300. private _height;
  49301. /** The URL to the image. */
  49302. url: string;
  49303. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49304. coordinatesMode: number;
  49305. /**
  49306. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49307. * @param url The location of the image
  49308. * @param scene The scene the texture will be used in
  49309. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49310. * @param noMipmap Forces to not generate the mipmap if true
  49311. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49312. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49313. * @param onLoad — defines a callback called when texture is loaded
  49314. * @param onError — defines a callback called if there is an error
  49315. */
  49316. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49317. /**
  49318. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49319. */
  49320. private loadImage;
  49321. /**
  49322. * Convert the image buffer into a cubemap and create a CubeTexture.
  49323. */
  49324. private loadTexture;
  49325. /**
  49326. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49327. * @param buffer The ArrayBuffer that should be converted.
  49328. * @returns The buffer as Float32Array.
  49329. */
  49330. private getFloat32ArrayFromArrayBuffer;
  49331. /**
  49332. * Get the current class name of the texture useful for serialization or dynamic coding.
  49333. * @returns "EquiRectangularCubeTexture"
  49334. */
  49335. getClassName(): string;
  49336. /**
  49337. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49338. * @returns A clone of the current EquiRectangularCubeTexture.
  49339. */
  49340. clone(): EquiRectangularCubeTexture;
  49341. }
  49342. }
  49343. declare module "babylonjs/Misc/tga" {
  49344. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49345. /**
  49346. * Based on jsTGALoader - Javascript loader for TGA file
  49347. * By Vincent Thibault
  49348. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49349. */
  49350. export class TGATools {
  49351. private static _TYPE_INDEXED;
  49352. private static _TYPE_RGB;
  49353. private static _TYPE_GREY;
  49354. private static _TYPE_RLE_INDEXED;
  49355. private static _TYPE_RLE_RGB;
  49356. private static _TYPE_RLE_GREY;
  49357. private static _ORIGIN_MASK;
  49358. private static _ORIGIN_SHIFT;
  49359. private static _ORIGIN_BL;
  49360. private static _ORIGIN_BR;
  49361. private static _ORIGIN_UL;
  49362. private static _ORIGIN_UR;
  49363. /**
  49364. * Gets the header of a TGA file
  49365. * @param data defines the TGA data
  49366. * @returns the header
  49367. */
  49368. static GetTGAHeader(data: Uint8Array): any;
  49369. /**
  49370. * Uploads TGA content to a Babylon Texture
  49371. * @hidden
  49372. */
  49373. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49374. /** @hidden */
  49375. 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;
  49376. /** @hidden */
  49377. 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;
  49378. /** @hidden */
  49379. 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;
  49380. /** @hidden */
  49381. 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;
  49382. /** @hidden */
  49383. 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;
  49384. /** @hidden */
  49385. 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;
  49386. }
  49387. }
  49388. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49389. import { Nullable } from "babylonjs/types";
  49390. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49391. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49392. /**
  49393. * Implementation of the TGA Texture Loader.
  49394. * @hidden
  49395. */
  49396. export class _TGATextureLoader implements IInternalTextureLoader {
  49397. /**
  49398. * Defines wether the loader supports cascade loading the different faces.
  49399. */
  49400. readonly supportCascades: boolean;
  49401. /**
  49402. * This returns if the loader support the current file information.
  49403. * @param extension defines the file extension of the file being loaded
  49404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49405. * @param fallback defines the fallback internal texture if any
  49406. * @param isBase64 defines whether the texture is encoded as a base64
  49407. * @param isBuffer defines whether the texture data are stored as a buffer
  49408. * @returns true if the loader can load the specified file
  49409. */
  49410. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49411. /**
  49412. * Transform the url before loading if required.
  49413. * @param rootUrl the url of the texture
  49414. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49415. * @returns the transformed texture
  49416. */
  49417. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49418. /**
  49419. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49420. * @param rootUrl the url of the texture
  49421. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49422. * @returns the fallback texture
  49423. */
  49424. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49425. /**
  49426. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49427. * @param data contains the texture data
  49428. * @param texture defines the BabylonJS internal texture
  49429. * @param createPolynomials will be true if polynomials have been requested
  49430. * @param onLoad defines the callback to trigger once the texture is ready
  49431. * @param onError defines the callback to trigger in case of error
  49432. */
  49433. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49434. /**
  49435. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49436. * @param data contains the texture data
  49437. * @param texture defines the BabylonJS internal texture
  49438. * @param callback defines the method to call once ready to upload
  49439. */
  49440. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49441. }
  49442. }
  49443. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49444. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49445. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49446. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49447. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49448. }
  49449. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49450. import { Scene } from "babylonjs/scene";
  49451. import { Texture } from "babylonjs/Materials/Textures/texture";
  49452. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49453. /**
  49454. * 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.
  49455. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49456. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49457. */
  49458. export class CustomProceduralTexture extends ProceduralTexture {
  49459. private _animate;
  49460. private _time;
  49461. private _config;
  49462. private _texturePath;
  49463. /**
  49464. * Instantiates a new Custom Procedural Texture.
  49465. * 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.
  49466. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49467. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49468. * @param name Define the name of the texture
  49469. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49470. * @param size Define the size of the texture to create
  49471. * @param scene Define the scene the texture belongs to
  49472. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49473. * @param generateMipMaps Define if the texture should creates mip maps or not
  49474. */
  49475. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49476. private _loadJson;
  49477. /**
  49478. * Is the texture ready to be used ? (rendered at least once)
  49479. * @returns true if ready, otherwise, false.
  49480. */
  49481. isReady(): boolean;
  49482. /**
  49483. * Render the texture to its associated render target.
  49484. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49485. */
  49486. render(useCameraPostProcess?: boolean): void;
  49487. /**
  49488. * Update the list of dependant textures samplers in the shader.
  49489. */
  49490. updateTextures(): void;
  49491. /**
  49492. * Update the uniform values of the procedural texture in the shader.
  49493. */
  49494. updateShaderUniforms(): void;
  49495. /**
  49496. * Define if the texture animates or not.
  49497. */
  49498. animate: boolean;
  49499. }
  49500. }
  49501. declare module "babylonjs/Shaders/noise.fragment" {
  49502. /** @hidden */
  49503. export var noisePixelShader: {
  49504. name: string;
  49505. shader: string;
  49506. };
  49507. }
  49508. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49509. import { Nullable } from "babylonjs/types";
  49510. import { Scene } from "babylonjs/scene";
  49511. import { Texture } from "babylonjs/Materials/Textures/texture";
  49512. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49513. import "babylonjs/Shaders/noise.fragment";
  49514. /**
  49515. * Class used to generate noise procedural textures
  49516. */
  49517. export class NoiseProceduralTexture extends ProceduralTexture {
  49518. private _time;
  49519. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49520. brightness: number;
  49521. /** Defines the number of octaves to process */
  49522. octaves: number;
  49523. /** Defines the level of persistence (0.8 by default) */
  49524. persistence: number;
  49525. /** Gets or sets animation speed factor (default is 1) */
  49526. animationSpeedFactor: number;
  49527. /**
  49528. * Creates a new NoiseProceduralTexture
  49529. * @param name defines the name fo the texture
  49530. * @param size defines the size of the texture (default is 256)
  49531. * @param scene defines the hosting scene
  49532. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49533. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49534. */
  49535. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49536. private _updateShaderUniforms;
  49537. protected _getDefines(): string;
  49538. /** Generate the current state of the procedural texture */
  49539. render(useCameraPostProcess?: boolean): void;
  49540. /**
  49541. * Serializes this noise procedural texture
  49542. * @returns a serialized noise procedural texture object
  49543. */
  49544. serialize(): any;
  49545. /**
  49546. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49547. * @param parsedTexture defines parsed texture data
  49548. * @param scene defines the current scene
  49549. * @param rootUrl defines the root URL containing noise procedural texture information
  49550. * @returns a parsed NoiseProceduralTexture
  49551. */
  49552. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49553. }
  49554. }
  49555. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49556. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49557. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49558. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49559. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49560. }
  49561. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49562. import { Nullable } from "babylonjs/types";
  49563. import { Scene } from "babylonjs/scene";
  49564. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49566. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49567. /**
  49568. * Raw cube texture where the raw buffers are passed in
  49569. */
  49570. export class RawCubeTexture extends CubeTexture {
  49571. /**
  49572. * Creates a cube texture where the raw buffers are passed in.
  49573. * @param scene defines the scene the texture is attached to
  49574. * @param data defines the array of data to use to create each face
  49575. * @param size defines the size of the textures
  49576. * @param format defines the format of the data
  49577. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49578. * @param generateMipMaps defines if the engine should generate the mip levels
  49579. * @param invertY defines if data must be stored with Y axis inverted
  49580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49581. * @param compression defines the compression used (null by default)
  49582. */
  49583. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49584. /**
  49585. * Updates the raw cube texture.
  49586. * @param data defines the data to store
  49587. * @param format defines the data format
  49588. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49589. * @param invertY defines if data must be stored with Y axis inverted
  49590. * @param compression defines the compression used (null by default)
  49591. * @param level defines which level of the texture to update
  49592. */
  49593. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49594. /**
  49595. * Updates a raw cube texture with RGBD encoded data.
  49596. * @param data defines the array of data [mipmap][face] to use to create each face
  49597. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49598. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49599. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49600. * @returns a promsie that resolves when the operation is complete
  49601. */
  49602. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49603. /**
  49604. * Clones the raw cube texture.
  49605. * @return a new cube texture
  49606. */
  49607. clone(): CubeTexture;
  49608. /** @hidden */
  49609. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49610. }
  49611. }
  49612. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49613. import { Scene } from "babylonjs/scene";
  49614. import { Texture } from "babylonjs/Materials/Textures/texture";
  49615. /**
  49616. * Class used to store 3D textures containing user data
  49617. */
  49618. export class RawTexture3D extends Texture {
  49619. /** Gets or sets the texture format to use */
  49620. format: number;
  49621. private _engine;
  49622. /**
  49623. * Create a new RawTexture3D
  49624. * @param data defines the data of the texture
  49625. * @param width defines the width of the texture
  49626. * @param height defines the height of the texture
  49627. * @param depth defines the depth of the texture
  49628. * @param format defines the texture format to use
  49629. * @param scene defines the hosting scene
  49630. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49631. * @param invertY defines if texture must be stored with Y axis inverted
  49632. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49633. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49634. */
  49635. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49636. /** Gets or sets the texture format to use */
  49637. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49638. /**
  49639. * Update the texture with new data
  49640. * @param data defines the data to store in the texture
  49641. */
  49642. update(data: ArrayBufferView): void;
  49643. }
  49644. }
  49645. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49646. import { Scene } from "babylonjs/scene";
  49647. import { Plane } from "babylonjs/Maths/math";
  49648. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49649. /**
  49650. * Creates a refraction texture used by refraction channel of the standard material.
  49651. * It is like a mirror but to see through a material.
  49652. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49653. */
  49654. export class RefractionTexture extends RenderTargetTexture {
  49655. /**
  49656. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49657. * 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.
  49658. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49659. */
  49660. refractionPlane: Plane;
  49661. /**
  49662. * Define how deep under the surface we should see.
  49663. */
  49664. depth: number;
  49665. /**
  49666. * Creates a refraction texture used by refraction channel of the standard material.
  49667. * It is like a mirror but to see through a material.
  49668. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49669. * @param name Define the texture name
  49670. * @param size Define the size of the underlying texture
  49671. * @param scene Define the scene the refraction belongs to
  49672. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49673. */
  49674. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49675. /**
  49676. * Clone the refraction texture.
  49677. * @returns the cloned texture
  49678. */
  49679. clone(): RefractionTexture;
  49680. /**
  49681. * Serialize the texture to a JSON representation you could use in Parse later on
  49682. * @returns the serialized JSON representation
  49683. */
  49684. serialize(): any;
  49685. }
  49686. }
  49687. declare module "babylonjs/Materials/Textures/index" {
  49688. export * from "babylonjs/Materials/Textures/baseTexture";
  49689. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49690. export * from "babylonjs/Materials/Textures/cubeTexture";
  49691. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49692. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  49693. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49694. export * from "babylonjs/Materials/Textures/internalTexture";
  49695. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49696. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49697. export * from "babylonjs/Materials/Textures/Loaders/index";
  49698. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49699. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49700. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49701. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49702. export * from "babylonjs/Materials/Textures/rawTexture";
  49703. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49704. export * from "babylonjs/Materials/Textures/refractionTexture";
  49705. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49706. export * from "babylonjs/Materials/Textures/texture";
  49707. export * from "babylonjs/Materials/Textures/videoTexture";
  49708. }
  49709. declare module "babylonjs/Materials/index" {
  49710. export * from "babylonjs/Materials/Background/index";
  49711. export * from "babylonjs/Materials/colorCurves";
  49712. export * from "babylonjs/Materials/effect";
  49713. export * from "babylonjs/Materials/fresnelParameters";
  49714. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49715. export * from "babylonjs/Materials/material";
  49716. export * from "babylonjs/Materials/materialDefines";
  49717. export * from "babylonjs/Materials/materialHelper";
  49718. export * from "babylonjs/Materials/multiMaterial";
  49719. export * from "babylonjs/Materials/PBR/index";
  49720. export * from "babylonjs/Materials/pushMaterial";
  49721. export * from "babylonjs/Materials/shaderMaterial";
  49722. export * from "babylonjs/Materials/standardMaterial";
  49723. export * from "babylonjs/Materials/Textures/index";
  49724. export * from "babylonjs/Materials/uniformBuffer";
  49725. export * from "babylonjs/Materials/materialFlags";
  49726. }
  49727. declare module "babylonjs/Maths/index" {
  49728. export * from "babylonjs/Maths/math.scalar";
  49729. export * from "babylonjs/Maths/math";
  49730. export * from "babylonjs/Maths/sphericalPolynomial";
  49731. }
  49732. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49733. import { IDisposable } from "babylonjs/scene";
  49734. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49735. /**
  49736. * Configuration for Draco compression
  49737. */
  49738. export interface IDracoCompressionConfiguration {
  49739. /**
  49740. * Configuration for the decoder.
  49741. */
  49742. decoder?: {
  49743. /**
  49744. * The url to the WebAssembly module.
  49745. */
  49746. wasmUrl?: string;
  49747. /**
  49748. * The url to the WebAssembly binary.
  49749. */
  49750. wasmBinaryUrl?: string;
  49751. /**
  49752. * The url to the fallback JavaScript module.
  49753. */
  49754. fallbackUrl?: string;
  49755. };
  49756. }
  49757. /**
  49758. * Draco compression (https://google.github.io/draco/)
  49759. *
  49760. * This class wraps the Draco module.
  49761. *
  49762. * **Encoder**
  49763. *
  49764. * The encoder is not currently implemented.
  49765. *
  49766. * **Decoder**
  49767. *
  49768. * 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.
  49769. *
  49770. * To update the configuration, use the following code:
  49771. * ```javascript
  49772. * DracoCompression.Configuration = {
  49773. * decoder: {
  49774. * wasmUrl: "<url to the WebAssembly library>",
  49775. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49776. * fallbackUrl: "<url to the fallback JavaScript library>",
  49777. * }
  49778. * };
  49779. * ```
  49780. *
  49781. * 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.
  49782. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49783. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49784. *
  49785. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49786. * ```javascript
  49787. * var dracoCompression = new DracoCompression();
  49788. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49789. * [VertexBuffer.PositionKind]: 0
  49790. * });
  49791. * ```
  49792. *
  49793. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49794. */
  49795. export class DracoCompression implements IDisposable {
  49796. private static _DecoderModulePromise;
  49797. /**
  49798. * The configuration. Defaults to the following urls:
  49799. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49800. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49801. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49802. */
  49803. static Configuration: IDracoCompressionConfiguration;
  49804. /**
  49805. * Returns true if the decoder is available.
  49806. */
  49807. static readonly DecoderAvailable: boolean;
  49808. /**
  49809. * Constructor
  49810. */
  49811. constructor();
  49812. /**
  49813. * Stop all async operations and release resources.
  49814. */
  49815. dispose(): void;
  49816. /**
  49817. * Decode Draco compressed mesh data to vertex data.
  49818. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49819. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49820. * @returns A promise that resolves with the decoded vertex data
  49821. */
  49822. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49823. [kind: string]: number;
  49824. }): Promise<VertexData>;
  49825. private static _GetDecoderModule;
  49826. private static _LoadScriptAsync;
  49827. private static _LoadFileAsync;
  49828. }
  49829. }
  49830. declare module "babylonjs/Meshes/Compression/index" {
  49831. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49832. }
  49833. declare module "babylonjs/Meshes/csg" {
  49834. import { Nullable } from "babylonjs/types";
  49835. import { Scene } from "babylonjs/scene";
  49836. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49837. import { Mesh } from "babylonjs/Meshes/mesh";
  49838. import { Material } from "babylonjs/Materials/material";
  49839. /**
  49840. * Class for building Constructive Solid Geometry
  49841. */
  49842. export class CSG {
  49843. private polygons;
  49844. /**
  49845. * The world matrix
  49846. */
  49847. matrix: Matrix;
  49848. /**
  49849. * Stores the position
  49850. */
  49851. position: Vector3;
  49852. /**
  49853. * Stores the rotation
  49854. */
  49855. rotation: Vector3;
  49856. /**
  49857. * Stores the rotation quaternion
  49858. */
  49859. rotationQuaternion: Nullable<Quaternion>;
  49860. /**
  49861. * Stores the scaling vector
  49862. */
  49863. scaling: Vector3;
  49864. /**
  49865. * Convert the Mesh to CSG
  49866. * @param mesh The Mesh to convert to CSG
  49867. * @returns A new CSG from the Mesh
  49868. */
  49869. static FromMesh(mesh: Mesh): CSG;
  49870. /**
  49871. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49872. * @param polygons Polygons used to construct a CSG solid
  49873. */
  49874. private static FromPolygons;
  49875. /**
  49876. * Clones, or makes a deep copy, of the CSG
  49877. * @returns A new CSG
  49878. */
  49879. clone(): CSG;
  49880. /**
  49881. * Unions this CSG with another CSG
  49882. * @param csg The CSG to union against this CSG
  49883. * @returns The unioned CSG
  49884. */
  49885. union(csg: CSG): CSG;
  49886. /**
  49887. * Unions this CSG with another CSG in place
  49888. * @param csg The CSG to union against this CSG
  49889. */
  49890. unionInPlace(csg: CSG): void;
  49891. /**
  49892. * Subtracts this CSG with another CSG
  49893. * @param csg The CSG to subtract against this CSG
  49894. * @returns A new CSG
  49895. */
  49896. subtract(csg: CSG): CSG;
  49897. /**
  49898. * Subtracts this CSG with another CSG in place
  49899. * @param csg The CSG to subtact against this CSG
  49900. */
  49901. subtractInPlace(csg: CSG): void;
  49902. /**
  49903. * Intersect this CSG with another CSG
  49904. * @param csg The CSG to intersect against this CSG
  49905. * @returns A new CSG
  49906. */
  49907. intersect(csg: CSG): CSG;
  49908. /**
  49909. * Intersects this CSG with another CSG in place
  49910. * @param csg The CSG to intersect against this CSG
  49911. */
  49912. intersectInPlace(csg: CSG): void;
  49913. /**
  49914. * Return a new CSG solid with solid and empty space switched. This solid is
  49915. * not modified.
  49916. * @returns A new CSG solid with solid and empty space switched
  49917. */
  49918. inverse(): CSG;
  49919. /**
  49920. * Inverses the CSG in place
  49921. */
  49922. inverseInPlace(): void;
  49923. /**
  49924. * This is used to keep meshes transformations so they can be restored
  49925. * when we build back a Babylon Mesh
  49926. * NB : All CSG operations are performed in world coordinates
  49927. * @param csg The CSG to copy the transform attributes from
  49928. * @returns This CSG
  49929. */
  49930. copyTransformAttributes(csg: CSG): CSG;
  49931. /**
  49932. * Build Raw mesh from CSG
  49933. * Coordinates here are in world space
  49934. * @param name The name of the mesh geometry
  49935. * @param scene The Scene
  49936. * @param keepSubMeshes Specifies if the submeshes should be kept
  49937. * @returns A new Mesh
  49938. */
  49939. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49940. /**
  49941. * Build Mesh from CSG taking material and transforms into account
  49942. * @param name The name of the Mesh
  49943. * @param material The material of the Mesh
  49944. * @param scene The Scene
  49945. * @param keepSubMeshes Specifies if submeshes should be kept
  49946. * @returns The new Mesh
  49947. */
  49948. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49949. }
  49950. }
  49951. declare module "babylonjs/Meshes/trailMesh" {
  49952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49953. import { Mesh } from "babylonjs/Meshes/mesh";
  49954. import { Scene } from "babylonjs/scene";
  49955. /**
  49956. * Class used to create a trail following a mesh
  49957. */
  49958. export class TrailMesh extends Mesh {
  49959. private _generator;
  49960. private _autoStart;
  49961. private _running;
  49962. private _diameter;
  49963. private _length;
  49964. private _sectionPolygonPointsCount;
  49965. private _sectionVectors;
  49966. private _sectionNormalVectors;
  49967. private _beforeRenderObserver;
  49968. /**
  49969. * @constructor
  49970. * @param name The value used by scene.getMeshByName() to do a lookup.
  49971. * @param generator The mesh to generate a trail.
  49972. * @param scene The scene to add this mesh to.
  49973. * @param diameter Diameter of trailing mesh. Default is 1.
  49974. * @param length Length of trailing mesh. Default is 60.
  49975. * @param autoStart Automatically start trailing mesh. Default true.
  49976. */
  49977. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49978. /**
  49979. * "TrailMesh"
  49980. * @returns "TrailMesh"
  49981. */
  49982. getClassName(): string;
  49983. private _createMesh;
  49984. /**
  49985. * Start trailing mesh.
  49986. */
  49987. start(): void;
  49988. /**
  49989. * Stop trailing mesh.
  49990. */
  49991. stop(): void;
  49992. /**
  49993. * Update trailing mesh geometry.
  49994. */
  49995. update(): void;
  49996. /**
  49997. * Returns a new TrailMesh object.
  49998. * @param name is a string, the name given to the new mesh
  49999. * @param newGenerator use new generator object for cloned trail mesh
  50000. * @returns a new mesh
  50001. */
  50002. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50003. /**
  50004. * Serializes this trail mesh
  50005. * @param serializationObject object to write serialization to
  50006. */
  50007. serialize(serializationObject: any): void;
  50008. /**
  50009. * Parses a serialized trail mesh
  50010. * @param parsedMesh the serialized mesh
  50011. * @param scene the scene to create the trail mesh in
  50012. * @returns the created trail mesh
  50013. */
  50014. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50015. }
  50016. }
  50017. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50018. import { Nullable } from "babylonjs/types";
  50019. import { Scene } from "babylonjs/scene";
  50020. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50021. import { Mesh } from "babylonjs/Meshes/mesh";
  50022. /**
  50023. * Class containing static functions to help procedurally build meshes
  50024. */
  50025. export class RibbonBuilder {
  50026. /**
  50027. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50028. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50029. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50030. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50031. * * 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
  50032. * * 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
  50033. * * 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
  50034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50037. * * 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
  50038. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50039. * * 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
  50040. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50042. * @param name defines the name of the mesh
  50043. * @param options defines the options used to create the mesh
  50044. * @param scene defines the hosting scene
  50045. * @returns the ribbon mesh
  50046. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50048. */
  50049. static CreateRibbon(name: string, options: {
  50050. pathArray: Vector3[][];
  50051. closeArray?: boolean;
  50052. closePath?: boolean;
  50053. offset?: number;
  50054. updatable?: boolean;
  50055. sideOrientation?: number;
  50056. frontUVs?: Vector4;
  50057. backUVs?: Vector4;
  50058. instance?: Mesh;
  50059. invertUV?: boolean;
  50060. uvs?: Vector2[];
  50061. colors?: Color4[];
  50062. }, scene?: Nullable<Scene>): Mesh;
  50063. }
  50064. }
  50065. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50066. import { Vector4 } from "babylonjs/Maths/math";
  50067. import { Mesh } from "babylonjs/Meshes/mesh";
  50068. /**
  50069. * Class containing static functions to help procedurally build meshes
  50070. */
  50071. export class TorusKnotBuilder {
  50072. /**
  50073. * Creates a torus knot mesh
  50074. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50075. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50076. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50077. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50081. * @param name defines the name of the mesh
  50082. * @param options defines the options used to create the mesh
  50083. * @param scene defines the hosting scene
  50084. * @returns the torus knot mesh
  50085. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50086. */
  50087. static CreateTorusKnot(name: string, options: {
  50088. radius?: number;
  50089. tube?: number;
  50090. radialSegments?: number;
  50091. tubularSegments?: number;
  50092. p?: number;
  50093. q?: number;
  50094. updatable?: boolean;
  50095. sideOrientation?: number;
  50096. frontUVs?: Vector4;
  50097. backUVs?: Vector4;
  50098. }, scene: any): Mesh;
  50099. }
  50100. }
  50101. declare module "babylonjs/Meshes/polygonMesh" {
  50102. import { Scene } from "babylonjs/scene";
  50103. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50104. import { Mesh } from "babylonjs/Meshes/mesh";
  50105. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50106. /**
  50107. * Polygon
  50108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50109. */
  50110. export class Polygon {
  50111. /**
  50112. * Creates a rectangle
  50113. * @param xmin bottom X coord
  50114. * @param ymin bottom Y coord
  50115. * @param xmax top X coord
  50116. * @param ymax top Y coord
  50117. * @returns points that make the resulting rectation
  50118. */
  50119. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50120. /**
  50121. * Creates a circle
  50122. * @param radius radius of circle
  50123. * @param cx scale in x
  50124. * @param cy scale in y
  50125. * @param numberOfSides number of sides that make up the circle
  50126. * @returns points that make the resulting circle
  50127. */
  50128. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50129. /**
  50130. * Creates a polygon from input string
  50131. * @param input Input polygon data
  50132. * @returns the parsed points
  50133. */
  50134. static Parse(input: string): Vector2[];
  50135. /**
  50136. * Starts building a polygon from x and y coordinates
  50137. * @param x x coordinate
  50138. * @param y y coordinate
  50139. * @returns the started path2
  50140. */
  50141. static StartingAt(x: number, y: number): Path2;
  50142. }
  50143. /**
  50144. * Builds a polygon
  50145. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50146. */
  50147. export class PolygonMeshBuilder {
  50148. private _points;
  50149. private _outlinepoints;
  50150. private _holes;
  50151. private _name;
  50152. private _scene;
  50153. private _epoints;
  50154. private _eholes;
  50155. private _addToepoint;
  50156. /**
  50157. * Babylon reference to the earcut plugin.
  50158. */
  50159. bjsEarcut: any;
  50160. /**
  50161. * Creates a PolygonMeshBuilder
  50162. * @param name name of the builder
  50163. * @param contours Path of the polygon
  50164. * @param scene scene to add to when creating the mesh
  50165. * @param earcutInjection can be used to inject your own earcut reference
  50166. */
  50167. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50168. /**
  50169. * Adds a whole within the polygon
  50170. * @param hole Array of points defining the hole
  50171. * @returns this
  50172. */
  50173. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50174. /**
  50175. * Creates the polygon
  50176. * @param updatable If the mesh should be updatable
  50177. * @param depth The depth of the mesh created
  50178. * @returns the created mesh
  50179. */
  50180. build(updatable?: boolean, depth?: number): Mesh;
  50181. /**
  50182. * Creates the polygon
  50183. * @param depth The depth of the mesh created
  50184. * @returns the created VertexData
  50185. */
  50186. buildVertexData(depth?: number): VertexData;
  50187. /**
  50188. * Adds a side to the polygon
  50189. * @param positions points that make the polygon
  50190. * @param normals normals of the polygon
  50191. * @param uvs uvs of the polygon
  50192. * @param indices indices of the polygon
  50193. * @param bounds bounds of the polygon
  50194. * @param points points of the polygon
  50195. * @param depth depth of the polygon
  50196. * @param flip flip of the polygon
  50197. */
  50198. private addSide;
  50199. }
  50200. }
  50201. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50202. import { Scene } from "babylonjs/scene";
  50203. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50204. import { Mesh } from "babylonjs/Meshes/mesh";
  50205. /**
  50206. * Class containing static functions to help procedurally build meshes
  50207. */
  50208. export class PolygonBuilder {
  50209. /**
  50210. * Creates a polygon mesh
  50211. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50212. * * 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
  50213. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50216. * * Remember you can only change the shape positions, not their number when updating a polygon
  50217. * @param name defines the name of the mesh
  50218. * @param options defines the options used to create the mesh
  50219. * @param scene defines the hosting scene
  50220. * @param earcutInjection can be used to inject your own earcut reference
  50221. * @returns the polygon mesh
  50222. */
  50223. static CreatePolygon(name: string, options: {
  50224. shape: Vector3[];
  50225. holes?: Vector3[][];
  50226. depth?: number;
  50227. faceUV?: Vector4[];
  50228. faceColors?: Color4[];
  50229. updatable?: boolean;
  50230. sideOrientation?: number;
  50231. frontUVs?: Vector4;
  50232. backUVs?: Vector4;
  50233. }, scene: Scene, earcutInjection?: any): Mesh;
  50234. /**
  50235. * Creates an extruded polygon mesh, with depth in the Y direction.
  50236. * * 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)
  50237. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50238. * @param name defines the name of the mesh
  50239. * @param options defines the options used to create the mesh
  50240. * @param scene defines the hosting scene
  50241. * @param earcutInjection can be used to inject your own earcut reference
  50242. * @returns the polygon mesh
  50243. */
  50244. static ExtrudePolygon(name: string, options: {
  50245. shape: Vector3[];
  50246. holes?: Vector3[][];
  50247. depth?: number;
  50248. faceUV?: Vector4[];
  50249. faceColors?: Color4[];
  50250. updatable?: boolean;
  50251. sideOrientation?: number;
  50252. frontUVs?: Vector4;
  50253. backUVs?: Vector4;
  50254. }, scene: Scene, earcutInjection?: any): Mesh;
  50255. }
  50256. }
  50257. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50258. import { Nullable } from "babylonjs/types";
  50259. import { Scene } from "babylonjs/scene";
  50260. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50261. import { Mesh } from "babylonjs/Meshes/mesh";
  50262. /**
  50263. * Class containing static functions to help procedurally build meshes
  50264. */
  50265. export class ShapeBuilder {
  50266. /**
  50267. * 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.
  50268. * * 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.
  50269. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50270. * * 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.
  50271. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50272. * * 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
  50273. * * 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
  50274. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50279. * @param name defines the name of the mesh
  50280. * @param options defines the options used to create the mesh
  50281. * @param scene defines the hosting scene
  50282. * @returns the extruded shape mesh
  50283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50285. */
  50286. static ExtrudeShape(name: string, options: {
  50287. shape: Vector3[];
  50288. path: Vector3[];
  50289. scale?: number;
  50290. rotation?: number;
  50291. cap?: number;
  50292. updatable?: boolean;
  50293. sideOrientation?: number;
  50294. frontUVs?: Vector4;
  50295. backUVs?: Vector4;
  50296. instance?: Mesh;
  50297. invertUV?: boolean;
  50298. }, scene?: Nullable<Scene>): Mesh;
  50299. /**
  50300. * Creates an custom extruded shape mesh.
  50301. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50302. * * 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.
  50303. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50304. * * 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
  50305. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50306. * * 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
  50307. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50308. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50309. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50310. * * 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
  50311. * * 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
  50312. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50317. * @param name defines the name of the mesh
  50318. * @param options defines the options used to create the mesh
  50319. * @param scene defines the hosting scene
  50320. * @returns the custom extruded shape mesh
  50321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50324. */
  50325. static ExtrudeShapeCustom(name: string, options: {
  50326. shape: Vector3[];
  50327. path: Vector3[];
  50328. scaleFunction?: any;
  50329. rotationFunction?: any;
  50330. ribbonCloseArray?: boolean;
  50331. ribbonClosePath?: boolean;
  50332. cap?: number;
  50333. updatable?: boolean;
  50334. sideOrientation?: number;
  50335. frontUVs?: Vector4;
  50336. backUVs?: Vector4;
  50337. instance?: Mesh;
  50338. invertUV?: boolean;
  50339. }, scene: Scene): Mesh;
  50340. private static _ExtrudeShapeGeneric;
  50341. }
  50342. }
  50343. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50344. import { Scene } from "babylonjs/scene";
  50345. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50346. import { Mesh } from "babylonjs/Meshes/mesh";
  50347. /**
  50348. * Class containing static functions to help procedurally build meshes
  50349. */
  50350. export class LatheBuilder {
  50351. /**
  50352. * Creates lathe mesh.
  50353. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50354. * * 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
  50355. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50356. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50357. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50358. * * 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
  50359. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50360. * * 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
  50361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50363. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50365. * @param name defines the name of the mesh
  50366. * @param options defines the options used to create the mesh
  50367. * @param scene defines the hosting scene
  50368. * @returns the lathe mesh
  50369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50370. */
  50371. static CreateLathe(name: string, options: {
  50372. shape: Vector3[];
  50373. radius?: number;
  50374. tessellation?: number;
  50375. clip?: number;
  50376. arc?: number;
  50377. closed?: boolean;
  50378. updatable?: boolean;
  50379. sideOrientation?: number;
  50380. frontUVs?: Vector4;
  50381. backUVs?: Vector4;
  50382. cap?: number;
  50383. invertUV?: boolean;
  50384. }, scene: Scene): Mesh;
  50385. }
  50386. }
  50387. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50388. import { Scene } from "babylonjs/scene";
  50389. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50390. import { Mesh } from "babylonjs/Meshes/mesh";
  50391. /**
  50392. * Class containing static functions to help procedurally build meshes
  50393. */
  50394. export class TubeBuilder {
  50395. /**
  50396. * Creates a tube mesh.
  50397. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50398. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50399. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50400. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50401. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50402. * * 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)
  50403. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50404. * * 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
  50405. * * 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
  50406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50410. * @param name defines the name of the mesh
  50411. * @param options defines the options used to create the mesh
  50412. * @param scene defines the hosting scene
  50413. * @returns the tube mesh
  50414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50415. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50416. */
  50417. static CreateTube(name: string, options: {
  50418. path: Vector3[];
  50419. radius?: number;
  50420. tessellation?: number;
  50421. radiusFunction?: {
  50422. (i: number, distance: number): number;
  50423. };
  50424. cap?: number;
  50425. arc?: number;
  50426. updatable?: boolean;
  50427. sideOrientation?: number;
  50428. frontUVs?: Vector4;
  50429. backUVs?: Vector4;
  50430. instance?: Mesh;
  50431. invertUV?: boolean;
  50432. }, scene: Scene): Mesh;
  50433. }
  50434. }
  50435. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50436. import { Scene } from "babylonjs/scene";
  50437. import { Vector4 } from "babylonjs/Maths/math";
  50438. import { Mesh } from "babylonjs/Meshes/mesh";
  50439. /**
  50440. * Class containing static functions to help procedurally build meshes
  50441. */
  50442. export class IcoSphereBuilder {
  50443. /**
  50444. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50445. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50446. * * 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`)
  50447. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50448. * * 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
  50449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50452. * @param name defines the name of the mesh
  50453. * @param options defines the options used to create the mesh
  50454. * @param scene defines the hosting scene
  50455. * @returns the icosahedron mesh
  50456. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50457. */
  50458. static CreateIcoSphere(name: string, options: {
  50459. radius?: number;
  50460. radiusX?: number;
  50461. radiusY?: number;
  50462. radiusZ?: number;
  50463. flat?: boolean;
  50464. subdivisions?: number;
  50465. sideOrientation?: number;
  50466. frontUVs?: Vector4;
  50467. backUVs?: Vector4;
  50468. updatable?: boolean;
  50469. }, scene: Scene): Mesh;
  50470. }
  50471. }
  50472. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50473. import { Vector3 } from "babylonjs/Maths/math";
  50474. import { Mesh } from "babylonjs/Meshes/mesh";
  50475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50476. /**
  50477. * Class containing static functions to help procedurally build meshes
  50478. */
  50479. export class DecalBuilder {
  50480. /**
  50481. * Creates a decal mesh.
  50482. * 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
  50483. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50484. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50485. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50486. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50487. * @param name defines the name of the mesh
  50488. * @param sourceMesh defines the mesh where the decal must be applied
  50489. * @param options defines the options used to create the mesh
  50490. * @param scene defines the hosting scene
  50491. * @returns the decal mesh
  50492. * @see https://doc.babylonjs.com/how_to/decals
  50493. */
  50494. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50495. position?: Vector3;
  50496. normal?: Vector3;
  50497. size?: Vector3;
  50498. angle?: number;
  50499. }): Mesh;
  50500. }
  50501. }
  50502. declare module "babylonjs/Meshes/meshBuilder" {
  50503. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50504. import { Nullable } from "babylonjs/types";
  50505. import { Scene } from "babylonjs/scene";
  50506. import { Mesh } from "babylonjs/Meshes/mesh";
  50507. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50508. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50510. /**
  50511. * Class containing static functions to help procedurally build meshes
  50512. */
  50513. export class MeshBuilder {
  50514. /**
  50515. * Creates a box mesh
  50516. * * The parameter `size` sets the size (float) of each box side (default 1)
  50517. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50518. * * 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)
  50519. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50523. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50524. * @param name defines the name of the mesh
  50525. * @param options defines the options used to create the mesh
  50526. * @param scene defines the hosting scene
  50527. * @returns the box mesh
  50528. */
  50529. static CreateBox(name: string, options: {
  50530. size?: number;
  50531. width?: number;
  50532. height?: number;
  50533. depth?: number;
  50534. faceUV?: Vector4[];
  50535. faceColors?: Color4[];
  50536. sideOrientation?: number;
  50537. frontUVs?: Vector4;
  50538. backUVs?: Vector4;
  50539. updatable?: boolean;
  50540. }, scene?: Nullable<Scene>): Mesh;
  50541. /**
  50542. * Creates a sphere mesh
  50543. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50544. * * 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`)
  50545. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50546. * * 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
  50547. * * 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)
  50548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50551. * @param name defines the name of the mesh
  50552. * @param options defines the options used to create the mesh
  50553. * @param scene defines the hosting scene
  50554. * @returns the sphere mesh
  50555. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50556. */
  50557. static CreateSphere(name: string, options: {
  50558. segments?: number;
  50559. diameter?: number;
  50560. diameterX?: number;
  50561. diameterY?: number;
  50562. diameterZ?: number;
  50563. arc?: number;
  50564. slice?: number;
  50565. sideOrientation?: number;
  50566. frontUVs?: Vector4;
  50567. backUVs?: Vector4;
  50568. updatable?: boolean;
  50569. }, scene: any): Mesh;
  50570. /**
  50571. * Creates a plane polygonal mesh. By default, this is a disc
  50572. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50573. * * 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
  50574. * * 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
  50575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50578. * @param name defines the name of the mesh
  50579. * @param options defines the options used to create the mesh
  50580. * @param scene defines the hosting scene
  50581. * @returns the plane polygonal mesh
  50582. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50583. */
  50584. static CreateDisc(name: string, options: {
  50585. radius?: number;
  50586. tessellation?: number;
  50587. arc?: number;
  50588. updatable?: boolean;
  50589. sideOrientation?: number;
  50590. frontUVs?: Vector4;
  50591. backUVs?: Vector4;
  50592. }, scene?: Nullable<Scene>): Mesh;
  50593. /**
  50594. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50595. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50596. * * 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`)
  50597. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50598. * * 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
  50599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50602. * @param name defines the name of the mesh
  50603. * @param options defines the options used to create the mesh
  50604. * @param scene defines the hosting scene
  50605. * @returns the icosahedron mesh
  50606. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50607. */
  50608. static CreateIcoSphere(name: string, options: {
  50609. radius?: number;
  50610. radiusX?: number;
  50611. radiusY?: number;
  50612. radiusZ?: number;
  50613. flat?: boolean;
  50614. subdivisions?: number;
  50615. sideOrientation?: number;
  50616. frontUVs?: Vector4;
  50617. backUVs?: Vector4;
  50618. updatable?: boolean;
  50619. }, scene: Scene): Mesh;
  50620. /**
  50621. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50622. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50623. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50624. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50625. * * 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
  50626. * * 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
  50627. * * 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
  50628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50630. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50631. * * 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
  50632. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50633. * * 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
  50634. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50636. * @param name defines the name of the mesh
  50637. * @param options defines the options used to create the mesh
  50638. * @param scene defines the hosting scene
  50639. * @returns the ribbon mesh
  50640. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50642. */
  50643. static CreateRibbon(name: string, options: {
  50644. pathArray: Vector3[][];
  50645. closeArray?: boolean;
  50646. closePath?: boolean;
  50647. offset?: number;
  50648. updatable?: boolean;
  50649. sideOrientation?: number;
  50650. frontUVs?: Vector4;
  50651. backUVs?: Vector4;
  50652. instance?: Mesh;
  50653. invertUV?: boolean;
  50654. uvs?: Vector2[];
  50655. colors?: Color4[];
  50656. }, scene?: Nullable<Scene>): Mesh;
  50657. /**
  50658. * Creates a cylinder or a cone mesh
  50659. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50660. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50661. * * 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.
  50662. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50663. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50664. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50665. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50666. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50667. * * 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).
  50668. * * 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
  50669. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50670. * * 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
  50671. * * 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.
  50672. * * If `enclose` is false, a ring surface is one element.
  50673. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50674. * * 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
  50675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50678. * @param name defines the name of the mesh
  50679. * @param options defines the options used to create the mesh
  50680. * @param scene defines the hosting scene
  50681. * @returns the cylinder mesh
  50682. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50683. */
  50684. static CreateCylinder(name: string, options: {
  50685. height?: number;
  50686. diameterTop?: number;
  50687. diameterBottom?: number;
  50688. diameter?: number;
  50689. tessellation?: number;
  50690. subdivisions?: number;
  50691. arc?: number;
  50692. faceColors?: Color4[];
  50693. faceUV?: Vector4[];
  50694. updatable?: boolean;
  50695. hasRings?: boolean;
  50696. enclose?: boolean;
  50697. sideOrientation?: number;
  50698. frontUVs?: Vector4;
  50699. backUVs?: Vector4;
  50700. }, scene: any): Mesh;
  50701. /**
  50702. * Creates a torus mesh
  50703. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50704. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50705. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50709. * @param name defines the name of the mesh
  50710. * @param options defines the options used to create the mesh
  50711. * @param scene defines the hosting scene
  50712. * @returns the torus mesh
  50713. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50714. */
  50715. static CreateTorus(name: string, options: {
  50716. diameter?: number;
  50717. thickness?: number;
  50718. tessellation?: number;
  50719. updatable?: boolean;
  50720. sideOrientation?: number;
  50721. frontUVs?: Vector4;
  50722. backUVs?: Vector4;
  50723. }, scene: any): Mesh;
  50724. /**
  50725. * Creates a torus knot mesh
  50726. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50727. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50728. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50729. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50733. * @param name defines the name of the mesh
  50734. * @param options defines the options used to create the mesh
  50735. * @param scene defines the hosting scene
  50736. * @returns the torus knot mesh
  50737. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50738. */
  50739. static CreateTorusKnot(name: string, options: {
  50740. radius?: number;
  50741. tube?: number;
  50742. radialSegments?: number;
  50743. tubularSegments?: number;
  50744. p?: number;
  50745. q?: number;
  50746. updatable?: boolean;
  50747. sideOrientation?: number;
  50748. frontUVs?: Vector4;
  50749. backUVs?: Vector4;
  50750. }, scene: any): Mesh;
  50751. /**
  50752. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50753. * * 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
  50754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50755. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50756. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50757. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50758. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50759. * * 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
  50760. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50763. * @param name defines the name of the new line system
  50764. * @param options defines the options used to create the line system
  50765. * @param scene defines the hosting scene
  50766. * @returns a new line system mesh
  50767. */
  50768. static CreateLineSystem(name: string, options: {
  50769. lines: Vector3[][];
  50770. updatable?: boolean;
  50771. instance?: Nullable<LinesMesh>;
  50772. colors?: Nullable<Color4[][]>;
  50773. useVertexAlpha?: boolean;
  50774. }, scene: Nullable<Scene>): LinesMesh;
  50775. /**
  50776. * Creates a line mesh
  50777. * 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
  50778. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50779. * * The parameter `points` is an array successive Vector3
  50780. * * 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
  50781. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50782. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50783. * * When updating an instance, remember that only point positions can change, not the number of points
  50784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50786. * @param name defines the name of the new line system
  50787. * @param options defines the options used to create the line system
  50788. * @param scene defines the hosting scene
  50789. * @returns a new line mesh
  50790. */
  50791. static CreateLines(name: string, options: {
  50792. points: Vector3[];
  50793. updatable?: boolean;
  50794. instance?: Nullable<LinesMesh>;
  50795. colors?: Color4[];
  50796. useVertexAlpha?: boolean;
  50797. }, scene?: Nullable<Scene>): LinesMesh;
  50798. /**
  50799. * Creates a dashed line mesh
  50800. * * 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
  50801. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50802. * * The parameter `points` is an array successive Vector3
  50803. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50804. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50805. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50806. * * 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
  50807. * * When updating an instance, remember that only point positions can change, not the number of points
  50808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50809. * @param name defines the name of the mesh
  50810. * @param options defines the options used to create the mesh
  50811. * @param scene defines the hosting scene
  50812. * @returns the dashed line mesh
  50813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50814. */
  50815. static CreateDashedLines(name: string, options: {
  50816. points: Vector3[];
  50817. dashSize?: number;
  50818. gapSize?: number;
  50819. dashNb?: number;
  50820. updatable?: boolean;
  50821. instance?: LinesMesh;
  50822. }, scene?: Nullable<Scene>): LinesMesh;
  50823. /**
  50824. * 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.
  50825. * * 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.
  50826. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50827. * * 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.
  50828. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50829. * * 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
  50830. * * 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
  50831. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50836. * @param name defines the name of the mesh
  50837. * @param options defines the options used to create the mesh
  50838. * @param scene defines the hosting scene
  50839. * @returns the extruded shape mesh
  50840. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50842. */
  50843. static ExtrudeShape(name: string, options: {
  50844. shape: Vector3[];
  50845. path: Vector3[];
  50846. scale?: number;
  50847. rotation?: number;
  50848. cap?: number;
  50849. updatable?: boolean;
  50850. sideOrientation?: number;
  50851. frontUVs?: Vector4;
  50852. backUVs?: Vector4;
  50853. instance?: Mesh;
  50854. invertUV?: boolean;
  50855. }, scene?: Nullable<Scene>): Mesh;
  50856. /**
  50857. * Creates an custom extruded shape mesh.
  50858. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50859. * * 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.
  50860. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50861. * * 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
  50862. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50863. * * 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
  50864. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50865. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50866. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50867. * * 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
  50868. * * 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
  50869. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50874. * @param name defines the name of the mesh
  50875. * @param options defines the options used to create the mesh
  50876. * @param scene defines the hosting scene
  50877. * @returns the custom extruded shape mesh
  50878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50879. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50881. */
  50882. static ExtrudeShapeCustom(name: string, options: {
  50883. shape: Vector3[];
  50884. path: Vector3[];
  50885. scaleFunction?: any;
  50886. rotationFunction?: any;
  50887. ribbonCloseArray?: boolean;
  50888. ribbonClosePath?: boolean;
  50889. cap?: number;
  50890. updatable?: boolean;
  50891. sideOrientation?: number;
  50892. frontUVs?: Vector4;
  50893. backUVs?: Vector4;
  50894. instance?: Mesh;
  50895. invertUV?: boolean;
  50896. }, scene: Scene): Mesh;
  50897. /**
  50898. * Creates lathe mesh.
  50899. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50900. * * 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
  50901. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50902. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50903. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50904. * * 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
  50905. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50906. * * 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
  50907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50911. * @param name defines the name of the mesh
  50912. * @param options defines the options used to create the mesh
  50913. * @param scene defines the hosting scene
  50914. * @returns the lathe mesh
  50915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50916. */
  50917. static CreateLathe(name: string, options: {
  50918. shape: Vector3[];
  50919. radius?: number;
  50920. tessellation?: number;
  50921. clip?: number;
  50922. arc?: number;
  50923. closed?: boolean;
  50924. updatable?: boolean;
  50925. sideOrientation?: number;
  50926. frontUVs?: Vector4;
  50927. backUVs?: Vector4;
  50928. cap?: number;
  50929. invertUV?: boolean;
  50930. }, scene: Scene): Mesh;
  50931. /**
  50932. * Creates a plane mesh
  50933. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50934. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50935. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50939. * @param name defines the name of the mesh
  50940. * @param options defines the options used to create the mesh
  50941. * @param scene defines the hosting scene
  50942. * @returns the plane mesh
  50943. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50944. */
  50945. static CreatePlane(name: string, options: {
  50946. size?: number;
  50947. width?: number;
  50948. height?: number;
  50949. sideOrientation?: number;
  50950. frontUVs?: Vector4;
  50951. backUVs?: Vector4;
  50952. updatable?: boolean;
  50953. sourcePlane?: Plane;
  50954. }, scene: Scene): Mesh;
  50955. /**
  50956. * Creates a ground mesh
  50957. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50958. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50960. * @param name defines the name of the mesh
  50961. * @param options defines the options used to create the mesh
  50962. * @param scene defines the hosting scene
  50963. * @returns the ground mesh
  50964. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50965. */
  50966. static CreateGround(name: string, options: {
  50967. width?: number;
  50968. height?: number;
  50969. subdivisions?: number;
  50970. subdivisionsX?: number;
  50971. subdivisionsY?: number;
  50972. updatable?: boolean;
  50973. }, scene: any): Mesh;
  50974. /**
  50975. * Creates a tiled ground mesh
  50976. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50977. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50978. * * 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
  50979. * * 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
  50980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50981. * @param name defines the name of the mesh
  50982. * @param options defines the options used to create the mesh
  50983. * @param scene defines the hosting scene
  50984. * @returns the tiled ground mesh
  50985. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50986. */
  50987. static CreateTiledGround(name: string, options: {
  50988. xmin: number;
  50989. zmin: number;
  50990. xmax: number;
  50991. zmax: number;
  50992. subdivisions?: {
  50993. w: number;
  50994. h: number;
  50995. };
  50996. precision?: {
  50997. w: number;
  50998. h: number;
  50999. };
  51000. updatable?: boolean;
  51001. }, scene: Scene): Mesh;
  51002. /**
  51003. * Creates a ground mesh from a height map
  51004. * * The parameter `url` sets the URL of the height map image resource.
  51005. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51006. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51007. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51008. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51009. * * 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.
  51010. * * 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).
  51011. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51013. * @param name defines the name of the mesh
  51014. * @param url defines the url to the height map
  51015. * @param options defines the options used to create the mesh
  51016. * @param scene defines the hosting scene
  51017. * @returns the ground mesh
  51018. * @see https://doc.babylonjs.com/babylon101/height_map
  51019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51020. */
  51021. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51022. width?: number;
  51023. height?: number;
  51024. subdivisions?: number;
  51025. minHeight?: number;
  51026. maxHeight?: number;
  51027. colorFilter?: Color3;
  51028. alphaFilter?: number;
  51029. updatable?: boolean;
  51030. onReady?: (mesh: GroundMesh) => void;
  51031. }, scene: Scene): GroundMesh;
  51032. /**
  51033. * Creates a polygon mesh
  51034. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51035. * * 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
  51036. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51039. * * Remember you can only change the shape positions, not their number when updating a polygon
  51040. * @param name defines the name of the mesh
  51041. * @param options defines the options used to create the mesh
  51042. * @param scene defines the hosting scene
  51043. * @param earcutInjection can be used to inject your own earcut reference
  51044. * @returns the polygon mesh
  51045. */
  51046. static CreatePolygon(name: string, options: {
  51047. shape: Vector3[];
  51048. holes?: Vector3[][];
  51049. depth?: number;
  51050. faceUV?: Vector4[];
  51051. faceColors?: Color4[];
  51052. updatable?: boolean;
  51053. sideOrientation?: number;
  51054. frontUVs?: Vector4;
  51055. backUVs?: Vector4;
  51056. }, scene: Scene, earcutInjection?: any): Mesh;
  51057. /**
  51058. * Creates an extruded polygon mesh, with depth in the Y direction.
  51059. * * 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)
  51060. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51061. * @param name defines the name of the mesh
  51062. * @param options defines the options used to create the mesh
  51063. * @param scene defines the hosting scene
  51064. * @param earcutInjection can be used to inject your own earcut reference
  51065. * @returns the polygon mesh
  51066. */
  51067. static ExtrudePolygon(name: string, options: {
  51068. shape: Vector3[];
  51069. holes?: Vector3[][];
  51070. depth?: number;
  51071. faceUV?: Vector4[];
  51072. faceColors?: Color4[];
  51073. updatable?: boolean;
  51074. sideOrientation?: number;
  51075. frontUVs?: Vector4;
  51076. backUVs?: Vector4;
  51077. }, scene: Scene, earcutInjection?: any): Mesh;
  51078. /**
  51079. * Creates a tube mesh.
  51080. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51081. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51082. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51083. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51084. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51085. * * 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)
  51086. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51087. * * 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
  51088. * * 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
  51089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51093. * @param name defines the name of the mesh
  51094. * @param options defines the options used to create the mesh
  51095. * @param scene defines the hosting scene
  51096. * @returns the tube mesh
  51097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51098. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51099. */
  51100. static CreateTube(name: string, options: {
  51101. path: Vector3[];
  51102. radius?: number;
  51103. tessellation?: number;
  51104. radiusFunction?: {
  51105. (i: number, distance: number): number;
  51106. };
  51107. cap?: number;
  51108. arc?: number;
  51109. updatable?: boolean;
  51110. sideOrientation?: number;
  51111. frontUVs?: Vector4;
  51112. backUVs?: Vector4;
  51113. instance?: Mesh;
  51114. invertUV?: boolean;
  51115. }, scene: Scene): Mesh;
  51116. /**
  51117. * Creates a polyhedron mesh
  51118. * * 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
  51119. * * The parameter `size` (positive float, default 1) sets the polygon size
  51120. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51121. * * 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`
  51122. * * 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
  51123. * * 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)`)
  51124. * * 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
  51125. * * 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
  51126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51129. * @param name defines the name of the mesh
  51130. * @param options defines the options used to create the mesh
  51131. * @param scene defines the hosting scene
  51132. * @returns the polyhedron mesh
  51133. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51134. */
  51135. static CreatePolyhedron(name: string, options: {
  51136. type?: number;
  51137. size?: number;
  51138. sizeX?: number;
  51139. sizeY?: number;
  51140. sizeZ?: number;
  51141. custom?: any;
  51142. faceUV?: Vector4[];
  51143. faceColors?: Color4[];
  51144. flat?: boolean;
  51145. updatable?: boolean;
  51146. sideOrientation?: number;
  51147. frontUVs?: Vector4;
  51148. backUVs?: Vector4;
  51149. }, scene: Scene): Mesh;
  51150. /**
  51151. * Creates a decal mesh.
  51152. * 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
  51153. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51154. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51155. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51156. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51157. * @param name defines the name of the mesh
  51158. * @param sourceMesh defines the mesh where the decal must be applied
  51159. * @param options defines the options used to create the mesh
  51160. * @param scene defines the hosting scene
  51161. * @returns the decal mesh
  51162. * @see https://doc.babylonjs.com/how_to/decals
  51163. */
  51164. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51165. position?: Vector3;
  51166. normal?: Vector3;
  51167. size?: Vector3;
  51168. angle?: number;
  51169. }): Mesh;
  51170. }
  51171. }
  51172. declare module "babylonjs/Meshes/meshSimplification" {
  51173. import { Mesh } from "babylonjs/Meshes/mesh";
  51174. /**
  51175. * A simplifier interface for future simplification implementations
  51176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51177. */
  51178. export interface ISimplifier {
  51179. /**
  51180. * Simplification of a given mesh according to the given settings.
  51181. * Since this requires computation, it is assumed that the function runs async.
  51182. * @param settings The settings of the simplification, including quality and distance
  51183. * @param successCallback A callback that will be called after the mesh was simplified.
  51184. * @param errorCallback in case of an error, this callback will be called. optional.
  51185. */
  51186. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51187. }
  51188. /**
  51189. * Expected simplification settings.
  51190. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51191. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51192. */
  51193. export interface ISimplificationSettings {
  51194. /**
  51195. * Gets or sets the expected quality
  51196. */
  51197. quality: number;
  51198. /**
  51199. * Gets or sets the distance when this optimized version should be used
  51200. */
  51201. distance: number;
  51202. /**
  51203. * Gets an already optimized mesh
  51204. */
  51205. optimizeMesh?: boolean;
  51206. }
  51207. /**
  51208. * Class used to specify simplification options
  51209. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51210. */
  51211. export class SimplificationSettings implements ISimplificationSettings {
  51212. /** expected quality */
  51213. quality: number;
  51214. /** distance when this optimized version should be used */
  51215. distance: number;
  51216. /** already optimized mesh */
  51217. optimizeMesh?: boolean | undefined;
  51218. /**
  51219. * Creates a SimplificationSettings
  51220. * @param quality expected quality
  51221. * @param distance distance when this optimized version should be used
  51222. * @param optimizeMesh already optimized mesh
  51223. */
  51224. constructor(
  51225. /** expected quality */
  51226. quality: number,
  51227. /** distance when this optimized version should be used */
  51228. distance: number,
  51229. /** already optimized mesh */
  51230. optimizeMesh?: boolean | undefined);
  51231. }
  51232. /**
  51233. * Interface used to define a simplification task
  51234. */
  51235. export interface ISimplificationTask {
  51236. /**
  51237. * Array of settings
  51238. */
  51239. settings: Array<ISimplificationSettings>;
  51240. /**
  51241. * Simplification type
  51242. */
  51243. simplificationType: SimplificationType;
  51244. /**
  51245. * Mesh to simplify
  51246. */
  51247. mesh: Mesh;
  51248. /**
  51249. * Callback called on success
  51250. */
  51251. successCallback?: () => void;
  51252. /**
  51253. * Defines if parallel processing can be used
  51254. */
  51255. parallelProcessing: boolean;
  51256. }
  51257. /**
  51258. * Queue used to order the simplification tasks
  51259. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51260. */
  51261. export class SimplificationQueue {
  51262. private _simplificationArray;
  51263. /**
  51264. * Gets a boolean indicating that the process is still running
  51265. */
  51266. running: boolean;
  51267. /**
  51268. * Creates a new queue
  51269. */
  51270. constructor();
  51271. /**
  51272. * Adds a new simplification task
  51273. * @param task defines a task to add
  51274. */
  51275. addTask(task: ISimplificationTask): void;
  51276. /**
  51277. * Execute next task
  51278. */
  51279. executeNext(): void;
  51280. /**
  51281. * Execute a simplification task
  51282. * @param task defines the task to run
  51283. */
  51284. runSimplification(task: ISimplificationTask): void;
  51285. private getSimplifier;
  51286. }
  51287. /**
  51288. * The implemented types of simplification
  51289. * At the moment only Quadratic Error Decimation is implemented
  51290. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51291. */
  51292. export enum SimplificationType {
  51293. /** Quadratic error decimation */
  51294. QUADRATIC = 0
  51295. }
  51296. }
  51297. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51298. import { Scene } from "babylonjs/scene";
  51299. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51300. import { ISceneComponent } from "babylonjs/sceneComponent";
  51301. module "babylonjs/scene" {
  51302. interface Scene {
  51303. /** @hidden (Backing field) */
  51304. _simplificationQueue: SimplificationQueue;
  51305. /**
  51306. * Gets or sets the simplification queue attached to the scene
  51307. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51308. */
  51309. simplificationQueue: SimplificationQueue;
  51310. }
  51311. }
  51312. module "babylonjs/Meshes/mesh" {
  51313. interface Mesh {
  51314. /**
  51315. * Simplify the mesh according to the given array of settings.
  51316. * Function will return immediately and will simplify async
  51317. * @param settings a collection of simplification settings
  51318. * @param parallelProcessing should all levels calculate parallel or one after the other
  51319. * @param simplificationType the type of simplification to run
  51320. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51321. * @returns the current mesh
  51322. */
  51323. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51324. }
  51325. }
  51326. /**
  51327. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51328. * created in a scene
  51329. */
  51330. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51331. /**
  51332. * The component name helpfull to identify the component in the list of scene components.
  51333. */
  51334. readonly name: string;
  51335. /**
  51336. * The scene the component belongs to.
  51337. */
  51338. scene: Scene;
  51339. /**
  51340. * Creates a new instance of the component for the given scene
  51341. * @param scene Defines the scene to register the component in
  51342. */
  51343. constructor(scene: Scene);
  51344. /**
  51345. * Registers the component in a given scene
  51346. */
  51347. register(): void;
  51348. /**
  51349. * Rebuilds the elements related to this component in case of
  51350. * context lost for instance.
  51351. */
  51352. rebuild(): void;
  51353. /**
  51354. * Disposes the component and the associated ressources
  51355. */
  51356. dispose(): void;
  51357. private _beforeCameraUpdate;
  51358. }
  51359. }
  51360. declare module "babylonjs/Meshes/Builders/index" {
  51361. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51362. export * from "babylonjs/Meshes/Builders/discBuilder";
  51363. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51364. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51365. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51366. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51367. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51368. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51369. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51370. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51371. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51372. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51373. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51374. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51375. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51376. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51377. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51378. }
  51379. declare module "babylonjs/Meshes/index" {
  51380. export * from "babylonjs/Meshes/abstractMesh";
  51381. export * from "babylonjs/Meshes/buffer";
  51382. export * from "babylonjs/Meshes/Compression/index";
  51383. export * from "babylonjs/Meshes/csg";
  51384. export * from "babylonjs/Meshes/geometry";
  51385. export * from "babylonjs/Meshes/groundMesh";
  51386. export * from "babylonjs/Meshes/trailMesh";
  51387. export * from "babylonjs/Meshes/instancedMesh";
  51388. export * from "babylonjs/Meshes/linesMesh";
  51389. export * from "babylonjs/Meshes/mesh";
  51390. export * from "babylonjs/Meshes/mesh.vertexData";
  51391. export * from "babylonjs/Meshes/meshBuilder";
  51392. export * from "babylonjs/Meshes/meshSimplification";
  51393. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51394. export * from "babylonjs/Meshes/polygonMesh";
  51395. export * from "babylonjs/Meshes/subMesh";
  51396. export * from "babylonjs/Meshes/transformNode";
  51397. export * from "babylonjs/Meshes/Builders/index";
  51398. }
  51399. declare module "babylonjs/Morph/index" {
  51400. export * from "babylonjs/Morph/morphTarget";
  51401. export * from "babylonjs/Morph/morphTargetManager";
  51402. }
  51403. declare module "babylonjs/Offline/database" {
  51404. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51405. /**
  51406. * Class used to enable access to IndexedDB
  51407. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51408. */
  51409. export class Database implements IOfflineProvider {
  51410. private _callbackManifestChecked;
  51411. private _currentSceneUrl;
  51412. private _db;
  51413. private _enableSceneOffline;
  51414. private _enableTexturesOffline;
  51415. private _manifestVersionFound;
  51416. private _mustUpdateRessources;
  51417. private _hasReachedQuota;
  51418. private _isSupported;
  51419. private _idbFactory;
  51420. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51421. private static IsUASupportingBlobStorage;
  51422. /**
  51423. * Gets a boolean indicating if Database storate is enabled (off by default)
  51424. */
  51425. static IDBStorageEnabled: boolean;
  51426. /**
  51427. * Gets a boolean indicating if scene must be saved in the database
  51428. */
  51429. readonly enableSceneOffline: boolean;
  51430. /**
  51431. * Gets a boolean indicating if textures must be saved in the database
  51432. */
  51433. readonly enableTexturesOffline: boolean;
  51434. /**
  51435. * Creates a new Database
  51436. * @param urlToScene defines the url to load the scene
  51437. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51438. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51439. */
  51440. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51441. private static _ParseURL;
  51442. private static _ReturnFullUrlLocation;
  51443. private _checkManifestFile;
  51444. /**
  51445. * Open the database and make it available
  51446. * @param successCallback defines the callback to call on success
  51447. * @param errorCallback defines the callback to call on error
  51448. */
  51449. open(successCallback: () => void, errorCallback: () => void): void;
  51450. /**
  51451. * Loads an image from the database
  51452. * @param url defines the url to load from
  51453. * @param image defines the target DOM image
  51454. */
  51455. loadImage(url: string, image: HTMLImageElement): void;
  51456. private _loadImageFromDBAsync;
  51457. private _saveImageIntoDBAsync;
  51458. private _checkVersionFromDB;
  51459. private _loadVersionFromDBAsync;
  51460. private _saveVersionIntoDBAsync;
  51461. /**
  51462. * Loads a file from database
  51463. * @param url defines the URL to load from
  51464. * @param sceneLoaded defines a callback to call on success
  51465. * @param progressCallBack defines a callback to call when progress changed
  51466. * @param errorCallback defines a callback to call on error
  51467. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51468. */
  51469. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51470. private _loadFileAsync;
  51471. private _saveFileAsync;
  51472. /**
  51473. * Validates if xhr data is correct
  51474. * @param xhr defines the request to validate
  51475. * @param dataType defines the expected data type
  51476. * @returns true if data is correct
  51477. */
  51478. private static _ValidateXHRData;
  51479. }
  51480. }
  51481. declare module "babylonjs/Offline/index" {
  51482. export * from "babylonjs/Offline/database";
  51483. export * from "babylonjs/Offline/IOfflineProvider";
  51484. }
  51485. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51486. /** @hidden */
  51487. export var gpuUpdateParticlesPixelShader: {
  51488. name: string;
  51489. shader: string;
  51490. };
  51491. }
  51492. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51493. /** @hidden */
  51494. export var gpuUpdateParticlesVertexShader: {
  51495. name: string;
  51496. shader: string;
  51497. };
  51498. }
  51499. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51500. /** @hidden */
  51501. export var clipPlaneFragmentDeclaration2: {
  51502. name: string;
  51503. shader: string;
  51504. };
  51505. }
  51506. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51507. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51508. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51509. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51510. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51511. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51512. /** @hidden */
  51513. export var gpuRenderParticlesPixelShader: {
  51514. name: string;
  51515. shader: string;
  51516. };
  51517. }
  51518. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51519. /** @hidden */
  51520. export var clipPlaneVertexDeclaration2: {
  51521. name: string;
  51522. shader: string;
  51523. };
  51524. }
  51525. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51528. /** @hidden */
  51529. export var gpuRenderParticlesVertexShader: {
  51530. name: string;
  51531. shader: string;
  51532. };
  51533. }
  51534. declare module "babylonjs/Particles/gpuParticleSystem" {
  51535. import { Nullable } from "babylonjs/types";
  51536. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51537. import { Observable } from "babylonjs/Misc/observable";
  51538. import { Color4, Color3 } from "babylonjs/Maths/math";
  51539. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51540. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51541. import { Scene, IDisposable } from "babylonjs/scene";
  51542. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51543. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51544. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51545. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51546. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51547. /**
  51548. * This represents a GPU particle system in Babylon
  51549. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51550. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51551. */
  51552. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51553. /**
  51554. * The layer mask we are rendering the particles through.
  51555. */
  51556. layerMask: number;
  51557. private _capacity;
  51558. private _activeCount;
  51559. private _currentActiveCount;
  51560. private _accumulatedCount;
  51561. private _renderEffect;
  51562. private _updateEffect;
  51563. private _buffer0;
  51564. private _buffer1;
  51565. private _spriteBuffer;
  51566. private _updateVAO;
  51567. private _renderVAO;
  51568. private _targetIndex;
  51569. private _sourceBuffer;
  51570. private _targetBuffer;
  51571. private _engine;
  51572. private _currentRenderId;
  51573. private _started;
  51574. private _stopped;
  51575. private _timeDelta;
  51576. private _randomTexture;
  51577. private _randomTexture2;
  51578. private _attributesStrideSize;
  51579. private _updateEffectOptions;
  51580. private _randomTextureSize;
  51581. private _actualFrame;
  51582. private readonly _rawTextureWidth;
  51583. /**
  51584. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51585. */
  51586. static readonly IsSupported: boolean;
  51587. /**
  51588. * An event triggered when the system is disposed.
  51589. */
  51590. onDisposeObservable: Observable<GPUParticleSystem>;
  51591. /**
  51592. * Gets the maximum number of particles active at the same time.
  51593. * @returns The max number of active particles.
  51594. */
  51595. getCapacity(): number;
  51596. /**
  51597. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51598. * to override the particles.
  51599. */
  51600. forceDepthWrite: boolean;
  51601. /**
  51602. * Gets or set the number of active particles
  51603. */
  51604. activeParticleCount: number;
  51605. private _preWarmDone;
  51606. /**
  51607. * Is this system ready to be used/rendered
  51608. * @return true if the system is ready
  51609. */
  51610. isReady(): boolean;
  51611. /**
  51612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51613. * @returns True if it has been started, otherwise false.
  51614. */
  51615. isStarted(): boolean;
  51616. /**
  51617. * Starts the particle system and begins to emit
  51618. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51619. */
  51620. start(delay?: number): void;
  51621. /**
  51622. * Stops the particle system.
  51623. */
  51624. stop(): void;
  51625. /**
  51626. * Remove all active particles
  51627. */
  51628. reset(): void;
  51629. /**
  51630. * Returns the string "GPUParticleSystem"
  51631. * @returns a string containing the class name
  51632. */
  51633. getClassName(): string;
  51634. private _colorGradientsTexture;
  51635. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51636. /**
  51637. * Adds a new color gradient
  51638. * @param gradient defines the gradient to use (between 0 and 1)
  51639. * @param color1 defines the color to affect to the specified gradient
  51640. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51641. * @returns the current particle system
  51642. */
  51643. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51644. /**
  51645. * Remove a specific color gradient
  51646. * @param gradient defines the gradient to remove
  51647. * @returns the current particle system
  51648. */
  51649. removeColorGradient(gradient: number): GPUParticleSystem;
  51650. private _angularSpeedGradientsTexture;
  51651. private _sizeGradientsTexture;
  51652. private _velocityGradientsTexture;
  51653. private _limitVelocityGradientsTexture;
  51654. private _dragGradientsTexture;
  51655. private _addFactorGradient;
  51656. /**
  51657. * Adds a new size gradient
  51658. * @param gradient defines the gradient to use (between 0 and 1)
  51659. * @param factor defines the size factor to affect to the specified gradient
  51660. * @returns the current particle system
  51661. */
  51662. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51663. /**
  51664. * Remove a specific size gradient
  51665. * @param gradient defines the gradient to remove
  51666. * @returns the current particle system
  51667. */
  51668. removeSizeGradient(gradient: number): GPUParticleSystem;
  51669. /**
  51670. * Adds a new angular speed gradient
  51671. * @param gradient defines the gradient to use (between 0 and 1)
  51672. * @param factor defines the angular speed to affect to the specified gradient
  51673. * @returns the current particle system
  51674. */
  51675. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51676. /**
  51677. * Remove a specific angular speed gradient
  51678. * @param gradient defines the gradient to remove
  51679. * @returns the current particle system
  51680. */
  51681. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51682. /**
  51683. * Adds a new velocity gradient
  51684. * @param gradient defines the gradient to use (between 0 and 1)
  51685. * @param factor defines the velocity to affect to the specified gradient
  51686. * @returns the current particle system
  51687. */
  51688. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51689. /**
  51690. * Remove a specific velocity gradient
  51691. * @param gradient defines the gradient to remove
  51692. * @returns the current particle system
  51693. */
  51694. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51695. /**
  51696. * Adds a new limit velocity gradient
  51697. * @param gradient defines the gradient to use (between 0 and 1)
  51698. * @param factor defines the limit velocity value to affect to the specified gradient
  51699. * @returns the current particle system
  51700. */
  51701. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51702. /**
  51703. * Remove a specific limit velocity gradient
  51704. * @param gradient defines the gradient to remove
  51705. * @returns the current particle system
  51706. */
  51707. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51708. /**
  51709. * Adds a new drag gradient
  51710. * @param gradient defines the gradient to use (between 0 and 1)
  51711. * @param factor defines the drag value to affect to the specified gradient
  51712. * @returns the current particle system
  51713. */
  51714. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51715. /**
  51716. * Remove a specific drag gradient
  51717. * @param gradient defines the gradient to remove
  51718. * @returns the current particle system
  51719. */
  51720. removeDragGradient(gradient: number): GPUParticleSystem;
  51721. /**
  51722. * Not supported by GPUParticleSystem
  51723. * @param gradient defines the gradient to use (between 0 and 1)
  51724. * @param factor defines the emit rate value to affect to the specified gradient
  51725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51726. * @returns the current particle system
  51727. */
  51728. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51729. /**
  51730. * Not supported by GPUParticleSystem
  51731. * @param gradient defines the gradient to remove
  51732. * @returns the current particle system
  51733. */
  51734. removeEmitRateGradient(gradient: number): IParticleSystem;
  51735. /**
  51736. * Not supported by GPUParticleSystem
  51737. * @param gradient defines the gradient to use (between 0 and 1)
  51738. * @param factor defines the start size value to affect to the specified gradient
  51739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51740. * @returns the current particle system
  51741. */
  51742. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51743. /**
  51744. * Not supported by GPUParticleSystem
  51745. * @param gradient defines the gradient to remove
  51746. * @returns the current particle system
  51747. */
  51748. removeStartSizeGradient(gradient: number): IParticleSystem;
  51749. /**
  51750. * Not supported by GPUParticleSystem
  51751. * @param gradient defines the gradient to use (between 0 and 1)
  51752. * @param min defines the color remap minimal range
  51753. * @param max defines the color remap maximal range
  51754. * @returns the current particle system
  51755. */
  51756. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51757. /**
  51758. * Not supported by GPUParticleSystem
  51759. * @param gradient defines the gradient to remove
  51760. * @returns the current particle system
  51761. */
  51762. removeColorRemapGradient(): IParticleSystem;
  51763. /**
  51764. * Not supported by GPUParticleSystem
  51765. * @param gradient defines the gradient to use (between 0 and 1)
  51766. * @param min defines the alpha remap minimal range
  51767. * @param max defines the alpha remap maximal range
  51768. * @returns the current particle system
  51769. */
  51770. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51771. /**
  51772. * Not supported by GPUParticleSystem
  51773. * @param gradient defines the gradient to remove
  51774. * @returns the current particle system
  51775. */
  51776. removeAlphaRemapGradient(): IParticleSystem;
  51777. /**
  51778. * Not supported by GPUParticleSystem
  51779. * @param gradient defines the gradient to use (between 0 and 1)
  51780. * @param color defines the color to affect to the specified gradient
  51781. * @returns the current particle system
  51782. */
  51783. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51784. /**
  51785. * Not supported by GPUParticleSystem
  51786. * @param gradient defines the gradient to remove
  51787. * @returns the current particle system
  51788. */
  51789. removeRampGradient(): IParticleSystem;
  51790. /**
  51791. * Not supported by GPUParticleSystem
  51792. * @returns the list of ramp gradients
  51793. */
  51794. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51795. /**
  51796. * Not supported by GPUParticleSystem
  51797. * Gets or sets a boolean indicating that ramp gradients must be used
  51798. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51799. */
  51800. useRampGradients: boolean;
  51801. /**
  51802. * Not supported by GPUParticleSystem
  51803. * @param gradient defines the gradient to use (between 0 and 1)
  51804. * @param factor defines the life time factor to affect to the specified gradient
  51805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51806. * @returns the current particle system
  51807. */
  51808. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51809. /**
  51810. * Not supported by GPUParticleSystem
  51811. * @param gradient defines the gradient to remove
  51812. * @returns the current particle system
  51813. */
  51814. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51815. /**
  51816. * Instantiates a GPU particle system.
  51817. * 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.
  51818. * @param name The name of the particle system
  51819. * @param options The options used to create the system
  51820. * @param scene The scene the particle system belongs to
  51821. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51822. */
  51823. constructor(name: string, options: Partial<{
  51824. capacity: number;
  51825. randomTextureSize: number;
  51826. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51827. protected _reset(): void;
  51828. private _createUpdateVAO;
  51829. private _createRenderVAO;
  51830. private _initialize;
  51831. /** @hidden */
  51832. _recreateUpdateEffect(): void;
  51833. /** @hidden */
  51834. _recreateRenderEffect(): void;
  51835. /**
  51836. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51837. * @param preWarm defines if we are in the pre-warmimg phase
  51838. */
  51839. animate(preWarm?: boolean): void;
  51840. private _createFactorGradientTexture;
  51841. private _createSizeGradientTexture;
  51842. private _createAngularSpeedGradientTexture;
  51843. private _createVelocityGradientTexture;
  51844. private _createLimitVelocityGradientTexture;
  51845. private _createDragGradientTexture;
  51846. private _createColorGradientTexture;
  51847. /**
  51848. * Renders the particle system in its current state
  51849. * @param preWarm defines if the system should only update the particles but not render them
  51850. * @returns the current number of particles
  51851. */
  51852. render(preWarm?: boolean): number;
  51853. /**
  51854. * Rebuilds the particle system
  51855. */
  51856. rebuild(): void;
  51857. private _releaseBuffers;
  51858. private _releaseVAOs;
  51859. /**
  51860. * Disposes the particle system and free the associated resources
  51861. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51862. */
  51863. dispose(disposeTexture?: boolean): void;
  51864. /**
  51865. * Clones the particle system.
  51866. * @param name The name of the cloned object
  51867. * @param newEmitter The new emitter to use
  51868. * @returns the cloned particle system
  51869. */
  51870. clone(name: string, newEmitter: any): GPUParticleSystem;
  51871. /**
  51872. * Serializes the particle system to a JSON object.
  51873. * @returns the JSON object
  51874. */
  51875. serialize(): any;
  51876. /**
  51877. * Parses a JSON object to create a GPU particle system.
  51878. * @param parsedParticleSystem The JSON object to parse
  51879. * @param scene The scene to create the particle system in
  51880. * @param rootUrl The root url to use to load external dependencies like texture
  51881. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51882. * @returns the parsed GPU particle system
  51883. */
  51884. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51885. }
  51886. }
  51887. declare module "babylonjs/Particles/particleSystemSet" {
  51888. import { Nullable } from "babylonjs/types";
  51889. import { Color3 } from "babylonjs/Maths/math";
  51890. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51892. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51893. import { Scene, IDisposable } from "babylonjs/scene";
  51894. /**
  51895. * Represents a set of particle systems working together to create a specific effect
  51896. */
  51897. export class ParticleSystemSet implements IDisposable {
  51898. private _emitterCreationOptions;
  51899. private _emitterNode;
  51900. /**
  51901. * Gets the particle system list
  51902. */
  51903. systems: IParticleSystem[];
  51904. /**
  51905. * Gets the emitter node used with this set
  51906. */
  51907. readonly emitterNode: Nullable<TransformNode>;
  51908. /**
  51909. * Creates a new emitter mesh as a sphere
  51910. * @param options defines the options used to create the sphere
  51911. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51912. * @param scene defines the hosting scene
  51913. */
  51914. setEmitterAsSphere(options: {
  51915. diameter: number;
  51916. segments: number;
  51917. color: Color3;
  51918. }, renderingGroupId: number, scene: Scene): void;
  51919. /**
  51920. * Starts all particle systems of the set
  51921. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51922. */
  51923. start(emitter?: AbstractMesh): void;
  51924. /**
  51925. * Release all associated resources
  51926. */
  51927. dispose(): void;
  51928. /**
  51929. * Serialize the set into a JSON compatible object
  51930. * @returns a JSON compatible representation of the set
  51931. */
  51932. serialize(): any;
  51933. /**
  51934. * Parse a new ParticleSystemSet from a serialized source
  51935. * @param data defines a JSON compatible representation of the set
  51936. * @param scene defines the hosting scene
  51937. * @param gpu defines if we want GPU particles or CPU particles
  51938. * @returns a new ParticleSystemSet
  51939. */
  51940. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51941. }
  51942. }
  51943. declare module "babylonjs/Particles/particleHelper" {
  51944. import { Nullable } from "babylonjs/types";
  51945. import { Scene } from "babylonjs/scene";
  51946. import { Vector3 } from "babylonjs/Maths/math";
  51947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51948. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51949. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51950. /**
  51951. * This class is made for on one-liner static method to help creating particle system set.
  51952. */
  51953. export class ParticleHelper {
  51954. /**
  51955. * Gets or sets base Assets URL
  51956. */
  51957. static BaseAssetsUrl: string;
  51958. /**
  51959. * Create a default particle system that you can tweak
  51960. * @param emitter defines the emitter to use
  51961. * @param capacity defines the system capacity (default is 500 particles)
  51962. * @param scene defines the hosting scene
  51963. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51964. * @returns the new Particle system
  51965. */
  51966. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51967. /**
  51968. * This is the main static method (one-liner) of this helper to create different particle systems
  51969. * @param type This string represents the type to the particle system to create
  51970. * @param scene The scene where the particle system should live
  51971. * @param gpu If the system will use gpu
  51972. * @returns the ParticleSystemSet created
  51973. */
  51974. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51975. /**
  51976. * Static function used to export a particle system to a ParticleSystemSet variable.
  51977. * Please note that the emitter shape is not exported
  51978. * @param systems defines the particle systems to export
  51979. * @returns the created particle system set
  51980. */
  51981. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51982. }
  51983. }
  51984. declare module "babylonjs/Particles/particleSystemComponent" {
  51985. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51986. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51987. import "babylonjs/Shaders/particles.vertex";
  51988. module "babylonjs/Engines/engine" {
  51989. interface Engine {
  51990. /**
  51991. * Create an effect to use with particle systems.
  51992. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51993. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51994. * @param uniformsNames defines a list of attribute names
  51995. * @param samplers defines an array of string used to represent textures
  51996. * @param defines defines the string containing the defines to use to compile the shaders
  51997. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51998. * @param onCompiled defines a function to call when the effect creation is successful
  51999. * @param onError defines a function to call when the effect creation has failed
  52000. * @returns the new Effect
  52001. */
  52002. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52003. }
  52004. }
  52005. module "babylonjs/Meshes/mesh" {
  52006. interface Mesh {
  52007. /**
  52008. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52009. * @returns an array of IParticleSystem
  52010. */
  52011. getEmittedParticleSystems(): IParticleSystem[];
  52012. /**
  52013. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52014. * @returns an array of IParticleSystem
  52015. */
  52016. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52017. }
  52018. }
  52019. /**
  52020. * @hidden
  52021. */
  52022. export var _IDoNeedToBeInTheBuild: number;
  52023. }
  52024. declare module "babylonjs/Particles/index" {
  52025. export * from "babylonjs/Particles/baseParticleSystem";
  52026. export * from "babylonjs/Particles/EmitterTypes/index";
  52027. export * from "babylonjs/Particles/gpuParticleSystem";
  52028. export * from "babylonjs/Particles/IParticleSystem";
  52029. export * from "babylonjs/Particles/particle";
  52030. export * from "babylonjs/Particles/particleHelper";
  52031. export * from "babylonjs/Particles/particleSystem";
  52032. export * from "babylonjs/Particles/particleSystemComponent";
  52033. export * from "babylonjs/Particles/particleSystemSet";
  52034. export * from "babylonjs/Particles/solidParticle";
  52035. export * from "babylonjs/Particles/solidParticleSystem";
  52036. export * from "babylonjs/Particles/subEmitter";
  52037. }
  52038. declare module "babylonjs/Physics/physicsEngineComponent" {
  52039. import { Nullable } from "babylonjs/types";
  52040. import { Observable, Observer } from "babylonjs/Misc/observable";
  52041. import { Vector3 } from "babylonjs/Maths/math";
  52042. import { Mesh } from "babylonjs/Meshes/mesh";
  52043. import { ISceneComponent } from "babylonjs/sceneComponent";
  52044. import { Scene } from "babylonjs/scene";
  52045. import { Node } from "babylonjs/node";
  52046. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52047. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52048. module "babylonjs/scene" {
  52049. interface Scene {
  52050. /** @hidden (Backing field) */
  52051. _physicsEngine: Nullable<IPhysicsEngine>;
  52052. /**
  52053. * Gets the current physics engine
  52054. * @returns a IPhysicsEngine or null if none attached
  52055. */
  52056. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52057. /**
  52058. * Enables physics to the current scene
  52059. * @param gravity defines the scene's gravity for the physics engine
  52060. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52061. * @return a boolean indicating if the physics engine was initialized
  52062. */
  52063. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52064. /**
  52065. * Disables and disposes the physics engine associated with the scene
  52066. */
  52067. disablePhysicsEngine(): void;
  52068. /**
  52069. * Gets a boolean indicating if there is an active physics engine
  52070. * @returns a boolean indicating if there is an active physics engine
  52071. */
  52072. isPhysicsEnabled(): boolean;
  52073. /**
  52074. * Deletes a physics compound impostor
  52075. * @param compound defines the compound to delete
  52076. */
  52077. deleteCompoundImpostor(compound: any): void;
  52078. /**
  52079. * An event triggered when physic simulation is about to be run
  52080. */
  52081. onBeforePhysicsObservable: Observable<Scene>;
  52082. /**
  52083. * An event triggered when physic simulation has been done
  52084. */
  52085. onAfterPhysicsObservable: Observable<Scene>;
  52086. }
  52087. }
  52088. module "babylonjs/Meshes/abstractMesh" {
  52089. interface AbstractMesh {
  52090. /** @hidden */
  52091. _physicsImpostor: Nullable<PhysicsImpostor>;
  52092. /**
  52093. * Gets or sets impostor used for physic simulation
  52094. * @see http://doc.babylonjs.com/features/physics_engine
  52095. */
  52096. physicsImpostor: Nullable<PhysicsImpostor>;
  52097. /**
  52098. * Gets the current physics impostor
  52099. * @see http://doc.babylonjs.com/features/physics_engine
  52100. * @returns a physics impostor or null
  52101. */
  52102. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52103. /** Apply a physic impulse to the mesh
  52104. * @param force defines the force to apply
  52105. * @param contactPoint defines where to apply the force
  52106. * @returns the current mesh
  52107. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52108. */
  52109. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52110. /**
  52111. * Creates a physic joint between two meshes
  52112. * @param otherMesh defines the other mesh to use
  52113. * @param pivot1 defines the pivot to use on this mesh
  52114. * @param pivot2 defines the pivot to use on the other mesh
  52115. * @param options defines additional options (can be plugin dependent)
  52116. * @returns the current mesh
  52117. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52118. */
  52119. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52120. /** @hidden */
  52121. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52122. }
  52123. }
  52124. /**
  52125. * Defines the physics engine scene component responsible to manage a physics engine
  52126. */
  52127. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52128. /**
  52129. * The component name helpful to identify the component in the list of scene components.
  52130. */
  52131. readonly name: string;
  52132. /**
  52133. * The scene the component belongs to.
  52134. */
  52135. scene: Scene;
  52136. /**
  52137. * Creates a new instance of the component for the given scene
  52138. * @param scene Defines the scene to register the component in
  52139. */
  52140. constructor(scene: Scene);
  52141. /**
  52142. * Registers the component in a given scene
  52143. */
  52144. register(): void;
  52145. /**
  52146. * Rebuilds the elements related to this component in case of
  52147. * context lost for instance.
  52148. */
  52149. rebuild(): void;
  52150. /**
  52151. * Disposes the component and the associated ressources
  52152. */
  52153. dispose(): void;
  52154. }
  52155. }
  52156. declare module "babylonjs/Physics/physicsHelper" {
  52157. import { Nullable } from "babylonjs/types";
  52158. import { Vector3 } from "babylonjs/Maths/math";
  52159. import { Mesh } from "babylonjs/Meshes/mesh";
  52160. import { Ray } from "babylonjs/Culling/ray";
  52161. import { Scene } from "babylonjs/scene";
  52162. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52163. /**
  52164. * A helper for physics simulations
  52165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52166. */
  52167. export class PhysicsHelper {
  52168. private _scene;
  52169. private _physicsEngine;
  52170. /**
  52171. * Initializes the Physics helper
  52172. * @param scene Babylon.js scene
  52173. */
  52174. constructor(scene: Scene);
  52175. /**
  52176. * Applies a radial explosion impulse
  52177. * @param origin the origin of the explosion
  52178. * @param radius the explosion radius
  52179. * @param strength the explosion strength
  52180. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52181. * @returns A physics radial explosion event, or null
  52182. */
  52183. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52184. /**
  52185. * Applies a radial explosion force
  52186. * @param origin the origin of the explosion
  52187. * @param radius the explosion radius
  52188. * @param strength the explosion strength
  52189. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52190. * @returns A physics radial explosion event, or null
  52191. */
  52192. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52193. /**
  52194. * Creates a gravitational field
  52195. * @param origin the origin of the explosion
  52196. * @param radius the explosion radius
  52197. * @param strength the explosion strength
  52198. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52199. * @returns A physics gravitational field event, or null
  52200. */
  52201. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52202. /**
  52203. * Creates a physics updraft event
  52204. * @param origin the origin of the updraft
  52205. * @param radius the radius of the updraft
  52206. * @param strength the strength of the updraft
  52207. * @param height the height of the updraft
  52208. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52209. * @returns A physics updraft event, or null
  52210. */
  52211. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52212. /**
  52213. * Creates a physics vortex event
  52214. * @param origin the of the vortex
  52215. * @param radius the radius of the vortex
  52216. * @param strength the strength of the vortex
  52217. * @param height the height of the vortex
  52218. * @returns a Physics vortex event, or null
  52219. * A physics vortex event or null
  52220. */
  52221. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52222. }
  52223. /**
  52224. * Represents a physics radial explosion event
  52225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52226. */
  52227. export class PhysicsRadialExplosionEvent {
  52228. private _scene;
  52229. private _sphere;
  52230. private _sphereOptions;
  52231. private _rays;
  52232. private _dataFetched;
  52233. /**
  52234. * Initializes a radial explosioin event
  52235. * @param scene BabylonJS scene
  52236. */
  52237. constructor(scene: Scene);
  52238. /**
  52239. * Returns the data related to the radial explosion event (sphere & rays).
  52240. * @returns The radial explosion event data
  52241. */
  52242. getData(): PhysicsRadialExplosionEventData;
  52243. /**
  52244. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52245. * @param impostor A physics imposter
  52246. * @param origin the origin of the explosion
  52247. * @param radius the explosion radius
  52248. * @param strength the explosion strength
  52249. * @param falloff possible options: Constant & Linear
  52250. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52251. */
  52252. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52253. /**
  52254. * Disposes the sphere.
  52255. * @param force Specifies if the sphere should be disposed by force
  52256. */
  52257. dispose(force?: boolean): void;
  52258. /*** Helpers ***/
  52259. private _prepareSphere;
  52260. private _intersectsWithSphere;
  52261. }
  52262. /**
  52263. * Represents a gravitational field event
  52264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52265. */
  52266. export class PhysicsGravitationalFieldEvent {
  52267. private _physicsHelper;
  52268. private _scene;
  52269. private _origin;
  52270. private _radius;
  52271. private _strength;
  52272. private _falloff;
  52273. private _tickCallback;
  52274. private _sphere;
  52275. private _dataFetched;
  52276. /**
  52277. * Initializes the physics gravitational field event
  52278. * @param physicsHelper A physics helper
  52279. * @param scene BabylonJS scene
  52280. * @param origin The origin position of the gravitational field event
  52281. * @param radius The radius of the gravitational field event
  52282. * @param strength The strength of the gravitational field event
  52283. * @param falloff The falloff for the gravitational field event
  52284. */
  52285. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52286. /**
  52287. * Returns the data related to the gravitational field event (sphere).
  52288. * @returns A gravitational field event
  52289. */
  52290. getData(): PhysicsGravitationalFieldEventData;
  52291. /**
  52292. * Enables the gravitational field.
  52293. */
  52294. enable(): void;
  52295. /**
  52296. * Disables the gravitational field.
  52297. */
  52298. disable(): void;
  52299. /**
  52300. * Disposes the sphere.
  52301. * @param force The force to dispose from the gravitational field event
  52302. */
  52303. dispose(force?: boolean): void;
  52304. private _tick;
  52305. }
  52306. /**
  52307. * Represents a physics updraft event
  52308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52309. */
  52310. export class PhysicsUpdraftEvent {
  52311. private _scene;
  52312. private _origin;
  52313. private _radius;
  52314. private _strength;
  52315. private _height;
  52316. private _updraftMode;
  52317. private _physicsEngine;
  52318. private _originTop;
  52319. private _originDirection;
  52320. private _tickCallback;
  52321. private _cylinder;
  52322. private _cylinderPosition;
  52323. private _dataFetched;
  52324. /**
  52325. * Initializes the physics updraft event
  52326. * @param _scene BabylonJS scene
  52327. * @param _origin The origin position of the updraft
  52328. * @param _radius The radius of the updraft
  52329. * @param _strength The strength of the updraft
  52330. * @param _height The height of the updraft
  52331. * @param _updraftMode The mode of the updraft
  52332. */
  52333. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52334. /**
  52335. * Returns the data related to the updraft event (cylinder).
  52336. * @returns A physics updraft event
  52337. */
  52338. getData(): PhysicsUpdraftEventData;
  52339. /**
  52340. * Enables the updraft.
  52341. */
  52342. enable(): void;
  52343. /**
  52344. * Disables the cortex.
  52345. */
  52346. disable(): void;
  52347. /**
  52348. * Disposes the sphere.
  52349. * @param force Specifies if the updraft should be disposed by force
  52350. */
  52351. dispose(force?: boolean): void;
  52352. private getImpostorForceAndContactPoint;
  52353. private _tick;
  52354. /*** Helpers ***/
  52355. private _prepareCylinder;
  52356. private _intersectsWithCylinder;
  52357. }
  52358. /**
  52359. * Represents a physics vortex event
  52360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52361. */
  52362. export class PhysicsVortexEvent {
  52363. private _scene;
  52364. private _origin;
  52365. private _radius;
  52366. private _strength;
  52367. private _height;
  52368. private _physicsEngine;
  52369. private _originTop;
  52370. private _centripetalForceThreshold;
  52371. private _updraftMultiplier;
  52372. private _tickCallback;
  52373. private _cylinder;
  52374. private _cylinderPosition;
  52375. private _dataFetched;
  52376. /**
  52377. * Initializes the physics vortex event
  52378. * @param _scene The BabylonJS scene
  52379. * @param _origin The origin position of the vortex
  52380. * @param _radius The radius of the vortex
  52381. * @param _strength The strength of the vortex
  52382. * @param _height The height of the vortex
  52383. */
  52384. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52385. /**
  52386. * Returns the data related to the vortex event (cylinder).
  52387. * @returns The physics vortex event data
  52388. */
  52389. getData(): PhysicsVortexEventData;
  52390. /**
  52391. * Enables the vortex.
  52392. */
  52393. enable(): void;
  52394. /**
  52395. * Disables the cortex.
  52396. */
  52397. disable(): void;
  52398. /**
  52399. * Disposes the sphere.
  52400. * @param force
  52401. */
  52402. dispose(force?: boolean): void;
  52403. private getImpostorForceAndContactPoint;
  52404. private _tick;
  52405. /*** Helpers ***/
  52406. private _prepareCylinder;
  52407. private _intersectsWithCylinder;
  52408. }
  52409. /**
  52410. * The strenght of the force in correspondence to the distance of the affected object
  52411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52412. */
  52413. export enum PhysicsRadialImpulseFalloff {
  52414. /** Defines that impulse is constant in strength across it's whole radius */
  52415. Constant = 0,
  52416. /** DEfines that impulse gets weaker if it's further from the origin */
  52417. Linear = 1
  52418. }
  52419. /**
  52420. * The strength of the force in correspondence to the distance of the affected object
  52421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52422. */
  52423. export enum PhysicsUpdraftMode {
  52424. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52425. Center = 0,
  52426. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52427. Perpendicular = 1
  52428. }
  52429. /**
  52430. * Interface for a physics force and contact point
  52431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52432. */
  52433. export interface PhysicsForceAndContactPoint {
  52434. /**
  52435. * The force applied at the contact point
  52436. */
  52437. force: Vector3;
  52438. /**
  52439. * The contact point
  52440. */
  52441. contactPoint: Vector3;
  52442. }
  52443. /**
  52444. * Interface for radial explosion event data
  52445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52446. */
  52447. export interface PhysicsRadialExplosionEventData {
  52448. /**
  52449. * A sphere used for the radial explosion event
  52450. */
  52451. sphere: Mesh;
  52452. /**
  52453. * An array of rays for the radial explosion event
  52454. */
  52455. rays: Array<Ray>;
  52456. }
  52457. /**
  52458. * Interface for gravitational field event data
  52459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52460. */
  52461. export interface PhysicsGravitationalFieldEventData {
  52462. /**
  52463. * A sphere mesh used for the gravitational field event
  52464. */
  52465. sphere: Mesh;
  52466. }
  52467. /**
  52468. * Interface for updraft event data
  52469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52470. */
  52471. export interface PhysicsUpdraftEventData {
  52472. /**
  52473. * A cylinder used for the updraft event
  52474. */
  52475. cylinder: Mesh;
  52476. }
  52477. /**
  52478. * Interface for vortex event data
  52479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52480. */
  52481. export interface PhysicsVortexEventData {
  52482. /**
  52483. * A cylinder used for the vortex event
  52484. */
  52485. cylinder: Mesh;
  52486. }
  52487. }
  52488. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52489. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52490. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52491. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52492. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52493. import { Nullable } from "babylonjs/types";
  52494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52495. /**
  52496. * AmmoJS Physics plugin
  52497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52498. * @see https://github.com/kripken/ammo.js/
  52499. */
  52500. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52501. private _useDeltaForWorldStep;
  52502. /**
  52503. * Reference to the Ammo library
  52504. */
  52505. bjsAMMO: any;
  52506. /**
  52507. * Created ammoJS world which physics bodies are added to
  52508. */
  52509. world: any;
  52510. /**
  52511. * Name of the plugin
  52512. */
  52513. name: string;
  52514. private _timeStep;
  52515. private _fixedTimeStep;
  52516. private _maxSteps;
  52517. private _tmpQuaternion;
  52518. private _tmpAmmoTransform;
  52519. private _tmpAmmoQuaternion;
  52520. private _tmpAmmoConcreteContactResultCallback;
  52521. private _collisionConfiguration;
  52522. private _dispatcher;
  52523. private _overlappingPairCache;
  52524. private _solver;
  52525. private _tmpAmmoVectorA;
  52526. private _tmpAmmoVectorB;
  52527. private _tmpAmmoVectorC;
  52528. private _tmpContactCallbackResult;
  52529. private static readonly DISABLE_COLLISION_FLAG;
  52530. private static readonly KINEMATIC_FLAG;
  52531. private static readonly DISABLE_DEACTIVATION_FLAG;
  52532. /**
  52533. * Initializes the ammoJS plugin
  52534. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52535. * @param ammoInjection can be used to inject your own ammo reference
  52536. */
  52537. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52538. /**
  52539. * Sets the gravity of the physics world (m/(s^2))
  52540. * @param gravity Gravity to set
  52541. */
  52542. setGravity(gravity: Vector3): void;
  52543. /**
  52544. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52545. * @param timeStep timestep to use in seconds
  52546. */
  52547. setTimeStep(timeStep: number): void;
  52548. /**
  52549. * 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)
  52550. * @param fixedTimeStep fixedTimeStep to use in seconds
  52551. */
  52552. setFixedTimeStep(fixedTimeStep: number): void;
  52553. /**
  52554. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52555. * @param maxSteps the maximum number of steps by the physics engine per frame
  52556. */
  52557. setMaxSteps(maxSteps: number): void;
  52558. /**
  52559. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52560. * @returns the current timestep in seconds
  52561. */
  52562. getTimeStep(): number;
  52563. private _isImpostorInContact;
  52564. private _isImpostorPairInContact;
  52565. private _stepSimulation;
  52566. /**
  52567. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52568. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52569. * After the step the babylon meshes are set to the position of the physics imposters
  52570. * @param delta amount of time to step forward
  52571. * @param impostors array of imposters to update before/after the step
  52572. */
  52573. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52574. private _tmpVector;
  52575. private _tmpMatrix;
  52576. /**
  52577. * Applies an implulse on the imposter
  52578. * @param impostor imposter to apply impulse
  52579. * @param force amount of force to be applied to the imposter
  52580. * @param contactPoint the location to apply the impulse on the imposter
  52581. */
  52582. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52583. /**
  52584. * Applies a force on the imposter
  52585. * @param impostor imposter to apply force
  52586. * @param force amount of force to be applied to the imposter
  52587. * @param contactPoint the location to apply the force on the imposter
  52588. */
  52589. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52590. /**
  52591. * Creates a physics body using the plugin
  52592. * @param impostor the imposter to create the physics body on
  52593. */
  52594. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52595. /**
  52596. * Removes the physics body from the imposter and disposes of the body's memory
  52597. * @param impostor imposter to remove the physics body from
  52598. */
  52599. removePhysicsBody(impostor: PhysicsImpostor): void;
  52600. /**
  52601. * Generates a joint
  52602. * @param impostorJoint the imposter joint to create the joint with
  52603. */
  52604. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52605. /**
  52606. * Removes a joint
  52607. * @param impostorJoint the imposter joint to remove the joint from
  52608. */
  52609. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52610. private _addMeshVerts;
  52611. private _createShape;
  52612. /**
  52613. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52614. * @param impostor imposter containing the physics body and babylon object
  52615. */
  52616. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52617. /**
  52618. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52619. * @param impostor imposter containing the physics body and babylon object
  52620. * @param newPosition new position
  52621. * @param newRotation new rotation
  52622. */
  52623. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52624. /**
  52625. * If this plugin is supported
  52626. * @returns true if its supported
  52627. */
  52628. isSupported(): boolean;
  52629. /**
  52630. * Sets the linear velocity of the physics body
  52631. * @param impostor imposter to set the velocity on
  52632. * @param velocity velocity to set
  52633. */
  52634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52635. /**
  52636. * Sets the angular velocity of the physics body
  52637. * @param impostor imposter to set the velocity on
  52638. * @param velocity velocity to set
  52639. */
  52640. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52641. /**
  52642. * gets the linear velocity
  52643. * @param impostor imposter to get linear velocity from
  52644. * @returns linear velocity
  52645. */
  52646. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52647. /**
  52648. * gets the angular velocity
  52649. * @param impostor imposter to get angular velocity from
  52650. * @returns angular velocity
  52651. */
  52652. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52653. /**
  52654. * Sets the mass of physics body
  52655. * @param impostor imposter to set the mass on
  52656. * @param mass mass to set
  52657. */
  52658. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52659. /**
  52660. * Gets the mass of the physics body
  52661. * @param impostor imposter to get the mass from
  52662. * @returns mass
  52663. */
  52664. getBodyMass(impostor: PhysicsImpostor): number;
  52665. /**
  52666. * Gets friction of the impostor
  52667. * @param impostor impostor to get friction from
  52668. * @returns friction value
  52669. */
  52670. getBodyFriction(impostor: PhysicsImpostor): number;
  52671. /**
  52672. * Sets friction of the impostor
  52673. * @param impostor impostor to set friction on
  52674. * @param friction friction value
  52675. */
  52676. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52677. /**
  52678. * Gets restitution of the impostor
  52679. * @param impostor impostor to get restitution from
  52680. * @returns restitution value
  52681. */
  52682. getBodyRestitution(impostor: PhysicsImpostor): number;
  52683. /**
  52684. * Sets resitution of the impostor
  52685. * @param impostor impostor to set resitution on
  52686. * @param restitution resitution value
  52687. */
  52688. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52689. /**
  52690. * Sleeps the physics body and stops it from being active
  52691. * @param impostor impostor to sleep
  52692. */
  52693. sleepBody(impostor: PhysicsImpostor): void;
  52694. /**
  52695. * Activates the physics body
  52696. * @param impostor impostor to activate
  52697. */
  52698. wakeUpBody(impostor: PhysicsImpostor): void;
  52699. /**
  52700. * Updates the distance parameters of the joint
  52701. * @param joint joint to update
  52702. * @param maxDistance maximum distance of the joint
  52703. * @param minDistance minimum distance of the joint
  52704. */
  52705. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52706. /**
  52707. * Sets a motor on the joint
  52708. * @param joint joint to set motor on
  52709. * @param speed speed of the motor
  52710. * @param maxForce maximum force of the motor
  52711. * @param motorIndex index of the motor
  52712. */
  52713. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52714. /**
  52715. * Sets the motors limit
  52716. * @param joint joint to set limit on
  52717. * @param upperLimit upper limit
  52718. * @param lowerLimit lower limit
  52719. */
  52720. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52721. /**
  52722. * Syncs the position and rotation of a mesh with the impostor
  52723. * @param mesh mesh to sync
  52724. * @param impostor impostor to update the mesh with
  52725. */
  52726. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52727. /**
  52728. * Gets the radius of the impostor
  52729. * @param impostor impostor to get radius from
  52730. * @returns the radius
  52731. */
  52732. getRadius(impostor: PhysicsImpostor): number;
  52733. /**
  52734. * Gets the box size of the impostor
  52735. * @param impostor impostor to get box size from
  52736. * @param result the resulting box size
  52737. */
  52738. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52739. /**
  52740. * Disposes of the impostor
  52741. */
  52742. dispose(): void;
  52743. }
  52744. }
  52745. declare module "babylonjs/Physics/Plugins/index" {
  52746. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52747. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52748. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52749. }
  52750. declare module "babylonjs/Physics/index" {
  52751. export * from "babylonjs/Physics/IPhysicsEngine";
  52752. export * from "babylonjs/Physics/physicsEngine";
  52753. export * from "babylonjs/Physics/physicsEngineComponent";
  52754. export * from "babylonjs/Physics/physicsHelper";
  52755. export * from "babylonjs/Physics/physicsImpostor";
  52756. export * from "babylonjs/Physics/physicsJoint";
  52757. export * from "babylonjs/Physics/Plugins/index";
  52758. }
  52759. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52760. /** @hidden */
  52761. export var blackAndWhitePixelShader: {
  52762. name: string;
  52763. shader: string;
  52764. };
  52765. }
  52766. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52768. import { Camera } from "babylonjs/Cameras/camera";
  52769. import { Engine } from "babylonjs/Engines/engine";
  52770. import "babylonjs/Shaders/blackAndWhite.fragment";
  52771. /**
  52772. * Post process used to render in black and white
  52773. */
  52774. export class BlackAndWhitePostProcess extends PostProcess {
  52775. /**
  52776. * Linear about to convert he result to black and white (default: 1)
  52777. */
  52778. degree: number;
  52779. /**
  52780. * Creates a black and white post process
  52781. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52782. * @param name The name of the effect.
  52783. * @param options The required width/height ratio to downsize to before computing the render pass.
  52784. * @param camera The camera to apply the render pass to.
  52785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52786. * @param engine The engine which the post process will be applied. (default: current engine)
  52787. * @param reusable If the post process can be reused on the same frame. (default: false)
  52788. */
  52789. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52790. }
  52791. }
  52792. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52793. import { Nullable } from "babylonjs/types";
  52794. import { Camera } from "babylonjs/Cameras/camera";
  52795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52796. import { Engine } from "babylonjs/Engines/engine";
  52797. /**
  52798. * This represents a set of one or more post processes in Babylon.
  52799. * A post process can be used to apply a shader to a texture after it is rendered.
  52800. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52801. */
  52802. export class PostProcessRenderEffect {
  52803. private _postProcesses;
  52804. private _getPostProcesses;
  52805. private _singleInstance;
  52806. private _cameras;
  52807. private _indicesForCamera;
  52808. /**
  52809. * Name of the effect
  52810. * @hidden
  52811. */
  52812. _name: string;
  52813. /**
  52814. * Instantiates a post process render effect.
  52815. * A post process can be used to apply a shader to a texture after it is rendered.
  52816. * @param engine The engine the effect is tied to
  52817. * @param name The name of the effect
  52818. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52819. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52820. */
  52821. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52822. /**
  52823. * Checks if all the post processes in the effect are supported.
  52824. */
  52825. readonly isSupported: boolean;
  52826. /**
  52827. * Updates the current state of the effect
  52828. * @hidden
  52829. */
  52830. _update(): void;
  52831. /**
  52832. * Attaches the effect on cameras
  52833. * @param cameras The camera to attach to.
  52834. * @hidden
  52835. */
  52836. _attachCameras(cameras: Camera): void;
  52837. /**
  52838. * Attaches the effect on cameras
  52839. * @param cameras The camera to attach to.
  52840. * @hidden
  52841. */
  52842. _attachCameras(cameras: Camera[]): void;
  52843. /**
  52844. * Detatches the effect on cameras
  52845. * @param cameras The camera to detatch from.
  52846. * @hidden
  52847. */
  52848. _detachCameras(cameras: Camera): void;
  52849. /**
  52850. * Detatches the effect on cameras
  52851. * @param cameras The camera to detatch from.
  52852. * @hidden
  52853. */
  52854. _detachCameras(cameras: Camera[]): void;
  52855. /**
  52856. * Enables the effect on given cameras
  52857. * @param cameras The camera to enable.
  52858. * @hidden
  52859. */
  52860. _enable(cameras: Camera): void;
  52861. /**
  52862. * Enables the effect on given cameras
  52863. * @param cameras The camera to enable.
  52864. * @hidden
  52865. */
  52866. _enable(cameras: Nullable<Camera[]>): void;
  52867. /**
  52868. * Disables the effect on the given cameras
  52869. * @param cameras The camera to disable.
  52870. * @hidden
  52871. */
  52872. _disable(cameras: Camera): void;
  52873. /**
  52874. * Disables the effect on the given cameras
  52875. * @param cameras The camera to disable.
  52876. * @hidden
  52877. */
  52878. _disable(cameras: Nullable<Camera[]>): void;
  52879. /**
  52880. * Gets a list of the post processes contained in the effect.
  52881. * @param camera The camera to get the post processes on.
  52882. * @returns The list of the post processes in the effect.
  52883. */
  52884. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52885. }
  52886. }
  52887. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52889. /** @hidden */
  52890. export var extractHighlightsPixelShader: {
  52891. name: string;
  52892. shader: string;
  52893. };
  52894. }
  52895. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52896. import { Nullable } from "babylonjs/types";
  52897. import { Camera } from "babylonjs/Cameras/camera";
  52898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52899. import { Engine } from "babylonjs/Engines/engine";
  52900. import "babylonjs/Shaders/extractHighlights.fragment";
  52901. /**
  52902. * 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.
  52903. */
  52904. export class ExtractHighlightsPostProcess extends PostProcess {
  52905. /**
  52906. * The luminance threshold, pixels below this value will be set to black.
  52907. */
  52908. threshold: number;
  52909. /** @hidden */
  52910. _exposure: number;
  52911. /**
  52912. * Post process which has the input texture to be used when performing highlight extraction
  52913. * @hidden
  52914. */
  52915. _inputPostProcess: Nullable<PostProcess>;
  52916. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52917. }
  52918. }
  52919. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52920. /** @hidden */
  52921. export var bloomMergePixelShader: {
  52922. name: string;
  52923. shader: string;
  52924. };
  52925. }
  52926. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52928. import { Nullable } from "babylonjs/types";
  52929. import { Engine } from "babylonjs/Engines/engine";
  52930. import { Camera } from "babylonjs/Cameras/camera";
  52931. import "babylonjs/Shaders/bloomMerge.fragment";
  52932. /**
  52933. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52934. */
  52935. export class BloomMergePostProcess extends PostProcess {
  52936. /** Weight of the bloom to be added to the original input. */
  52937. weight: number;
  52938. /**
  52939. * Creates a new instance of @see BloomMergePostProcess
  52940. * @param name The name of the effect.
  52941. * @param originalFromInput Post process which's input will be used for the merge.
  52942. * @param blurred Blurred highlights post process which's output will be used.
  52943. * @param weight Weight of the bloom to be added to the original input.
  52944. * @param options The required width/height ratio to downsize to before computing the render pass.
  52945. * @param camera The camera to apply the render pass to.
  52946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52947. * @param engine The engine which the post process will be applied. (default: current engine)
  52948. * @param reusable If the post process can be reused on the same frame. (default: false)
  52949. * @param textureType Type of textures used when performing the post process. (default: 0)
  52950. * @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)
  52951. */
  52952. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52953. /** Weight of the bloom to be added to the original input. */
  52954. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52955. }
  52956. }
  52957. declare module "babylonjs/PostProcesses/bloomEffect" {
  52958. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52959. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52960. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52961. import { Camera } from "babylonjs/Cameras/camera";
  52962. import { Scene } from "babylonjs/scene";
  52963. /**
  52964. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52965. */
  52966. export class BloomEffect extends PostProcessRenderEffect {
  52967. private bloomScale;
  52968. /**
  52969. * @hidden Internal
  52970. */
  52971. _effects: Array<PostProcess>;
  52972. /**
  52973. * @hidden Internal
  52974. */
  52975. _downscale: ExtractHighlightsPostProcess;
  52976. private _blurX;
  52977. private _blurY;
  52978. private _merge;
  52979. /**
  52980. * The luminance threshold to find bright areas of the image to bloom.
  52981. */
  52982. threshold: number;
  52983. /**
  52984. * The strength of the bloom.
  52985. */
  52986. weight: number;
  52987. /**
  52988. * Specifies the size of the bloom blur kernel, relative to the final output size
  52989. */
  52990. kernel: number;
  52991. /**
  52992. * Creates a new instance of @see BloomEffect
  52993. * @param scene The scene the effect belongs to.
  52994. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52995. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52996. * @param bloomWeight The the strength of bloom.
  52997. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52998. * @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)
  52999. */
  53000. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53001. /**
  53002. * Disposes each of the internal effects for a given camera.
  53003. * @param camera The camera to dispose the effect on.
  53004. */
  53005. disposeEffects(camera: Camera): void;
  53006. /**
  53007. * @hidden Internal
  53008. */
  53009. _updateEffects(): void;
  53010. /**
  53011. * Internal
  53012. * @returns if all the contained post processes are ready.
  53013. * @hidden
  53014. */
  53015. _isReady(): boolean;
  53016. }
  53017. }
  53018. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53019. /** @hidden */
  53020. export var chromaticAberrationPixelShader: {
  53021. name: string;
  53022. shader: string;
  53023. };
  53024. }
  53025. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53026. import { Vector2 } from "babylonjs/Maths/math";
  53027. import { Nullable } from "babylonjs/types";
  53028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53029. import { Camera } from "babylonjs/Cameras/camera";
  53030. import { Engine } from "babylonjs/Engines/engine";
  53031. import "babylonjs/Shaders/chromaticAberration.fragment";
  53032. /**
  53033. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53034. */
  53035. export class ChromaticAberrationPostProcess extends PostProcess {
  53036. /**
  53037. * The amount of seperation of rgb channels (default: 30)
  53038. */
  53039. aberrationAmount: number;
  53040. /**
  53041. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53042. */
  53043. radialIntensity: number;
  53044. /**
  53045. * 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))
  53046. */
  53047. direction: Vector2;
  53048. /**
  53049. * 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))
  53050. */
  53051. centerPosition: Vector2;
  53052. /**
  53053. * Creates a new instance ChromaticAberrationPostProcess
  53054. * @param name The name of the effect.
  53055. * @param screenWidth The width of the screen to apply the effect on.
  53056. * @param screenHeight The height of the screen to apply the effect on.
  53057. * @param options The required width/height ratio to downsize to before computing the render pass.
  53058. * @param camera The camera to apply the render pass to.
  53059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53060. * @param engine The engine which the post process will be applied. (default: current engine)
  53061. * @param reusable If the post process can be reused on the same frame. (default: false)
  53062. * @param textureType Type of textures used when performing the post process. (default: 0)
  53063. * @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)
  53064. */
  53065. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53066. }
  53067. }
  53068. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53069. /** @hidden */
  53070. export var circleOfConfusionPixelShader: {
  53071. name: string;
  53072. shader: string;
  53073. };
  53074. }
  53075. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53076. import { Nullable } from "babylonjs/types";
  53077. import { Engine } from "babylonjs/Engines/engine";
  53078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53080. import { Camera } from "babylonjs/Cameras/camera";
  53081. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53082. /**
  53083. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53084. */
  53085. export class CircleOfConfusionPostProcess extends PostProcess {
  53086. /**
  53087. * 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.
  53088. */
  53089. lensSize: number;
  53090. /**
  53091. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53092. */
  53093. fStop: number;
  53094. /**
  53095. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53096. */
  53097. focusDistance: number;
  53098. /**
  53099. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53100. */
  53101. focalLength: number;
  53102. private _depthTexture;
  53103. /**
  53104. * Creates a new instance CircleOfConfusionPostProcess
  53105. * @param name The name of the effect.
  53106. * @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.
  53107. * @param options The required width/height ratio to downsize to before computing the render pass.
  53108. * @param camera The camera to apply the render pass to.
  53109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53110. * @param engine The engine which the post process will be applied. (default: current engine)
  53111. * @param reusable If the post process can be reused on the same frame. (default: false)
  53112. * @param textureType Type of textures used when performing the post process. (default: 0)
  53113. * @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)
  53114. */
  53115. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53116. /**
  53117. * 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.
  53118. */
  53119. depthTexture: RenderTargetTexture;
  53120. }
  53121. }
  53122. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53123. /** @hidden */
  53124. export var colorCorrectionPixelShader: {
  53125. name: string;
  53126. shader: string;
  53127. };
  53128. }
  53129. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53130. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53131. import { Engine } from "babylonjs/Engines/engine";
  53132. import { Camera } from "babylonjs/Cameras/camera";
  53133. import "babylonjs/Shaders/colorCorrection.fragment";
  53134. /**
  53135. *
  53136. * This post-process allows the modification of rendered colors by using
  53137. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53138. *
  53139. * The object needs to be provided an url to a texture containing the color
  53140. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53141. * Use an image editing software to tweak the LUT to match your needs.
  53142. *
  53143. * For an example of a color LUT, see here:
  53144. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53145. * For explanations on color grading, see here:
  53146. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53147. *
  53148. */
  53149. export class ColorCorrectionPostProcess extends PostProcess {
  53150. private _colorTableTexture;
  53151. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53152. }
  53153. }
  53154. declare module "babylonjs/Shaders/convolution.fragment" {
  53155. /** @hidden */
  53156. export var convolutionPixelShader: {
  53157. name: string;
  53158. shader: string;
  53159. };
  53160. }
  53161. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53162. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53163. import { Nullable } from "babylonjs/types";
  53164. import { Camera } from "babylonjs/Cameras/camera";
  53165. import { Engine } from "babylonjs/Engines/engine";
  53166. import "babylonjs/Shaders/convolution.fragment";
  53167. /**
  53168. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53169. * input texture to perform effects such as edge detection or sharpening
  53170. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53171. */
  53172. export class ConvolutionPostProcess extends PostProcess {
  53173. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53174. kernel: number[];
  53175. /**
  53176. * Creates a new instance ConvolutionPostProcess
  53177. * @param name The name of the effect.
  53178. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53179. * @param options The required width/height ratio to downsize to before computing the render pass.
  53180. * @param camera The camera to apply the render pass to.
  53181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53182. * @param engine The engine which the post process will be applied. (default: current engine)
  53183. * @param reusable If the post process can be reused on the same frame. (default: false)
  53184. * @param textureType Type of textures used when performing the post process. (default: 0)
  53185. */
  53186. constructor(name: string,
  53187. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53188. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53189. /**
  53190. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53191. */
  53192. static EdgeDetect0Kernel: number[];
  53193. /**
  53194. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53195. */
  53196. static EdgeDetect1Kernel: number[];
  53197. /**
  53198. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53199. */
  53200. static EdgeDetect2Kernel: number[];
  53201. /**
  53202. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53203. */
  53204. static SharpenKernel: number[];
  53205. /**
  53206. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53207. */
  53208. static EmbossKernel: number[];
  53209. /**
  53210. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53211. */
  53212. static GaussianKernel: number[];
  53213. }
  53214. }
  53215. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53216. import { Nullable } from "babylonjs/types";
  53217. import { Vector2 } from "babylonjs/Maths/math";
  53218. import { Camera } from "babylonjs/Cameras/camera";
  53219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53220. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53221. import { Engine } from "babylonjs/Engines/engine";
  53222. import { Scene } from "babylonjs/scene";
  53223. /**
  53224. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53225. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53226. * based on samples that have a large difference in distance than the center pixel.
  53227. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53228. */
  53229. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53230. direction: Vector2;
  53231. /**
  53232. * Creates a new instance CircleOfConfusionPostProcess
  53233. * @param name The name of the effect.
  53234. * @param scene The scene the effect belongs to.
  53235. * @param direction The direction the blur should be applied.
  53236. * @param kernel The size of the kernel used to blur.
  53237. * @param options The required width/height ratio to downsize to before computing the render pass.
  53238. * @param camera The camera to apply the render pass to.
  53239. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53240. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53242. * @param engine The engine which the post process will be applied. (default: current engine)
  53243. * @param reusable If the post process can be reused on the same frame. (default: false)
  53244. * @param textureType Type of textures used when performing the post process. (default: 0)
  53245. * @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)
  53246. */
  53247. 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);
  53248. }
  53249. }
  53250. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53251. /** @hidden */
  53252. export var depthOfFieldMergePixelShader: {
  53253. name: string;
  53254. shader: string;
  53255. };
  53256. }
  53257. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53258. import { Nullable } from "babylonjs/types";
  53259. import { Camera } from "babylonjs/Cameras/camera";
  53260. import { Effect } from "babylonjs/Materials/effect";
  53261. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53262. import { Engine } from "babylonjs/Engines/engine";
  53263. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53264. /**
  53265. * Options to be set when merging outputs from the default pipeline.
  53266. */
  53267. export class DepthOfFieldMergePostProcessOptions {
  53268. /**
  53269. * The original image to merge on top of
  53270. */
  53271. originalFromInput: PostProcess;
  53272. /**
  53273. * Parameters to perform the merge of the depth of field effect
  53274. */
  53275. depthOfField?: {
  53276. circleOfConfusion: PostProcess;
  53277. blurSteps: Array<PostProcess>;
  53278. };
  53279. /**
  53280. * Parameters to perform the merge of bloom effect
  53281. */
  53282. bloom?: {
  53283. blurred: PostProcess;
  53284. weight: number;
  53285. };
  53286. }
  53287. /**
  53288. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53289. */
  53290. export class DepthOfFieldMergePostProcess extends PostProcess {
  53291. private blurSteps;
  53292. /**
  53293. * Creates a new instance of DepthOfFieldMergePostProcess
  53294. * @param name The name of the effect.
  53295. * @param originalFromInput Post process which's input will be used for the merge.
  53296. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53297. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53298. * @param options The required width/height ratio to downsize to before computing the render pass.
  53299. * @param camera The camera to apply the render pass to.
  53300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53301. * @param engine The engine which the post process will be applied. (default: current engine)
  53302. * @param reusable If the post process can be reused on the same frame. (default: false)
  53303. * @param textureType Type of textures used when performing the post process. (default: 0)
  53304. * @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)
  53305. */
  53306. 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);
  53307. /**
  53308. * Updates the effect with the current post process compile time values and recompiles the shader.
  53309. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53310. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53311. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53312. * @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
  53313. * @param onCompiled Called when the shader has been compiled.
  53314. * @param onError Called if there is an error when compiling a shader.
  53315. */
  53316. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53317. }
  53318. }
  53319. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53320. import { Nullable } from "babylonjs/types";
  53321. import { Camera } from "babylonjs/Cameras/camera";
  53322. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53323. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53324. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53325. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53326. import { Scene } from "babylonjs/scene";
  53327. /**
  53328. * Specifies the level of max blur that should be applied when using the depth of field effect
  53329. */
  53330. export enum DepthOfFieldEffectBlurLevel {
  53331. /**
  53332. * Subtle blur
  53333. */
  53334. Low = 0,
  53335. /**
  53336. * Medium blur
  53337. */
  53338. Medium = 1,
  53339. /**
  53340. * Large blur
  53341. */
  53342. High = 2
  53343. }
  53344. /**
  53345. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53346. */
  53347. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53348. private _circleOfConfusion;
  53349. /**
  53350. * @hidden Internal, blurs from high to low
  53351. */
  53352. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53353. private _depthOfFieldBlurY;
  53354. private _dofMerge;
  53355. /**
  53356. * @hidden Internal post processes in depth of field effect
  53357. */
  53358. _effects: Array<PostProcess>;
  53359. /**
  53360. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53361. */
  53362. focalLength: number;
  53363. /**
  53364. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53365. */
  53366. fStop: number;
  53367. /**
  53368. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53369. */
  53370. focusDistance: number;
  53371. /**
  53372. * 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.
  53373. */
  53374. lensSize: number;
  53375. /**
  53376. * Creates a new instance DepthOfFieldEffect
  53377. * @param scene The scene the effect belongs to.
  53378. * @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.
  53379. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53380. * @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)
  53381. */
  53382. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53383. /**
  53384. * 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.
  53385. */
  53386. depthTexture: RenderTargetTexture;
  53387. /**
  53388. * Disposes each of the internal effects for a given camera.
  53389. * @param camera The camera to dispose the effect on.
  53390. */
  53391. disposeEffects(camera: Camera): void;
  53392. /**
  53393. * @hidden Internal
  53394. */
  53395. _updateEffects(): void;
  53396. /**
  53397. * Internal
  53398. * @returns if all the contained post processes are ready.
  53399. * @hidden
  53400. */
  53401. _isReady(): boolean;
  53402. }
  53403. }
  53404. declare module "babylonjs/Shaders/displayPass.fragment" {
  53405. /** @hidden */
  53406. export var displayPassPixelShader: {
  53407. name: string;
  53408. shader: string;
  53409. };
  53410. }
  53411. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53412. import { Nullable } from "babylonjs/types";
  53413. import { Camera } from "babylonjs/Cameras/camera";
  53414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53415. import { Engine } from "babylonjs/Engines/engine";
  53416. import "babylonjs/Shaders/displayPass.fragment";
  53417. /**
  53418. * DisplayPassPostProcess which produces an output the same as it's input
  53419. */
  53420. export class DisplayPassPostProcess extends PostProcess {
  53421. /**
  53422. * Creates the DisplayPassPostProcess
  53423. * @param name The name of the effect.
  53424. * @param options The required width/height ratio to downsize to before computing the render pass.
  53425. * @param camera The camera to apply the render pass to.
  53426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53427. * @param engine The engine which the post process will be applied. (default: current engine)
  53428. * @param reusable If the post process can be reused on the same frame. (default: false)
  53429. */
  53430. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53431. }
  53432. }
  53433. declare module "babylonjs/Shaders/filter.fragment" {
  53434. /** @hidden */
  53435. export var filterPixelShader: {
  53436. name: string;
  53437. shader: string;
  53438. };
  53439. }
  53440. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53441. import { Nullable } from "babylonjs/types";
  53442. import { Matrix } from "babylonjs/Maths/math";
  53443. import { Camera } from "babylonjs/Cameras/camera";
  53444. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53445. import { Engine } from "babylonjs/Engines/engine";
  53446. import "babylonjs/Shaders/filter.fragment";
  53447. /**
  53448. * Applies a kernel filter to the image
  53449. */
  53450. export class FilterPostProcess extends PostProcess {
  53451. /** The matrix to be applied to the image */
  53452. kernelMatrix: Matrix;
  53453. /**
  53454. *
  53455. * @param name The name of the effect.
  53456. * @param kernelMatrix The matrix to be applied to the image
  53457. * @param options The required width/height ratio to downsize to before computing the render pass.
  53458. * @param camera The camera to apply the render pass to.
  53459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53460. * @param engine The engine which the post process will be applied. (default: current engine)
  53461. * @param reusable If the post process can be reused on the same frame. (default: false)
  53462. */
  53463. constructor(name: string,
  53464. /** The matrix to be applied to the image */
  53465. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53466. }
  53467. }
  53468. declare module "babylonjs/Shaders/fxaa.fragment" {
  53469. /** @hidden */
  53470. export var fxaaPixelShader: {
  53471. name: string;
  53472. shader: string;
  53473. };
  53474. }
  53475. declare module "babylonjs/Shaders/fxaa.vertex" {
  53476. /** @hidden */
  53477. export var fxaaVertexShader: {
  53478. name: string;
  53479. shader: string;
  53480. };
  53481. }
  53482. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53483. import { Nullable } from "babylonjs/types";
  53484. import { Camera } from "babylonjs/Cameras/camera";
  53485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53486. import { Engine } from "babylonjs/Engines/engine";
  53487. import "babylonjs/Shaders/fxaa.fragment";
  53488. import "babylonjs/Shaders/fxaa.vertex";
  53489. /**
  53490. * Fxaa post process
  53491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53492. */
  53493. export class FxaaPostProcess extends PostProcess {
  53494. /** @hidden */
  53495. texelWidth: number;
  53496. /** @hidden */
  53497. texelHeight: number;
  53498. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53499. private _getDefines;
  53500. }
  53501. }
  53502. declare module "babylonjs/Shaders/grain.fragment" {
  53503. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53504. /** @hidden */
  53505. export var grainPixelShader: {
  53506. name: string;
  53507. shader: string;
  53508. };
  53509. }
  53510. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53511. import { Nullable } from "babylonjs/types";
  53512. import { Camera } from "babylonjs/Cameras/camera";
  53513. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53514. import { Engine } from "babylonjs/Engines/engine";
  53515. import "babylonjs/Shaders/grain.fragment";
  53516. /**
  53517. * The GrainPostProcess adds noise to the image at mid luminance levels
  53518. */
  53519. export class GrainPostProcess extends PostProcess {
  53520. /**
  53521. * The intensity of the grain added (default: 30)
  53522. */
  53523. intensity: number;
  53524. /**
  53525. * If the grain should be randomized on every frame
  53526. */
  53527. animated: boolean;
  53528. /**
  53529. * Creates a new instance of @see GrainPostProcess
  53530. * @param name The name of the effect.
  53531. * @param options The required width/height ratio to downsize to before computing the render pass.
  53532. * @param camera The camera to apply the render pass to.
  53533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53534. * @param engine The engine which the post process will be applied. (default: current engine)
  53535. * @param reusable If the post process can be reused on the same frame. (default: false)
  53536. * @param textureType Type of textures used when performing the post process. (default: 0)
  53537. * @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)
  53538. */
  53539. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53540. }
  53541. }
  53542. declare module "babylonjs/Shaders/highlights.fragment" {
  53543. /** @hidden */
  53544. export var highlightsPixelShader: {
  53545. name: string;
  53546. shader: string;
  53547. };
  53548. }
  53549. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53550. import { Nullable } from "babylonjs/types";
  53551. import { Camera } from "babylonjs/Cameras/camera";
  53552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53553. import { Engine } from "babylonjs/Engines/engine";
  53554. import "babylonjs/Shaders/highlights.fragment";
  53555. /**
  53556. * Extracts highlights from the image
  53557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53558. */
  53559. export class HighlightsPostProcess extends PostProcess {
  53560. /**
  53561. * Extracts highlights from the image
  53562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53563. * @param name The name of the effect.
  53564. * @param options The required width/height ratio to downsize to before computing the render pass.
  53565. * @param camera The camera to apply the render pass to.
  53566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53567. * @param engine The engine which the post process will be applied. (default: current engine)
  53568. * @param reusable If the post process can be reused on the same frame. (default: false)
  53569. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53570. */
  53571. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53572. }
  53573. }
  53574. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53575. /** @hidden */
  53576. export var mrtFragmentDeclaration: {
  53577. name: string;
  53578. shader: string;
  53579. };
  53580. }
  53581. declare module "babylonjs/Shaders/geometry.fragment" {
  53582. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53583. /** @hidden */
  53584. export var geometryPixelShader: {
  53585. name: string;
  53586. shader: string;
  53587. };
  53588. }
  53589. declare module "babylonjs/Shaders/geometry.vertex" {
  53590. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53591. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53592. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53593. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53594. /** @hidden */
  53595. export var geometryVertexShader: {
  53596. name: string;
  53597. shader: string;
  53598. };
  53599. }
  53600. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53601. import { Matrix } from "babylonjs/Maths/math";
  53602. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53603. import { Mesh } from "babylonjs/Meshes/mesh";
  53604. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53605. import { Effect } from "babylonjs/Materials/effect";
  53606. import { Scene } from "babylonjs/scene";
  53607. import "babylonjs/Shaders/geometry.fragment";
  53608. import "babylonjs/Shaders/geometry.vertex";
  53609. /**
  53610. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53611. */
  53612. export class GeometryBufferRenderer {
  53613. /**
  53614. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53615. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53616. */
  53617. static readonly POSITION_TEXTURE_TYPE: number;
  53618. /**
  53619. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53620. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53621. */
  53622. static readonly VELOCITY_TEXTURE_TYPE: number;
  53623. /**
  53624. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53625. * in order to compute objects velocities when enableVelocity is set to "true"
  53626. * @hidden
  53627. */
  53628. _previousTransformationMatrices: {
  53629. [index: number]: Matrix;
  53630. };
  53631. private _scene;
  53632. private _multiRenderTarget;
  53633. private _ratio;
  53634. private _enablePosition;
  53635. private _enableVelocity;
  53636. private _positionIndex;
  53637. private _velocityIndex;
  53638. protected _effect: Effect;
  53639. protected _cachedDefines: string;
  53640. /**
  53641. * Set the render list (meshes to be rendered) used in the G buffer.
  53642. */
  53643. renderList: Mesh[];
  53644. /**
  53645. * Gets wether or not G buffer are supported by the running hardware.
  53646. * This requires draw buffer supports
  53647. */
  53648. readonly isSupported: boolean;
  53649. /**
  53650. * Returns the index of the given texture type in the G-Buffer textures array
  53651. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53652. * @returns the index of the given texture type in the G-Buffer textures array
  53653. */
  53654. getTextureIndex(textureType: number): number;
  53655. /**
  53656. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53657. */
  53658. /**
  53659. * Sets whether or not objects positions are enabled for the G buffer.
  53660. */
  53661. enablePosition: boolean;
  53662. /**
  53663. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53664. */
  53665. /**
  53666. * Sets wether or not objects velocities are enabled for the G buffer.
  53667. */
  53668. enableVelocity: boolean;
  53669. /**
  53670. * Gets the scene associated with the buffer.
  53671. */
  53672. readonly scene: Scene;
  53673. /**
  53674. * Gets the ratio used by the buffer during its creation.
  53675. * How big is the buffer related to the main canvas.
  53676. */
  53677. readonly ratio: number;
  53678. /** @hidden */
  53679. static _SceneComponentInitialization: (scene: Scene) => void;
  53680. /**
  53681. * Creates a new G Buffer for the scene
  53682. * @param scene The scene the buffer belongs to
  53683. * @param ratio How big is the buffer related to the main canvas.
  53684. */
  53685. constructor(scene: Scene, ratio?: number);
  53686. /**
  53687. * Checks wether everything is ready to render a submesh to the G buffer.
  53688. * @param subMesh the submesh to check readiness for
  53689. * @param useInstances is the mesh drawn using instance or not
  53690. * @returns true if ready otherwise false
  53691. */
  53692. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53693. /**
  53694. * Gets the current underlying G Buffer.
  53695. * @returns the buffer
  53696. */
  53697. getGBuffer(): MultiRenderTarget;
  53698. /**
  53699. * Gets the number of samples used to render the buffer (anti aliasing).
  53700. */
  53701. /**
  53702. * Sets the number of samples used to render the buffer (anti aliasing).
  53703. */
  53704. samples: number;
  53705. /**
  53706. * Disposes the renderer and frees up associated resources.
  53707. */
  53708. dispose(): void;
  53709. protected _createRenderTargets(): void;
  53710. }
  53711. }
  53712. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53713. import { Nullable } from "babylonjs/types";
  53714. import { Scene } from "babylonjs/scene";
  53715. import { ISceneComponent } from "babylonjs/sceneComponent";
  53716. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53717. module "babylonjs/scene" {
  53718. interface Scene {
  53719. /** @hidden (Backing field) */
  53720. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53721. /**
  53722. * Gets or Sets the current geometry buffer associated to the scene.
  53723. */
  53724. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53725. /**
  53726. * Enables a GeometryBufferRender and associates it with the scene
  53727. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53728. * @returns the GeometryBufferRenderer
  53729. */
  53730. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53731. /**
  53732. * Disables the GeometryBufferRender associated with the scene
  53733. */
  53734. disableGeometryBufferRenderer(): void;
  53735. }
  53736. }
  53737. /**
  53738. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53739. * in several rendering techniques.
  53740. */
  53741. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53742. /**
  53743. * The component name helpful to identify the component in the list of scene components.
  53744. */
  53745. readonly name: string;
  53746. /**
  53747. * The scene the component belongs to.
  53748. */
  53749. scene: Scene;
  53750. /**
  53751. * Creates a new instance of the component for the given scene
  53752. * @param scene Defines the scene to register the component in
  53753. */
  53754. constructor(scene: Scene);
  53755. /**
  53756. * Registers the component in a given scene
  53757. */
  53758. register(): void;
  53759. /**
  53760. * Rebuilds the elements related to this component in case of
  53761. * context lost for instance.
  53762. */
  53763. rebuild(): void;
  53764. /**
  53765. * Disposes the component and the associated ressources
  53766. */
  53767. dispose(): void;
  53768. private _gatherRenderTargets;
  53769. }
  53770. }
  53771. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53772. /** @hidden */
  53773. export var motionBlurPixelShader: {
  53774. name: string;
  53775. shader: string;
  53776. };
  53777. }
  53778. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53779. import { Nullable } from "babylonjs/types";
  53780. import { Camera } from "babylonjs/Cameras/camera";
  53781. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53782. import { Scene } from "babylonjs/scene";
  53783. import "babylonjs/Animations/animatable";
  53784. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53785. import "babylonjs/Shaders/motionBlur.fragment";
  53786. import { Engine } from "babylonjs/Engines/engine";
  53787. /**
  53788. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53789. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53790. * As an example, all you have to do is to create the post-process:
  53791. * var mb = new BABYLON.MotionBlurPostProcess(
  53792. * 'mb', // The name of the effect.
  53793. * scene, // The scene containing the objects to blur according to their velocity.
  53794. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53795. * camera // The camera to apply the render pass to.
  53796. * );
  53797. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53798. */
  53799. export class MotionBlurPostProcess extends PostProcess {
  53800. /**
  53801. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53802. */
  53803. motionStrength: number;
  53804. /**
  53805. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53806. */
  53807. /**
  53808. * Sets the number of iterations to be used for motion blur quality
  53809. */
  53810. motionBlurSamples: number;
  53811. private _motionBlurSamples;
  53812. private _geometryBufferRenderer;
  53813. /**
  53814. * Creates a new instance MotionBlurPostProcess
  53815. * @param name The name of the effect.
  53816. * @param scene The scene containing the objects to blur according to their velocity.
  53817. * @param options The required width/height ratio to downsize to before computing the render pass.
  53818. * @param camera The camera to apply the render pass to.
  53819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53820. * @param engine The engine which the post process will be applied. (default: current engine)
  53821. * @param reusable If the post process can be reused on the same frame. (default: false)
  53822. * @param textureType Type of textures used when performing the post process. (default: 0)
  53823. * @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)
  53824. */
  53825. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53826. /**
  53827. * Disposes the post process.
  53828. * @param camera The camera to dispose the post process on.
  53829. */
  53830. dispose(camera?: Camera): void;
  53831. }
  53832. }
  53833. declare module "babylonjs/Shaders/refraction.fragment" {
  53834. /** @hidden */
  53835. export var refractionPixelShader: {
  53836. name: string;
  53837. shader: string;
  53838. };
  53839. }
  53840. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53841. import { Color3 } from "babylonjs/Maths/math";
  53842. import { Camera } from "babylonjs/Cameras/camera";
  53843. import { Texture } from "babylonjs/Materials/Textures/texture";
  53844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53845. import { Engine } from "babylonjs/Engines/engine";
  53846. import "babylonjs/Shaders/refraction.fragment";
  53847. /**
  53848. * Post process which applies a refractin texture
  53849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53850. */
  53851. export class RefractionPostProcess extends PostProcess {
  53852. /** the base color of the refraction (used to taint the rendering) */
  53853. color: Color3;
  53854. /** simulated refraction depth */
  53855. depth: number;
  53856. /** the coefficient of the base color (0 to remove base color tainting) */
  53857. colorLevel: number;
  53858. private _refTexture;
  53859. private _ownRefractionTexture;
  53860. /**
  53861. * Gets or sets the refraction texture
  53862. * Please note that you are responsible for disposing the texture if you set it manually
  53863. */
  53864. refractionTexture: Texture;
  53865. /**
  53866. * Initializes the RefractionPostProcess
  53867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53868. * @param name The name of the effect.
  53869. * @param refractionTextureUrl Url of the refraction texture to use
  53870. * @param color the base color of the refraction (used to taint the rendering)
  53871. * @param depth simulated refraction depth
  53872. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53873. * @param camera The camera to apply the render pass to.
  53874. * @param options The required width/height ratio to downsize to before computing the render pass.
  53875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53876. * @param engine The engine which the post process will be applied. (default: current engine)
  53877. * @param reusable If the post process can be reused on the same frame. (default: false)
  53878. */
  53879. constructor(name: string, refractionTextureUrl: string,
  53880. /** the base color of the refraction (used to taint the rendering) */
  53881. color: Color3,
  53882. /** simulated refraction depth */
  53883. depth: number,
  53884. /** the coefficient of the base color (0 to remove base color tainting) */
  53885. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53886. /**
  53887. * Disposes of the post process
  53888. * @param camera Camera to dispose post process on
  53889. */
  53890. dispose(camera: Camera): void;
  53891. }
  53892. }
  53893. declare module "babylonjs/Shaders/sharpen.fragment" {
  53894. /** @hidden */
  53895. export var sharpenPixelShader: {
  53896. name: string;
  53897. shader: string;
  53898. };
  53899. }
  53900. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53901. import { Nullable } from "babylonjs/types";
  53902. import { Camera } from "babylonjs/Cameras/camera";
  53903. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53904. import "babylonjs/Shaders/sharpen.fragment";
  53905. import { Engine } from "babylonjs/Engines/engine";
  53906. /**
  53907. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53908. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53909. */
  53910. export class SharpenPostProcess extends PostProcess {
  53911. /**
  53912. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53913. */
  53914. colorAmount: number;
  53915. /**
  53916. * How much sharpness should be applied (default: 0.3)
  53917. */
  53918. edgeAmount: number;
  53919. /**
  53920. * Creates a new instance ConvolutionPostProcess
  53921. * @param name The name of the effect.
  53922. * @param options The required width/height ratio to downsize to before computing the render pass.
  53923. * @param camera The camera to apply the render pass to.
  53924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53925. * @param engine The engine which the post process will be applied. (default: current engine)
  53926. * @param reusable If the post process can be reused on the same frame. (default: false)
  53927. * @param textureType Type of textures used when performing the post process. (default: 0)
  53928. * @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)
  53929. */
  53930. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53931. }
  53932. }
  53933. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53934. import { Nullable } from "babylonjs/types";
  53935. import { Camera } from "babylonjs/Cameras/camera";
  53936. import { Engine } from "babylonjs/Engines/engine";
  53937. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53938. /**
  53939. * PostProcessRenderPipeline
  53940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53941. */
  53942. export class PostProcessRenderPipeline {
  53943. private engine;
  53944. private _renderEffects;
  53945. private _renderEffectsForIsolatedPass;
  53946. /**
  53947. * @hidden
  53948. */
  53949. protected _cameras: Camera[];
  53950. /** @hidden */
  53951. _name: string;
  53952. /**
  53953. * Gets pipeline name
  53954. */
  53955. readonly name: string;
  53956. /**
  53957. * Initializes a PostProcessRenderPipeline
  53958. * @param engine engine to add the pipeline to
  53959. * @param name name of the pipeline
  53960. */
  53961. constructor(engine: Engine, name: string);
  53962. /**
  53963. * Gets the class name
  53964. * @returns "PostProcessRenderPipeline"
  53965. */
  53966. getClassName(): string;
  53967. /**
  53968. * If all the render effects in the pipeline are supported
  53969. */
  53970. readonly isSupported: boolean;
  53971. /**
  53972. * Adds an effect to the pipeline
  53973. * @param renderEffect the effect to add
  53974. */
  53975. addEffect(renderEffect: PostProcessRenderEffect): void;
  53976. /** @hidden */
  53977. _rebuild(): void;
  53978. /** @hidden */
  53979. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53980. /** @hidden */
  53981. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53982. /** @hidden */
  53983. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53984. /** @hidden */
  53985. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53986. /** @hidden */
  53987. _attachCameras(cameras: Camera, unique: boolean): void;
  53988. /** @hidden */
  53989. _attachCameras(cameras: Camera[], unique: boolean): void;
  53990. /** @hidden */
  53991. _detachCameras(cameras: Camera): void;
  53992. /** @hidden */
  53993. _detachCameras(cameras: Nullable<Camera[]>): void;
  53994. /** @hidden */
  53995. _update(): void;
  53996. /** @hidden */
  53997. _reset(): void;
  53998. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53999. /**
  54000. * Disposes of the pipeline
  54001. */
  54002. dispose(): void;
  54003. }
  54004. }
  54005. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54006. import { Camera } from "babylonjs/Cameras/camera";
  54007. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54008. /**
  54009. * PostProcessRenderPipelineManager class
  54010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54011. */
  54012. export class PostProcessRenderPipelineManager {
  54013. private _renderPipelines;
  54014. /**
  54015. * Initializes a PostProcessRenderPipelineManager
  54016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54017. */
  54018. constructor();
  54019. /**
  54020. * Gets the list of supported render pipelines
  54021. */
  54022. readonly supportedPipelines: PostProcessRenderPipeline[];
  54023. /**
  54024. * Adds a pipeline to the manager
  54025. * @param renderPipeline The pipeline to add
  54026. */
  54027. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54028. /**
  54029. * Attaches a camera to the pipeline
  54030. * @param renderPipelineName The name of the pipeline to attach to
  54031. * @param cameras the camera to attach
  54032. * @param unique if the camera can be attached multiple times to the pipeline
  54033. */
  54034. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54035. /**
  54036. * Detaches a camera from the pipeline
  54037. * @param renderPipelineName The name of the pipeline to detach from
  54038. * @param cameras the camera to detach
  54039. */
  54040. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54041. /**
  54042. * Enables an effect by name on a pipeline
  54043. * @param renderPipelineName the name of the pipeline to enable the effect in
  54044. * @param renderEffectName the name of the effect to enable
  54045. * @param cameras the cameras that the effect should be enabled on
  54046. */
  54047. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54048. /**
  54049. * Disables an effect by name on a pipeline
  54050. * @param renderPipelineName the name of the pipeline to disable the effect in
  54051. * @param renderEffectName the name of the effect to disable
  54052. * @param cameras the cameras that the effect should be disabled on
  54053. */
  54054. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54055. /**
  54056. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54057. */
  54058. update(): void;
  54059. /** @hidden */
  54060. _rebuild(): void;
  54061. /**
  54062. * Disposes of the manager and pipelines
  54063. */
  54064. dispose(): void;
  54065. }
  54066. }
  54067. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54068. import { ISceneComponent } from "babylonjs/sceneComponent";
  54069. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54070. import { Scene } from "babylonjs/scene";
  54071. module "babylonjs/scene" {
  54072. interface Scene {
  54073. /** @hidden (Backing field) */
  54074. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54075. /**
  54076. * Gets the postprocess render pipeline manager
  54077. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54078. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54079. */
  54080. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54081. }
  54082. }
  54083. /**
  54084. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54085. */
  54086. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54087. /**
  54088. * The component name helpfull to identify the component in the list of scene components.
  54089. */
  54090. readonly name: string;
  54091. /**
  54092. * The scene the component belongs to.
  54093. */
  54094. scene: Scene;
  54095. /**
  54096. * Creates a new instance of the component for the given scene
  54097. * @param scene Defines the scene to register the component in
  54098. */
  54099. constructor(scene: Scene);
  54100. /**
  54101. * Registers the component in a given scene
  54102. */
  54103. register(): void;
  54104. /**
  54105. * Rebuilds the elements related to this component in case of
  54106. * context lost for instance.
  54107. */
  54108. rebuild(): void;
  54109. /**
  54110. * Disposes the component and the associated ressources
  54111. */
  54112. dispose(): void;
  54113. private _gatherRenderTargets;
  54114. }
  54115. }
  54116. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54117. import { IAnimatable } from "babylonjs/Misc/tools";
  54118. import { Camera } from "babylonjs/Cameras/camera";
  54119. import { IDisposable } from "babylonjs/scene";
  54120. import { Scene } from "babylonjs/scene";
  54121. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54122. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54123. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54124. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54125. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54126. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54127. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54128. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54129. import { Animation } from "babylonjs/Animations/animation";
  54130. /**
  54131. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54132. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54133. */
  54134. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54135. private _scene;
  54136. private _camerasToBeAttached;
  54137. /**
  54138. * ID of the sharpen post process,
  54139. */
  54140. private readonly SharpenPostProcessId;
  54141. /**
  54142. * @ignore
  54143. * ID of the image processing post process;
  54144. */
  54145. readonly ImageProcessingPostProcessId: string;
  54146. /**
  54147. * @ignore
  54148. * ID of the Fast Approximate Anti-Aliasing post process;
  54149. */
  54150. readonly FxaaPostProcessId: string;
  54151. /**
  54152. * ID of the chromatic aberration post process,
  54153. */
  54154. private readonly ChromaticAberrationPostProcessId;
  54155. /**
  54156. * ID of the grain post process
  54157. */
  54158. private readonly GrainPostProcessId;
  54159. /**
  54160. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54161. */
  54162. sharpen: SharpenPostProcess;
  54163. private _sharpenEffect;
  54164. private bloom;
  54165. /**
  54166. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54167. */
  54168. depthOfField: DepthOfFieldEffect;
  54169. /**
  54170. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54171. */
  54172. fxaa: FxaaPostProcess;
  54173. /**
  54174. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54175. */
  54176. imageProcessing: ImageProcessingPostProcess;
  54177. /**
  54178. * Chromatic aberration post process which will shift rgb colors in the image
  54179. */
  54180. chromaticAberration: ChromaticAberrationPostProcess;
  54181. private _chromaticAberrationEffect;
  54182. /**
  54183. * Grain post process which add noise to the image
  54184. */
  54185. grain: GrainPostProcess;
  54186. private _grainEffect;
  54187. /**
  54188. * Glow post process which adds a glow to emissive areas of the image
  54189. */
  54190. private _glowLayer;
  54191. /**
  54192. * Animations which can be used to tweak settings over a period of time
  54193. */
  54194. animations: Animation[];
  54195. private _imageProcessingConfigurationObserver;
  54196. private _sharpenEnabled;
  54197. private _bloomEnabled;
  54198. private _depthOfFieldEnabled;
  54199. private _depthOfFieldBlurLevel;
  54200. private _fxaaEnabled;
  54201. private _imageProcessingEnabled;
  54202. private _defaultPipelineTextureType;
  54203. private _bloomScale;
  54204. private _chromaticAberrationEnabled;
  54205. private _grainEnabled;
  54206. private _buildAllowed;
  54207. /**
  54208. * Gets active scene
  54209. */
  54210. readonly scene: Scene;
  54211. /**
  54212. * Enable or disable the sharpen process from the pipeline
  54213. */
  54214. sharpenEnabled: boolean;
  54215. private _resizeObserver;
  54216. private _hardwareScaleLevel;
  54217. private _bloomKernel;
  54218. /**
  54219. * Specifies the size of the bloom blur kernel, relative to the final output size
  54220. */
  54221. bloomKernel: number;
  54222. /**
  54223. * Specifies the weight of the bloom in the final rendering
  54224. */
  54225. private _bloomWeight;
  54226. /**
  54227. * Specifies the luma threshold for the area that will be blurred by the bloom
  54228. */
  54229. private _bloomThreshold;
  54230. private _hdr;
  54231. /**
  54232. * The strength of the bloom.
  54233. */
  54234. bloomWeight: number;
  54235. /**
  54236. * The strength of the bloom.
  54237. */
  54238. bloomThreshold: number;
  54239. /**
  54240. * The scale of the bloom, lower value will provide better performance.
  54241. */
  54242. bloomScale: number;
  54243. /**
  54244. * Enable or disable the bloom from the pipeline
  54245. */
  54246. bloomEnabled: boolean;
  54247. private _rebuildBloom;
  54248. /**
  54249. * If the depth of field is enabled.
  54250. */
  54251. depthOfFieldEnabled: boolean;
  54252. /**
  54253. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54254. */
  54255. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54256. /**
  54257. * If the anti aliasing is enabled.
  54258. */
  54259. fxaaEnabled: boolean;
  54260. private _samples;
  54261. /**
  54262. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54263. */
  54264. samples: number;
  54265. /**
  54266. * If image processing is enabled.
  54267. */
  54268. imageProcessingEnabled: boolean;
  54269. /**
  54270. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54271. */
  54272. glowLayerEnabled: boolean;
  54273. /**
  54274. * Enable or disable the chromaticAberration process from the pipeline
  54275. */
  54276. chromaticAberrationEnabled: boolean;
  54277. /**
  54278. * Enable or disable the grain process from the pipeline
  54279. */
  54280. grainEnabled: boolean;
  54281. /**
  54282. * @constructor
  54283. * @param name - The rendering pipeline name (default: "")
  54284. * @param hdr - If high dynamic range textures should be used (default: true)
  54285. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54286. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54287. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54288. */
  54289. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54290. /**
  54291. * Get the class name
  54292. * @returns "DefaultRenderingPipeline"
  54293. */
  54294. getClassName(): string;
  54295. /**
  54296. * Force the compilation of the entire pipeline.
  54297. */
  54298. prepare(): void;
  54299. private _hasCleared;
  54300. private _prevPostProcess;
  54301. private _prevPrevPostProcess;
  54302. private _setAutoClearAndTextureSharing;
  54303. private _depthOfFieldSceneObserver;
  54304. private _buildPipeline;
  54305. private _disposePostProcesses;
  54306. /**
  54307. * Adds a camera to the pipeline
  54308. * @param camera the camera to be added
  54309. */
  54310. addCamera(camera: Camera): void;
  54311. /**
  54312. * Removes a camera from the pipeline
  54313. * @param camera the camera to remove
  54314. */
  54315. removeCamera(camera: Camera): void;
  54316. /**
  54317. * Dispose of the pipeline and stop all post processes
  54318. */
  54319. dispose(): void;
  54320. /**
  54321. * Serialize the rendering pipeline (Used when exporting)
  54322. * @returns the serialized object
  54323. */
  54324. serialize(): any;
  54325. /**
  54326. * Parse the serialized pipeline
  54327. * @param source Source pipeline.
  54328. * @param scene The scene to load the pipeline to.
  54329. * @param rootUrl The URL of the serialized pipeline.
  54330. * @returns An instantiated pipeline from the serialized object.
  54331. */
  54332. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54333. }
  54334. }
  54335. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54336. /** @hidden */
  54337. export var lensHighlightsPixelShader: {
  54338. name: string;
  54339. shader: string;
  54340. };
  54341. }
  54342. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54343. /** @hidden */
  54344. export var depthOfFieldPixelShader: {
  54345. name: string;
  54346. shader: string;
  54347. };
  54348. }
  54349. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54350. import { Camera } from "babylonjs/Cameras/camera";
  54351. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54352. import { Scene } from "babylonjs/scene";
  54353. import "babylonjs/Shaders/chromaticAberration.fragment";
  54354. import "babylonjs/Shaders/lensHighlights.fragment";
  54355. import "babylonjs/Shaders/depthOfField.fragment";
  54356. /**
  54357. * BABYLON.JS Chromatic Aberration GLSL Shader
  54358. * Author: Olivier Guyot
  54359. * Separates very slightly R, G and B colors on the edges of the screen
  54360. * Inspired by Francois Tarlier & Martins Upitis
  54361. */
  54362. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54363. /**
  54364. * @ignore
  54365. * The chromatic aberration PostProcess id in the pipeline
  54366. */
  54367. LensChromaticAberrationEffect: string;
  54368. /**
  54369. * @ignore
  54370. * The highlights enhancing PostProcess id in the pipeline
  54371. */
  54372. HighlightsEnhancingEffect: string;
  54373. /**
  54374. * @ignore
  54375. * The depth-of-field PostProcess id in the pipeline
  54376. */
  54377. LensDepthOfFieldEffect: string;
  54378. private _scene;
  54379. private _depthTexture;
  54380. private _grainTexture;
  54381. private _chromaticAberrationPostProcess;
  54382. private _highlightsPostProcess;
  54383. private _depthOfFieldPostProcess;
  54384. private _edgeBlur;
  54385. private _grainAmount;
  54386. private _chromaticAberration;
  54387. private _distortion;
  54388. private _highlightsGain;
  54389. private _highlightsThreshold;
  54390. private _dofDistance;
  54391. private _dofAperture;
  54392. private _dofDarken;
  54393. private _dofPentagon;
  54394. private _blurNoise;
  54395. /**
  54396. * @constructor
  54397. *
  54398. * Effect parameters are as follow:
  54399. * {
  54400. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54401. * edge_blur: number; // from 0 to x (1 for realism)
  54402. * distortion: number; // from 0 to x (1 for realism)
  54403. * grain_amount: number; // from 0 to 1
  54404. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54405. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54406. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54407. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54408. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54409. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54410. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54411. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54412. * }
  54413. * Note: if an effect parameter is unset, effect is disabled
  54414. *
  54415. * @param name The rendering pipeline name
  54416. * @param parameters - An object containing all parameters (see above)
  54417. * @param scene The scene linked to this pipeline
  54418. * @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)
  54419. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54420. */
  54421. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54422. /**
  54423. * Get the class name
  54424. * @returns "LensRenderingPipeline"
  54425. */
  54426. getClassName(): string;
  54427. /**
  54428. * Gets associated scene
  54429. */
  54430. readonly scene: Scene;
  54431. /**
  54432. * Gets or sets the edge blur
  54433. */
  54434. edgeBlur: number;
  54435. /**
  54436. * Gets or sets the grain amount
  54437. */
  54438. grainAmount: number;
  54439. /**
  54440. * Gets or sets the chromatic aberration amount
  54441. */
  54442. chromaticAberration: number;
  54443. /**
  54444. * Gets or sets the depth of field aperture
  54445. */
  54446. dofAperture: number;
  54447. /**
  54448. * Gets or sets the edge distortion
  54449. */
  54450. edgeDistortion: number;
  54451. /**
  54452. * Gets or sets the depth of field distortion
  54453. */
  54454. dofDistortion: number;
  54455. /**
  54456. * Gets or sets the darken out of focus amount
  54457. */
  54458. darkenOutOfFocus: number;
  54459. /**
  54460. * Gets or sets a boolean indicating if blur noise is enabled
  54461. */
  54462. blurNoise: boolean;
  54463. /**
  54464. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54465. */
  54466. pentagonBokeh: boolean;
  54467. /**
  54468. * Gets or sets the highlight grain amount
  54469. */
  54470. highlightsGain: number;
  54471. /**
  54472. * Gets or sets the highlight threshold
  54473. */
  54474. highlightsThreshold: number;
  54475. /**
  54476. * Sets the amount of blur at the edges
  54477. * @param amount blur amount
  54478. */
  54479. setEdgeBlur(amount: number): void;
  54480. /**
  54481. * Sets edge blur to 0
  54482. */
  54483. disableEdgeBlur(): void;
  54484. /**
  54485. * Sets the amout of grain
  54486. * @param amount Amount of grain
  54487. */
  54488. setGrainAmount(amount: number): void;
  54489. /**
  54490. * Set grain amount to 0
  54491. */
  54492. disableGrain(): void;
  54493. /**
  54494. * Sets the chromatic aberration amount
  54495. * @param amount amount of chromatic aberration
  54496. */
  54497. setChromaticAberration(amount: number): void;
  54498. /**
  54499. * Sets chromatic aberration amount to 0
  54500. */
  54501. disableChromaticAberration(): void;
  54502. /**
  54503. * Sets the EdgeDistortion amount
  54504. * @param amount amount of EdgeDistortion
  54505. */
  54506. setEdgeDistortion(amount: number): void;
  54507. /**
  54508. * Sets edge distortion to 0
  54509. */
  54510. disableEdgeDistortion(): void;
  54511. /**
  54512. * Sets the FocusDistance amount
  54513. * @param amount amount of FocusDistance
  54514. */
  54515. setFocusDistance(amount: number): void;
  54516. /**
  54517. * Disables depth of field
  54518. */
  54519. disableDepthOfField(): void;
  54520. /**
  54521. * Sets the Aperture amount
  54522. * @param amount amount of Aperture
  54523. */
  54524. setAperture(amount: number): void;
  54525. /**
  54526. * Sets the DarkenOutOfFocus amount
  54527. * @param amount amount of DarkenOutOfFocus
  54528. */
  54529. setDarkenOutOfFocus(amount: number): void;
  54530. private _pentagonBokehIsEnabled;
  54531. /**
  54532. * Creates a pentagon bokeh effect
  54533. */
  54534. enablePentagonBokeh(): void;
  54535. /**
  54536. * Disables the pentagon bokeh effect
  54537. */
  54538. disablePentagonBokeh(): void;
  54539. /**
  54540. * Enables noise blur
  54541. */
  54542. enableNoiseBlur(): void;
  54543. /**
  54544. * Disables noise blur
  54545. */
  54546. disableNoiseBlur(): void;
  54547. /**
  54548. * Sets the HighlightsGain amount
  54549. * @param amount amount of HighlightsGain
  54550. */
  54551. setHighlightsGain(amount: number): void;
  54552. /**
  54553. * Sets the HighlightsThreshold amount
  54554. * @param amount amount of HighlightsThreshold
  54555. */
  54556. setHighlightsThreshold(amount: number): void;
  54557. /**
  54558. * Disables highlights
  54559. */
  54560. disableHighlights(): void;
  54561. /**
  54562. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54563. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54564. */
  54565. dispose(disableDepthRender?: boolean): void;
  54566. private _createChromaticAberrationPostProcess;
  54567. private _createHighlightsPostProcess;
  54568. private _createDepthOfFieldPostProcess;
  54569. private _createGrainTexture;
  54570. }
  54571. }
  54572. declare module "babylonjs/Shaders/ssao2.fragment" {
  54573. /** @hidden */
  54574. export var ssao2PixelShader: {
  54575. name: string;
  54576. shader: string;
  54577. };
  54578. }
  54579. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54580. /** @hidden */
  54581. export var ssaoCombinePixelShader: {
  54582. name: string;
  54583. shader: string;
  54584. };
  54585. }
  54586. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54587. import { Camera } from "babylonjs/Cameras/camera";
  54588. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54589. import { Scene } from "babylonjs/scene";
  54590. import "babylonjs/Shaders/ssao2.fragment";
  54591. import "babylonjs/Shaders/ssaoCombine.fragment";
  54592. /**
  54593. * Render pipeline to produce ssao effect
  54594. */
  54595. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54596. /**
  54597. * @ignore
  54598. * The PassPostProcess id in the pipeline that contains the original scene color
  54599. */
  54600. SSAOOriginalSceneColorEffect: string;
  54601. /**
  54602. * @ignore
  54603. * The SSAO PostProcess id in the pipeline
  54604. */
  54605. SSAORenderEffect: string;
  54606. /**
  54607. * @ignore
  54608. * The horizontal blur PostProcess id in the pipeline
  54609. */
  54610. SSAOBlurHRenderEffect: string;
  54611. /**
  54612. * @ignore
  54613. * The vertical blur PostProcess id in the pipeline
  54614. */
  54615. SSAOBlurVRenderEffect: string;
  54616. /**
  54617. * @ignore
  54618. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54619. */
  54620. SSAOCombineRenderEffect: string;
  54621. /**
  54622. * The output strength of the SSAO post-process. Default value is 1.0.
  54623. */
  54624. totalStrength: number;
  54625. /**
  54626. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54627. */
  54628. maxZ: number;
  54629. /**
  54630. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54631. */
  54632. minZAspect: number;
  54633. private _samples;
  54634. /**
  54635. * Number of samples used for the SSAO calculations. Default value is 8
  54636. */
  54637. samples: number;
  54638. private _textureSamples;
  54639. /**
  54640. * Number of samples to use for antialiasing
  54641. */
  54642. textureSamples: number;
  54643. /**
  54644. * Ratio object used for SSAO ratio and blur ratio
  54645. */
  54646. private _ratio;
  54647. /**
  54648. * Dynamically generated sphere sampler.
  54649. */
  54650. private _sampleSphere;
  54651. /**
  54652. * Blur filter offsets
  54653. */
  54654. private _samplerOffsets;
  54655. private _expensiveBlur;
  54656. /**
  54657. * If bilateral blur should be used
  54658. */
  54659. expensiveBlur: boolean;
  54660. /**
  54661. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54662. */
  54663. radius: number;
  54664. /**
  54665. * The base color of the SSAO post-process
  54666. * The final result is "base + ssao" between [0, 1]
  54667. */
  54668. base: number;
  54669. /**
  54670. * Support test.
  54671. */
  54672. static readonly IsSupported: boolean;
  54673. private _scene;
  54674. private _depthTexture;
  54675. private _normalTexture;
  54676. private _randomTexture;
  54677. private _originalColorPostProcess;
  54678. private _ssaoPostProcess;
  54679. private _blurHPostProcess;
  54680. private _blurVPostProcess;
  54681. private _ssaoCombinePostProcess;
  54682. private _firstUpdate;
  54683. /**
  54684. * Gets active scene
  54685. */
  54686. readonly scene: Scene;
  54687. /**
  54688. * @constructor
  54689. * @param name The rendering pipeline name
  54690. * @param scene The scene linked to this pipeline
  54691. * @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 }
  54692. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54693. */
  54694. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54695. /**
  54696. * Get the class name
  54697. * @returns "SSAO2RenderingPipeline"
  54698. */
  54699. getClassName(): string;
  54700. /**
  54701. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54702. */
  54703. dispose(disableGeometryBufferRenderer?: boolean): void;
  54704. private _createBlurPostProcess;
  54705. /** @hidden */
  54706. _rebuild(): void;
  54707. private _bits;
  54708. private _radicalInverse_VdC;
  54709. private _hammersley;
  54710. private _hemisphereSample_uniform;
  54711. private _generateHemisphere;
  54712. private _createSSAOPostProcess;
  54713. private _createSSAOCombinePostProcess;
  54714. private _createRandomTexture;
  54715. /**
  54716. * Serialize the rendering pipeline (Used when exporting)
  54717. * @returns the serialized object
  54718. */
  54719. serialize(): any;
  54720. /**
  54721. * Parse the serialized pipeline
  54722. * @param source Source pipeline.
  54723. * @param scene The scene to load the pipeline to.
  54724. * @param rootUrl The URL of the serialized pipeline.
  54725. * @returns An instantiated pipeline from the serialized object.
  54726. */
  54727. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54728. }
  54729. }
  54730. declare module "babylonjs/Shaders/ssao.fragment" {
  54731. /** @hidden */
  54732. export var ssaoPixelShader: {
  54733. name: string;
  54734. shader: string;
  54735. };
  54736. }
  54737. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54738. import { Camera } from "babylonjs/Cameras/camera";
  54739. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54740. import { Scene } from "babylonjs/scene";
  54741. import "babylonjs/Shaders/ssao.fragment";
  54742. import "babylonjs/Shaders/ssaoCombine.fragment";
  54743. /**
  54744. * Render pipeline to produce ssao effect
  54745. */
  54746. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54747. /**
  54748. * @ignore
  54749. * The PassPostProcess id in the pipeline that contains the original scene color
  54750. */
  54751. SSAOOriginalSceneColorEffect: string;
  54752. /**
  54753. * @ignore
  54754. * The SSAO PostProcess id in the pipeline
  54755. */
  54756. SSAORenderEffect: string;
  54757. /**
  54758. * @ignore
  54759. * The horizontal blur PostProcess id in the pipeline
  54760. */
  54761. SSAOBlurHRenderEffect: string;
  54762. /**
  54763. * @ignore
  54764. * The vertical blur PostProcess id in the pipeline
  54765. */
  54766. SSAOBlurVRenderEffect: string;
  54767. /**
  54768. * @ignore
  54769. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54770. */
  54771. SSAOCombineRenderEffect: string;
  54772. /**
  54773. * The output strength of the SSAO post-process. Default value is 1.0.
  54774. */
  54775. totalStrength: number;
  54776. /**
  54777. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54778. */
  54779. radius: number;
  54780. /**
  54781. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54782. * Must not be equal to fallOff and superior to fallOff.
  54783. * Default value is 0.0075
  54784. */
  54785. area: number;
  54786. /**
  54787. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54788. * Must not be equal to area and inferior to area.
  54789. * Default value is 0.000001
  54790. */
  54791. fallOff: number;
  54792. /**
  54793. * The base color of the SSAO post-process
  54794. * The final result is "base + ssao" between [0, 1]
  54795. */
  54796. base: number;
  54797. private _scene;
  54798. private _depthTexture;
  54799. private _randomTexture;
  54800. private _originalColorPostProcess;
  54801. private _ssaoPostProcess;
  54802. private _blurHPostProcess;
  54803. private _blurVPostProcess;
  54804. private _ssaoCombinePostProcess;
  54805. private _firstUpdate;
  54806. /**
  54807. * Gets active scene
  54808. */
  54809. readonly scene: Scene;
  54810. /**
  54811. * @constructor
  54812. * @param name - The rendering pipeline name
  54813. * @param scene - The scene linked to this pipeline
  54814. * @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 }
  54815. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54816. */
  54817. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54818. /**
  54819. * Get the class name
  54820. * @returns "SSAORenderingPipeline"
  54821. */
  54822. getClassName(): string;
  54823. /**
  54824. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54825. */
  54826. dispose(disableDepthRender?: boolean): void;
  54827. private _createBlurPostProcess;
  54828. /** @hidden */
  54829. _rebuild(): void;
  54830. private _createSSAOPostProcess;
  54831. private _createSSAOCombinePostProcess;
  54832. private _createRandomTexture;
  54833. }
  54834. }
  54835. declare module "babylonjs/Shaders/standard.fragment" {
  54836. /** @hidden */
  54837. export var standardPixelShader: {
  54838. name: string;
  54839. shader: string;
  54840. };
  54841. }
  54842. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54843. import { Nullable } from "babylonjs/types";
  54844. import { IAnimatable } from "babylonjs/Misc/tools";
  54845. import { Camera } from "babylonjs/Cameras/camera";
  54846. import { Texture } from "babylonjs/Materials/Textures/texture";
  54847. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54848. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54849. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54850. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54851. import { IDisposable } from "babylonjs/scene";
  54852. import { SpotLight } from "babylonjs/Lights/spotLight";
  54853. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54854. import { Scene } from "babylonjs/scene";
  54855. import { Animation } from "babylonjs/Animations/animation";
  54856. import "babylonjs/Shaders/standard.fragment";
  54857. /**
  54858. * Standard rendering pipeline
  54859. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54860. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54861. */
  54862. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54863. /**
  54864. * Public members
  54865. */
  54866. /**
  54867. * Post-process which contains the original scene color before the pipeline applies all the effects
  54868. */
  54869. originalPostProcess: Nullable<PostProcess>;
  54870. /**
  54871. * Post-process used to down scale an image x4
  54872. */
  54873. downSampleX4PostProcess: Nullable<PostProcess>;
  54874. /**
  54875. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54876. */
  54877. brightPassPostProcess: Nullable<PostProcess>;
  54878. /**
  54879. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54880. */
  54881. blurHPostProcesses: PostProcess[];
  54882. /**
  54883. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54884. */
  54885. blurVPostProcesses: PostProcess[];
  54886. /**
  54887. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54888. */
  54889. textureAdderPostProcess: Nullable<PostProcess>;
  54890. /**
  54891. * Post-process used to create volumetric lighting effect
  54892. */
  54893. volumetricLightPostProcess: Nullable<PostProcess>;
  54894. /**
  54895. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54896. */
  54897. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54898. /**
  54899. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54900. */
  54901. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54902. /**
  54903. * Post-process used to merge the volumetric light effect and the real scene color
  54904. */
  54905. volumetricLightMergePostProces: Nullable<PostProcess>;
  54906. /**
  54907. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54908. */
  54909. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54910. /**
  54911. * Base post-process used to calculate the average luminance of the final image for HDR
  54912. */
  54913. luminancePostProcess: Nullable<PostProcess>;
  54914. /**
  54915. * Post-processes used to create down sample post-processes in order to get
  54916. * the average luminance of the final image for HDR
  54917. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54918. */
  54919. luminanceDownSamplePostProcesses: PostProcess[];
  54920. /**
  54921. * Post-process used to create a HDR effect (light adaptation)
  54922. */
  54923. hdrPostProcess: Nullable<PostProcess>;
  54924. /**
  54925. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54926. */
  54927. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54928. /**
  54929. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54930. */
  54931. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54932. /**
  54933. * Post-process used to merge the final HDR post-process and the real scene color
  54934. */
  54935. hdrFinalPostProcess: Nullable<PostProcess>;
  54936. /**
  54937. * Post-process used to create a lens flare effect
  54938. */
  54939. lensFlarePostProcess: Nullable<PostProcess>;
  54940. /**
  54941. * Post-process that merges the result of the lens flare post-process and the real scene color
  54942. */
  54943. lensFlareComposePostProcess: Nullable<PostProcess>;
  54944. /**
  54945. * Post-process used to create a motion blur effect
  54946. */
  54947. motionBlurPostProcess: Nullable<PostProcess>;
  54948. /**
  54949. * Post-process used to create a depth of field effect
  54950. */
  54951. depthOfFieldPostProcess: Nullable<PostProcess>;
  54952. /**
  54953. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54954. */
  54955. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54956. /**
  54957. * Represents the brightness threshold in order to configure the illuminated surfaces
  54958. */
  54959. brightThreshold: number;
  54960. /**
  54961. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54962. */
  54963. blurWidth: number;
  54964. /**
  54965. * Sets if the blur for highlighted surfaces must be only horizontal
  54966. */
  54967. horizontalBlur: boolean;
  54968. /**
  54969. * Sets the overall exposure used by the pipeline
  54970. */
  54971. exposure: number;
  54972. /**
  54973. * Texture used typically to simulate "dirty" on camera lens
  54974. */
  54975. lensTexture: Nullable<Texture>;
  54976. /**
  54977. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54978. */
  54979. volumetricLightCoefficient: number;
  54980. /**
  54981. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54982. */
  54983. volumetricLightPower: number;
  54984. /**
  54985. * Used the set the blur intensity to smooth the volumetric lights
  54986. */
  54987. volumetricLightBlurScale: number;
  54988. /**
  54989. * Light (spot or directional) used to generate the volumetric lights rays
  54990. * The source light must have a shadow generate so the pipeline can get its
  54991. * depth map
  54992. */
  54993. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54994. /**
  54995. * For eye adaptation, represents the minimum luminance the eye can see
  54996. */
  54997. hdrMinimumLuminance: number;
  54998. /**
  54999. * For eye adaptation, represents the decrease luminance speed
  55000. */
  55001. hdrDecreaseRate: number;
  55002. /**
  55003. * For eye adaptation, represents the increase luminance speed
  55004. */
  55005. hdrIncreaseRate: number;
  55006. /**
  55007. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55008. */
  55009. lensColorTexture: Nullable<Texture>;
  55010. /**
  55011. * The overall strengh for the lens flare effect
  55012. */
  55013. lensFlareStrength: number;
  55014. /**
  55015. * Dispersion coefficient for lens flare ghosts
  55016. */
  55017. lensFlareGhostDispersal: number;
  55018. /**
  55019. * Main lens flare halo width
  55020. */
  55021. lensFlareHaloWidth: number;
  55022. /**
  55023. * Based on the lens distortion effect, defines how much the lens flare result
  55024. * is distorted
  55025. */
  55026. lensFlareDistortionStrength: number;
  55027. /**
  55028. * Lens star texture must be used to simulate rays on the flares and is available
  55029. * in the documentation
  55030. */
  55031. lensStarTexture: Nullable<Texture>;
  55032. /**
  55033. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55034. * flare effect by taking account of the dirt texture
  55035. */
  55036. lensFlareDirtTexture: Nullable<Texture>;
  55037. /**
  55038. * Represents the focal length for the depth of field effect
  55039. */
  55040. depthOfFieldDistance: number;
  55041. /**
  55042. * Represents the blur intensity for the blurred part of the depth of field effect
  55043. */
  55044. depthOfFieldBlurWidth: number;
  55045. /**
  55046. * For motion blur, defines how much the image is blurred by the movement
  55047. */
  55048. motionStrength: number;
  55049. /**
  55050. * List of animations for the pipeline (IAnimatable implementation)
  55051. */
  55052. animations: Animation[];
  55053. /**
  55054. * Private members
  55055. */
  55056. private _scene;
  55057. private _currentDepthOfFieldSource;
  55058. private _basePostProcess;
  55059. private _hdrCurrentLuminance;
  55060. private _floatTextureType;
  55061. private _ratio;
  55062. private _bloomEnabled;
  55063. private _depthOfFieldEnabled;
  55064. private _vlsEnabled;
  55065. private _lensFlareEnabled;
  55066. private _hdrEnabled;
  55067. private _motionBlurEnabled;
  55068. private _fxaaEnabled;
  55069. private _motionBlurSamples;
  55070. private _volumetricLightStepsCount;
  55071. private _samples;
  55072. /**
  55073. * @ignore
  55074. * Specifies if the bloom pipeline is enabled
  55075. */
  55076. BloomEnabled: boolean;
  55077. /**
  55078. * @ignore
  55079. * Specifies if the depth of field pipeline is enabed
  55080. */
  55081. DepthOfFieldEnabled: boolean;
  55082. /**
  55083. * @ignore
  55084. * Specifies if the lens flare pipeline is enabed
  55085. */
  55086. LensFlareEnabled: boolean;
  55087. /**
  55088. * @ignore
  55089. * Specifies if the HDR pipeline is enabled
  55090. */
  55091. HDREnabled: boolean;
  55092. /**
  55093. * @ignore
  55094. * Specifies if the volumetric lights scattering effect is enabled
  55095. */
  55096. VLSEnabled: boolean;
  55097. /**
  55098. * @ignore
  55099. * Specifies if the motion blur effect is enabled
  55100. */
  55101. MotionBlurEnabled: boolean;
  55102. /**
  55103. * Specifies if anti-aliasing is enabled
  55104. */
  55105. fxaaEnabled: boolean;
  55106. /**
  55107. * Specifies the number of steps used to calculate the volumetric lights
  55108. * Typically in interval [50, 200]
  55109. */
  55110. volumetricLightStepsCount: number;
  55111. /**
  55112. * Specifies the number of samples used for the motion blur effect
  55113. * Typically in interval [16, 64]
  55114. */
  55115. motionBlurSamples: number;
  55116. /**
  55117. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55118. */
  55119. samples: number;
  55120. /**
  55121. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55122. * @constructor
  55123. * @param name The rendering pipeline name
  55124. * @param scene The scene linked to this pipeline
  55125. * @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)
  55126. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55127. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55128. */
  55129. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55130. private _buildPipeline;
  55131. private _createDownSampleX4PostProcess;
  55132. private _createBrightPassPostProcess;
  55133. private _createBlurPostProcesses;
  55134. private _createTextureAdderPostProcess;
  55135. private _createVolumetricLightPostProcess;
  55136. private _createLuminancePostProcesses;
  55137. private _createHdrPostProcess;
  55138. private _createLensFlarePostProcess;
  55139. private _createDepthOfFieldPostProcess;
  55140. private _createMotionBlurPostProcess;
  55141. private _getDepthTexture;
  55142. private _disposePostProcesses;
  55143. /**
  55144. * Dispose of the pipeline and stop all post processes
  55145. */
  55146. dispose(): void;
  55147. /**
  55148. * Serialize the rendering pipeline (Used when exporting)
  55149. * @returns the serialized object
  55150. */
  55151. serialize(): any;
  55152. /**
  55153. * Parse the serialized pipeline
  55154. * @param source Source pipeline.
  55155. * @param scene The scene to load the pipeline to.
  55156. * @param rootUrl The URL of the serialized pipeline.
  55157. * @returns An instantiated pipeline from the serialized object.
  55158. */
  55159. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55160. /**
  55161. * Luminance steps
  55162. */
  55163. static LuminanceSteps: number;
  55164. }
  55165. }
  55166. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55167. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55168. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55169. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55170. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55171. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55172. }
  55173. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55174. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55175. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55176. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55177. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55178. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55179. }
  55180. declare module "babylonjs/Shaders/tonemap.fragment" {
  55181. /** @hidden */
  55182. export var tonemapPixelShader: {
  55183. name: string;
  55184. shader: string;
  55185. };
  55186. }
  55187. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55188. import { Camera } from "babylonjs/Cameras/camera";
  55189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55190. import "babylonjs/Shaders/tonemap.fragment";
  55191. import { Engine } from "babylonjs/Engines/engine";
  55192. /** Defines operator used for tonemapping */
  55193. export enum TonemappingOperator {
  55194. /** Hable */
  55195. Hable = 0,
  55196. /** Reinhard */
  55197. Reinhard = 1,
  55198. /** HejiDawson */
  55199. HejiDawson = 2,
  55200. /** Photographic */
  55201. Photographic = 3
  55202. }
  55203. /**
  55204. * Defines a post process to apply tone mapping
  55205. */
  55206. export class TonemapPostProcess extends PostProcess {
  55207. private _operator;
  55208. /** Defines the required exposure adjustement */
  55209. exposureAdjustment: number;
  55210. /**
  55211. * Creates a new TonemapPostProcess
  55212. * @param name defines the name of the postprocess
  55213. * @param _operator defines the operator to use
  55214. * @param exposureAdjustment defines the required exposure adjustement
  55215. * @param camera defines the camera to use (can be null)
  55216. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55217. * @param engine defines the hosting engine (can be ignore if camera is set)
  55218. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55219. */
  55220. constructor(name: string, _operator: TonemappingOperator,
  55221. /** Defines the required exposure adjustement */
  55222. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55223. }
  55224. }
  55225. declare module "babylonjs/Shaders/depth.vertex" {
  55226. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55227. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55228. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55229. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55230. /** @hidden */
  55231. export var depthVertexShader: {
  55232. name: string;
  55233. shader: string;
  55234. };
  55235. }
  55236. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55237. /** @hidden */
  55238. export var volumetricLightScatteringPixelShader: {
  55239. name: string;
  55240. shader: string;
  55241. };
  55242. }
  55243. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55244. /** @hidden */
  55245. export var volumetricLightScatteringPassPixelShader: {
  55246. name: string;
  55247. shader: string;
  55248. };
  55249. }
  55250. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55251. import { Vector3 } from "babylonjs/Maths/math";
  55252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55253. import { Mesh } from "babylonjs/Meshes/mesh";
  55254. import { Camera } from "babylonjs/Cameras/camera";
  55255. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55256. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55257. import { Scene } from "babylonjs/scene";
  55258. import "babylonjs/Meshes/Builders/planeBuilder";
  55259. import "babylonjs/Shaders/depth.vertex";
  55260. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55261. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55262. import { Engine } from "babylonjs/Engines/engine";
  55263. /**
  55264. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55265. */
  55266. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55267. private _volumetricLightScatteringPass;
  55268. private _volumetricLightScatteringRTT;
  55269. private _viewPort;
  55270. private _screenCoordinates;
  55271. private _cachedDefines;
  55272. /**
  55273. * If not undefined, the mesh position is computed from the attached node position
  55274. */
  55275. attachedNode: {
  55276. position: Vector3;
  55277. };
  55278. /**
  55279. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55280. */
  55281. customMeshPosition: Vector3;
  55282. /**
  55283. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55284. */
  55285. useCustomMeshPosition: boolean;
  55286. /**
  55287. * If the post-process should inverse the light scattering direction
  55288. */
  55289. invert: boolean;
  55290. /**
  55291. * The internal mesh used by the post-process
  55292. */
  55293. mesh: Mesh;
  55294. /**
  55295. * @hidden
  55296. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55297. */
  55298. useDiffuseColor: boolean;
  55299. /**
  55300. * Array containing the excluded meshes not rendered in the internal pass
  55301. */
  55302. excludedMeshes: AbstractMesh[];
  55303. /**
  55304. * Controls the overall intensity of the post-process
  55305. */
  55306. exposure: number;
  55307. /**
  55308. * Dissipates each sample's contribution in range [0, 1]
  55309. */
  55310. decay: number;
  55311. /**
  55312. * Controls the overall intensity of each sample
  55313. */
  55314. weight: number;
  55315. /**
  55316. * Controls the density of each sample
  55317. */
  55318. density: number;
  55319. /**
  55320. * @constructor
  55321. * @param name The post-process name
  55322. * @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)
  55323. * @param camera The camera that the post-process will be attached to
  55324. * @param mesh The mesh used to create the light scattering
  55325. * @param samples The post-process quality, default 100
  55326. * @param samplingModeThe post-process filtering mode
  55327. * @param engine The babylon engine
  55328. * @param reusable If the post-process is reusable
  55329. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55330. */
  55331. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55332. /**
  55333. * Returns the string "VolumetricLightScatteringPostProcess"
  55334. * @returns "VolumetricLightScatteringPostProcess"
  55335. */
  55336. getClassName(): string;
  55337. private _isReady;
  55338. /**
  55339. * Sets the new light position for light scattering effect
  55340. * @param position The new custom light position
  55341. */
  55342. setCustomMeshPosition(position: Vector3): void;
  55343. /**
  55344. * Returns the light position for light scattering effect
  55345. * @return Vector3 The custom light position
  55346. */
  55347. getCustomMeshPosition(): Vector3;
  55348. /**
  55349. * Disposes the internal assets and detaches the post-process from the camera
  55350. */
  55351. dispose(camera: Camera): void;
  55352. /**
  55353. * Returns the render target texture used by the post-process
  55354. * @return the render target texture used by the post-process
  55355. */
  55356. getPass(): RenderTargetTexture;
  55357. private _meshExcluded;
  55358. private _createPass;
  55359. private _updateMeshScreenCoordinates;
  55360. /**
  55361. * Creates a default mesh for the Volumeric Light Scattering post-process
  55362. * @param name The mesh name
  55363. * @param scene The scene where to create the mesh
  55364. * @return the default mesh
  55365. */
  55366. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55367. }
  55368. }
  55369. declare module "babylonjs/PostProcesses/index" {
  55370. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55371. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55372. export * from "babylonjs/PostProcesses/bloomEffect";
  55373. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55374. export * from "babylonjs/PostProcesses/blurPostProcess";
  55375. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55376. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55377. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55378. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55379. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55380. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55381. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55382. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55383. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55384. export * from "babylonjs/PostProcesses/filterPostProcess";
  55385. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55386. export * from "babylonjs/PostProcesses/grainPostProcess";
  55387. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55388. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55389. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55390. export * from "babylonjs/PostProcesses/passPostProcess";
  55391. export * from "babylonjs/PostProcesses/postProcess";
  55392. export * from "babylonjs/PostProcesses/postProcessManager";
  55393. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55394. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55395. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55396. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55397. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55398. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55399. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55400. }
  55401. declare module "babylonjs/Probes/index" {
  55402. export * from "babylonjs/Probes/reflectionProbe";
  55403. }
  55404. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55405. import { Scene } from "babylonjs/scene";
  55406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55407. import { Color3 } from "babylonjs/Maths/math";
  55408. import { SmartArray } from "babylonjs/Misc/smartArray";
  55409. import { ISceneComponent } from "babylonjs/sceneComponent";
  55410. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55411. import "babylonjs/Meshes/Builders/boxBuilder";
  55412. import "babylonjs/Shaders/color.fragment";
  55413. import "babylonjs/Shaders/color.vertex";
  55414. module "babylonjs/scene" {
  55415. interface Scene {
  55416. /** @hidden (Backing field) */
  55417. _boundingBoxRenderer: BoundingBoxRenderer;
  55418. /** @hidden (Backing field) */
  55419. _forceShowBoundingBoxes: boolean;
  55420. /**
  55421. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55422. */
  55423. forceShowBoundingBoxes: boolean;
  55424. /**
  55425. * Gets the bounding box renderer associated with the scene
  55426. * @returns a BoundingBoxRenderer
  55427. */
  55428. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55429. }
  55430. }
  55431. module "babylonjs/Meshes/abstractMesh" {
  55432. interface AbstractMesh {
  55433. /** @hidden (Backing field) */
  55434. _showBoundingBox: boolean;
  55435. /**
  55436. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55437. */
  55438. showBoundingBox: boolean;
  55439. }
  55440. }
  55441. /**
  55442. * Component responsible of rendering the bounding box of the meshes in a scene.
  55443. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55444. */
  55445. export class BoundingBoxRenderer implements ISceneComponent {
  55446. /**
  55447. * The component name helpfull to identify the component in the list of scene components.
  55448. */
  55449. readonly name: string;
  55450. /**
  55451. * The scene the component belongs to.
  55452. */
  55453. scene: Scene;
  55454. /**
  55455. * Color of the bounding box lines placed in front of an object
  55456. */
  55457. frontColor: Color3;
  55458. /**
  55459. * Color of the bounding box lines placed behind an object
  55460. */
  55461. backColor: Color3;
  55462. /**
  55463. * Defines if the renderer should show the back lines or not
  55464. */
  55465. showBackLines: boolean;
  55466. /**
  55467. * @hidden
  55468. */
  55469. renderList: SmartArray<BoundingBox>;
  55470. private _colorShader;
  55471. private _vertexBuffers;
  55472. private _indexBuffer;
  55473. /**
  55474. * Instantiates a new bounding box renderer in a scene.
  55475. * @param scene the scene the renderer renders in
  55476. */
  55477. constructor(scene: Scene);
  55478. /**
  55479. * Registers the component in a given scene
  55480. */
  55481. register(): void;
  55482. private _evaluateSubMesh;
  55483. private _activeMesh;
  55484. private _prepareRessources;
  55485. private _createIndexBuffer;
  55486. /**
  55487. * Rebuilds the elements related to this component in case of
  55488. * context lost for instance.
  55489. */
  55490. rebuild(): void;
  55491. /**
  55492. * @hidden
  55493. */
  55494. reset(): void;
  55495. /**
  55496. * Render the bounding boxes of a specific rendering group
  55497. * @param renderingGroupId defines the rendering group to render
  55498. */
  55499. render(renderingGroupId: number): void;
  55500. /**
  55501. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55502. * @param mesh Define the mesh to render the occlusion bounding box for
  55503. */
  55504. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55505. /**
  55506. * Dispose and release the resources attached to this renderer.
  55507. */
  55508. dispose(): void;
  55509. }
  55510. }
  55511. declare module "babylonjs/Shaders/depth.fragment" {
  55512. /** @hidden */
  55513. export var depthPixelShader: {
  55514. name: string;
  55515. shader: string;
  55516. };
  55517. }
  55518. declare module "babylonjs/Rendering/depthRenderer" {
  55519. import { Nullable } from "babylonjs/types";
  55520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55521. import { Scene } from "babylonjs/scene";
  55522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55523. import { Camera } from "babylonjs/Cameras/camera";
  55524. import "babylonjs/Shaders/depth.fragment";
  55525. import "babylonjs/Shaders/depth.vertex";
  55526. /**
  55527. * This represents a depth renderer in Babylon.
  55528. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55529. */
  55530. export class DepthRenderer {
  55531. private _scene;
  55532. private _depthMap;
  55533. private _effect;
  55534. private _cachedDefines;
  55535. private _camera;
  55536. /**
  55537. * Specifiess that the depth renderer will only be used within
  55538. * the camera it is created for.
  55539. * This can help forcing its rendering during the camera processing.
  55540. */
  55541. useOnlyInActiveCamera: boolean;
  55542. /** @hidden */
  55543. static _SceneComponentInitialization: (scene: Scene) => void;
  55544. /**
  55545. * Instantiates a depth renderer
  55546. * @param scene The scene the renderer belongs to
  55547. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55548. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55549. */
  55550. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55551. /**
  55552. * Creates the depth rendering effect and checks if the effect is ready.
  55553. * @param subMesh The submesh to be used to render the depth map of
  55554. * @param useInstances If multiple world instances should be used
  55555. * @returns if the depth renderer is ready to render the depth map
  55556. */
  55557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55558. /**
  55559. * Gets the texture which the depth map will be written to.
  55560. * @returns The depth map texture
  55561. */
  55562. getDepthMap(): RenderTargetTexture;
  55563. /**
  55564. * Disposes of the depth renderer.
  55565. */
  55566. dispose(): void;
  55567. }
  55568. }
  55569. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55570. import { Nullable } from "babylonjs/types";
  55571. import { Scene } from "babylonjs/scene";
  55572. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55573. import { Camera } from "babylonjs/Cameras/camera";
  55574. import { ISceneComponent } from "babylonjs/sceneComponent";
  55575. module "babylonjs/scene" {
  55576. interface Scene {
  55577. /** @hidden (Backing field) */
  55578. _depthRenderer: {
  55579. [id: string]: DepthRenderer;
  55580. };
  55581. /**
  55582. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55583. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55584. * @returns the created depth renderer
  55585. */
  55586. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55587. /**
  55588. * Disables a depth renderer for a given camera
  55589. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55590. */
  55591. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55592. }
  55593. }
  55594. /**
  55595. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55596. * in several rendering techniques.
  55597. */
  55598. export class DepthRendererSceneComponent implements ISceneComponent {
  55599. /**
  55600. * The component name helpfull to identify the component in the list of scene components.
  55601. */
  55602. readonly name: string;
  55603. /**
  55604. * The scene the component belongs to.
  55605. */
  55606. scene: Scene;
  55607. /**
  55608. * Creates a new instance of the component for the given scene
  55609. * @param scene Defines the scene to register the component in
  55610. */
  55611. constructor(scene: Scene);
  55612. /**
  55613. * Registers the component in a given scene
  55614. */
  55615. register(): void;
  55616. /**
  55617. * Rebuilds the elements related to this component in case of
  55618. * context lost for instance.
  55619. */
  55620. rebuild(): void;
  55621. /**
  55622. * Disposes the component and the associated ressources
  55623. */
  55624. dispose(): void;
  55625. private _gatherRenderTargets;
  55626. private _gatherActiveCameraRenderTargets;
  55627. }
  55628. }
  55629. declare module "babylonjs/Shaders/outline.fragment" {
  55630. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55631. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55632. /** @hidden */
  55633. export var outlinePixelShader: {
  55634. name: string;
  55635. shader: string;
  55636. };
  55637. }
  55638. declare module "babylonjs/Shaders/outline.vertex" {
  55639. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55641. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55642. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55643. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55644. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55645. /** @hidden */
  55646. export var outlineVertexShader: {
  55647. name: string;
  55648. shader: string;
  55649. };
  55650. }
  55651. declare module "babylonjs/Rendering/outlineRenderer" {
  55652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55653. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55654. import { Scene } from "babylonjs/scene";
  55655. import { ISceneComponent } from "babylonjs/sceneComponent";
  55656. import "babylonjs/Shaders/outline.fragment";
  55657. import "babylonjs/Shaders/outline.vertex";
  55658. module "babylonjs/scene" {
  55659. interface Scene {
  55660. /** @hidden */
  55661. _outlineRenderer: OutlineRenderer;
  55662. /**
  55663. * Gets the outline renderer associated with the scene
  55664. * @returns a OutlineRenderer
  55665. */
  55666. getOutlineRenderer(): OutlineRenderer;
  55667. }
  55668. }
  55669. module "babylonjs/Meshes/abstractMesh" {
  55670. interface AbstractMesh {
  55671. /** @hidden (Backing field) */
  55672. _renderOutline: boolean;
  55673. /**
  55674. * Gets or sets a boolean indicating if the outline must be rendered as well
  55675. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55676. */
  55677. renderOutline: boolean;
  55678. /** @hidden (Backing field) */
  55679. _renderOverlay: boolean;
  55680. /**
  55681. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55682. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55683. */
  55684. renderOverlay: boolean;
  55685. }
  55686. }
  55687. /**
  55688. * This class is responsible to draw bothe outline/overlay of meshes.
  55689. * It should not be used directly but through the available method on mesh.
  55690. */
  55691. export class OutlineRenderer implements ISceneComponent {
  55692. /**
  55693. * The name of the component. Each component must have a unique name.
  55694. */
  55695. name: string;
  55696. /**
  55697. * The scene the component belongs to.
  55698. */
  55699. scene: Scene;
  55700. /**
  55701. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55702. */
  55703. zOffset: number;
  55704. private _engine;
  55705. private _effect;
  55706. private _cachedDefines;
  55707. private _savedDepthWrite;
  55708. /**
  55709. * Instantiates a new outline renderer. (There could be only one per scene).
  55710. * @param scene Defines the scene it belongs to
  55711. */
  55712. constructor(scene: Scene);
  55713. /**
  55714. * Register the component to one instance of a scene.
  55715. */
  55716. register(): void;
  55717. /**
  55718. * Rebuilds the elements related to this component in case of
  55719. * context lost for instance.
  55720. */
  55721. rebuild(): void;
  55722. /**
  55723. * Disposes the component and the associated ressources.
  55724. */
  55725. dispose(): void;
  55726. /**
  55727. * Renders the outline in the canvas.
  55728. * @param subMesh Defines the sumesh to render
  55729. * @param batch Defines the batch of meshes in case of instances
  55730. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55731. */
  55732. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55733. /**
  55734. * Returns whether or not the outline renderer is ready for a given submesh.
  55735. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55736. * @param subMesh Defines the submesh to check readyness for
  55737. * @param useInstances Defines wheter wee are trying to render instances or not
  55738. * @returns true if ready otherwise false
  55739. */
  55740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55741. private _beforeRenderingMesh;
  55742. private _afterRenderingMesh;
  55743. }
  55744. }
  55745. declare module "babylonjs/Rendering/index" {
  55746. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55747. export * from "babylonjs/Rendering/depthRenderer";
  55748. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55749. export * from "babylonjs/Rendering/edgesRenderer";
  55750. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55751. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55752. export * from "babylonjs/Rendering/outlineRenderer";
  55753. export * from "babylonjs/Rendering/renderingGroup";
  55754. export * from "babylonjs/Rendering/renderingManager";
  55755. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55756. }
  55757. declare module "babylonjs/Sprites/index" {
  55758. export * from "babylonjs/Sprites/sprite";
  55759. export * from "babylonjs/Sprites/spriteManager";
  55760. export * from "babylonjs/Sprites/spriteSceneComponent";
  55761. }
  55762. declare module "babylonjs/Misc/assetsManager" {
  55763. import { Scene } from "babylonjs/scene";
  55764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55765. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55766. import { Skeleton } from "babylonjs/Bones/skeleton";
  55767. import { Observable } from "babylonjs/Misc/observable";
  55768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55769. import { Texture } from "babylonjs/Materials/Textures/texture";
  55770. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55771. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55772. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55773. /**
  55774. * Defines the list of states available for a task inside a AssetsManager
  55775. */
  55776. export enum AssetTaskState {
  55777. /**
  55778. * Initialization
  55779. */
  55780. INIT = 0,
  55781. /**
  55782. * Running
  55783. */
  55784. RUNNING = 1,
  55785. /**
  55786. * Done
  55787. */
  55788. DONE = 2,
  55789. /**
  55790. * Error
  55791. */
  55792. ERROR = 3
  55793. }
  55794. /**
  55795. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55796. */
  55797. export abstract class AbstractAssetTask {
  55798. /**
  55799. * Task name
  55800. */ name: string;
  55801. /**
  55802. * Callback called when the task is successful
  55803. */
  55804. onSuccess: (task: any) => void;
  55805. /**
  55806. * Callback called when the task is not successful
  55807. */
  55808. onError: (task: any, message?: string, exception?: any) => void;
  55809. /**
  55810. * Creates a new AssetsManager
  55811. * @param name defines the name of the task
  55812. */
  55813. constructor(
  55814. /**
  55815. * Task name
  55816. */ name: string);
  55817. private _isCompleted;
  55818. private _taskState;
  55819. private _errorObject;
  55820. /**
  55821. * Get if the task is completed
  55822. */
  55823. readonly isCompleted: boolean;
  55824. /**
  55825. * Gets the current state of the task
  55826. */
  55827. readonly taskState: AssetTaskState;
  55828. /**
  55829. * Gets the current error object (if task is in error)
  55830. */
  55831. readonly errorObject: {
  55832. message?: string;
  55833. exception?: any;
  55834. };
  55835. /**
  55836. * Internal only
  55837. * @hidden
  55838. */
  55839. _setErrorObject(message?: string, exception?: any): void;
  55840. /**
  55841. * Execute the current task
  55842. * @param scene defines the scene where you want your assets to be loaded
  55843. * @param onSuccess is a callback called when the task is successfully executed
  55844. * @param onError is a callback called if an error occurs
  55845. */
  55846. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55847. /**
  55848. * Execute the current task
  55849. * @param scene defines the scene where you want your assets to be loaded
  55850. * @param onSuccess is a callback called when the task is successfully executed
  55851. * @param onError is a callback called if an error occurs
  55852. */
  55853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55854. /**
  55855. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55856. * This can be used with failed tasks that have the reason for failure fixed.
  55857. */
  55858. reset(): void;
  55859. private onErrorCallback;
  55860. private onDoneCallback;
  55861. }
  55862. /**
  55863. * Define the interface used by progress events raised during assets loading
  55864. */
  55865. export interface IAssetsProgressEvent {
  55866. /**
  55867. * Defines the number of remaining tasks to process
  55868. */
  55869. remainingCount: number;
  55870. /**
  55871. * Defines the total number of tasks
  55872. */
  55873. totalCount: number;
  55874. /**
  55875. * Defines the task that was just processed
  55876. */
  55877. task: AbstractAssetTask;
  55878. }
  55879. /**
  55880. * Class used to share progress information about assets loading
  55881. */
  55882. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55883. /**
  55884. * Defines the number of remaining tasks to process
  55885. */
  55886. remainingCount: number;
  55887. /**
  55888. * Defines the total number of tasks
  55889. */
  55890. totalCount: number;
  55891. /**
  55892. * Defines the task that was just processed
  55893. */
  55894. task: AbstractAssetTask;
  55895. /**
  55896. * Creates a AssetsProgressEvent
  55897. * @param remainingCount defines the number of remaining tasks to process
  55898. * @param totalCount defines the total number of tasks
  55899. * @param task defines the task that was just processed
  55900. */
  55901. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55902. }
  55903. /**
  55904. * Define a task used by AssetsManager to load meshes
  55905. */
  55906. export class MeshAssetTask extends AbstractAssetTask {
  55907. /**
  55908. * Defines the name of the task
  55909. */
  55910. name: string;
  55911. /**
  55912. * Defines the list of mesh's names you want to load
  55913. */
  55914. meshesNames: any;
  55915. /**
  55916. * Defines the root url to use as a base to load your meshes and associated resources
  55917. */
  55918. rootUrl: string;
  55919. /**
  55920. * Defines the filename of the scene to load from
  55921. */
  55922. sceneFilename: string;
  55923. /**
  55924. * Gets the list of loaded meshes
  55925. */
  55926. loadedMeshes: Array<AbstractMesh>;
  55927. /**
  55928. * Gets the list of loaded particle systems
  55929. */
  55930. loadedParticleSystems: Array<IParticleSystem>;
  55931. /**
  55932. * Gets the list of loaded skeletons
  55933. */
  55934. loadedSkeletons: Array<Skeleton>;
  55935. /**
  55936. * Gets the list of loaded animation groups
  55937. */
  55938. loadedAnimationGroups: Array<AnimationGroup>;
  55939. /**
  55940. * Callback called when the task is successful
  55941. */
  55942. onSuccess: (task: MeshAssetTask) => void;
  55943. /**
  55944. * Callback called when the task is successful
  55945. */
  55946. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55947. /**
  55948. * Creates a new MeshAssetTask
  55949. * @param name defines the name of the task
  55950. * @param meshesNames defines the list of mesh's names you want to load
  55951. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55952. * @param sceneFilename defines the filename of the scene to load from
  55953. */
  55954. constructor(
  55955. /**
  55956. * Defines the name of the task
  55957. */
  55958. name: string,
  55959. /**
  55960. * Defines the list of mesh's names you want to load
  55961. */
  55962. meshesNames: any,
  55963. /**
  55964. * Defines the root url to use as a base to load your meshes and associated resources
  55965. */
  55966. rootUrl: string,
  55967. /**
  55968. * Defines the filename of the scene to load from
  55969. */
  55970. sceneFilename: string);
  55971. /**
  55972. * Execute the current task
  55973. * @param scene defines the scene where you want your assets to be loaded
  55974. * @param onSuccess is a callback called when the task is successfully executed
  55975. * @param onError is a callback called if an error occurs
  55976. */
  55977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55978. }
  55979. /**
  55980. * Define a task used by AssetsManager to load text content
  55981. */
  55982. export class TextFileAssetTask extends AbstractAssetTask {
  55983. /**
  55984. * Defines the name of the task
  55985. */
  55986. name: string;
  55987. /**
  55988. * Defines the location of the file to load
  55989. */
  55990. url: string;
  55991. /**
  55992. * Gets the loaded text string
  55993. */
  55994. text: string;
  55995. /**
  55996. * Callback called when the task is successful
  55997. */
  55998. onSuccess: (task: TextFileAssetTask) => void;
  55999. /**
  56000. * Callback called when the task is successful
  56001. */
  56002. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56003. /**
  56004. * Creates a new TextFileAssetTask object
  56005. * @param name defines the name of the task
  56006. * @param url defines the location of the file to load
  56007. */
  56008. constructor(
  56009. /**
  56010. * Defines the name of the task
  56011. */
  56012. name: string,
  56013. /**
  56014. * Defines the location of the file to load
  56015. */
  56016. url: string);
  56017. /**
  56018. * Execute the current task
  56019. * @param scene defines the scene where you want your assets to be loaded
  56020. * @param onSuccess is a callback called when the task is successfully executed
  56021. * @param onError is a callback called if an error occurs
  56022. */
  56023. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56024. }
  56025. /**
  56026. * Define a task used by AssetsManager to load binary data
  56027. */
  56028. export class BinaryFileAssetTask extends AbstractAssetTask {
  56029. /**
  56030. * Defines the name of the task
  56031. */
  56032. name: string;
  56033. /**
  56034. * Defines the location of the file to load
  56035. */
  56036. url: string;
  56037. /**
  56038. * Gets the lodaded data (as an array buffer)
  56039. */
  56040. data: ArrayBuffer;
  56041. /**
  56042. * Callback called when the task is successful
  56043. */
  56044. onSuccess: (task: BinaryFileAssetTask) => void;
  56045. /**
  56046. * Callback called when the task is successful
  56047. */
  56048. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56049. /**
  56050. * Creates a new BinaryFileAssetTask object
  56051. * @param name defines the name of the new task
  56052. * @param url defines the location of the file to load
  56053. */
  56054. constructor(
  56055. /**
  56056. * Defines the name of the task
  56057. */
  56058. name: string,
  56059. /**
  56060. * Defines the location of the file to load
  56061. */
  56062. url: string);
  56063. /**
  56064. * Execute the current task
  56065. * @param scene defines the scene where you want your assets to be loaded
  56066. * @param onSuccess is a callback called when the task is successfully executed
  56067. * @param onError is a callback called if an error occurs
  56068. */
  56069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56070. }
  56071. /**
  56072. * Define a task used by AssetsManager to load images
  56073. */
  56074. export class ImageAssetTask extends AbstractAssetTask {
  56075. /**
  56076. * Defines the name of the task
  56077. */
  56078. name: string;
  56079. /**
  56080. * Defines the location of the image to load
  56081. */
  56082. url: string;
  56083. /**
  56084. * Gets the loaded images
  56085. */
  56086. image: HTMLImageElement;
  56087. /**
  56088. * Callback called when the task is successful
  56089. */
  56090. onSuccess: (task: ImageAssetTask) => void;
  56091. /**
  56092. * Callback called when the task is successful
  56093. */
  56094. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56095. /**
  56096. * Creates a new ImageAssetTask
  56097. * @param name defines the name of the task
  56098. * @param url defines the location of the image to load
  56099. */
  56100. constructor(
  56101. /**
  56102. * Defines the name of the task
  56103. */
  56104. name: string,
  56105. /**
  56106. * Defines the location of the image to load
  56107. */
  56108. url: string);
  56109. /**
  56110. * Execute the current task
  56111. * @param scene defines the scene where you want your assets to be loaded
  56112. * @param onSuccess is a callback called when the task is successfully executed
  56113. * @param onError is a callback called if an error occurs
  56114. */
  56115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56116. }
  56117. /**
  56118. * Defines the interface used by texture loading tasks
  56119. */
  56120. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56121. /**
  56122. * Gets the loaded texture
  56123. */
  56124. texture: TEX;
  56125. }
  56126. /**
  56127. * Define a task used by AssetsManager to load 2D textures
  56128. */
  56129. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56130. /**
  56131. * Defines the name of the task
  56132. */
  56133. name: string;
  56134. /**
  56135. * Defines the location of the file to load
  56136. */
  56137. url: string;
  56138. /**
  56139. * Defines if mipmap should not be generated (default is false)
  56140. */
  56141. noMipmap?: boolean | undefined;
  56142. /**
  56143. * Defines if texture must be inverted on Y axis (default is false)
  56144. */
  56145. invertY?: boolean | undefined;
  56146. /**
  56147. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56148. */
  56149. samplingMode: number;
  56150. /**
  56151. * Gets the loaded texture
  56152. */
  56153. texture: Texture;
  56154. /**
  56155. * Callback called when the task is successful
  56156. */
  56157. onSuccess: (task: TextureAssetTask) => void;
  56158. /**
  56159. * Callback called when the task is successful
  56160. */
  56161. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56162. /**
  56163. * Creates a new TextureAssetTask object
  56164. * @param name defines the name of the task
  56165. * @param url defines the location of the file to load
  56166. * @param noMipmap defines if mipmap should not be generated (default is false)
  56167. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56168. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56169. */
  56170. constructor(
  56171. /**
  56172. * Defines the name of the task
  56173. */
  56174. name: string,
  56175. /**
  56176. * Defines the location of the file to load
  56177. */
  56178. url: string,
  56179. /**
  56180. * Defines if mipmap should not be generated (default is false)
  56181. */
  56182. noMipmap?: boolean | undefined,
  56183. /**
  56184. * Defines if texture must be inverted on Y axis (default is false)
  56185. */
  56186. invertY?: boolean | undefined,
  56187. /**
  56188. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56189. */
  56190. samplingMode?: number);
  56191. /**
  56192. * Execute the current task
  56193. * @param scene defines the scene where you want your assets to be loaded
  56194. * @param onSuccess is a callback called when the task is successfully executed
  56195. * @param onError is a callback called if an error occurs
  56196. */
  56197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56198. }
  56199. /**
  56200. * Define a task used by AssetsManager to load cube textures
  56201. */
  56202. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56203. /**
  56204. * Defines the name of the task
  56205. */
  56206. name: string;
  56207. /**
  56208. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56209. */
  56210. url: string;
  56211. /**
  56212. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56213. */
  56214. extensions?: string[] | undefined;
  56215. /**
  56216. * Defines if mipmaps should not be generated (default is false)
  56217. */
  56218. noMipmap?: boolean | undefined;
  56219. /**
  56220. * Defines the explicit list of files (undefined by default)
  56221. */
  56222. files?: string[] | undefined;
  56223. /**
  56224. * Gets the loaded texture
  56225. */
  56226. texture: CubeTexture;
  56227. /**
  56228. * Callback called when the task is successful
  56229. */
  56230. onSuccess: (task: CubeTextureAssetTask) => void;
  56231. /**
  56232. * Callback called when the task is successful
  56233. */
  56234. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56235. /**
  56236. * Creates a new CubeTextureAssetTask
  56237. * @param name defines the name of the task
  56238. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56239. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56240. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56241. * @param files defines the explicit list of files (undefined by default)
  56242. */
  56243. constructor(
  56244. /**
  56245. * Defines the name of the task
  56246. */
  56247. name: string,
  56248. /**
  56249. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56250. */
  56251. url: string,
  56252. /**
  56253. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56254. */
  56255. extensions?: string[] | undefined,
  56256. /**
  56257. * Defines if mipmaps should not be generated (default is false)
  56258. */
  56259. noMipmap?: boolean | undefined,
  56260. /**
  56261. * Defines the explicit list of files (undefined by default)
  56262. */
  56263. files?: string[] | undefined);
  56264. /**
  56265. * Execute the current task
  56266. * @param scene defines the scene where you want your assets to be loaded
  56267. * @param onSuccess is a callback called when the task is successfully executed
  56268. * @param onError is a callback called if an error occurs
  56269. */
  56270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56271. }
  56272. /**
  56273. * Define a task used by AssetsManager to load HDR cube textures
  56274. */
  56275. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56276. /**
  56277. * Defines the name of the task
  56278. */
  56279. name: string;
  56280. /**
  56281. * Defines the location of the file to load
  56282. */
  56283. url: string;
  56284. /**
  56285. * Defines the desired size (the more it increases the longer the generation will be)
  56286. */
  56287. size: number;
  56288. /**
  56289. * Defines if mipmaps should not be generated (default is false)
  56290. */
  56291. noMipmap: boolean;
  56292. /**
  56293. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56294. */
  56295. generateHarmonics: boolean;
  56296. /**
  56297. * 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)
  56298. */
  56299. gammaSpace: boolean;
  56300. /**
  56301. * Internal Use Only
  56302. */
  56303. reserved: boolean;
  56304. /**
  56305. * Gets the loaded texture
  56306. */
  56307. texture: HDRCubeTexture;
  56308. /**
  56309. * Callback called when the task is successful
  56310. */
  56311. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56312. /**
  56313. * Callback called when the task is successful
  56314. */
  56315. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56316. /**
  56317. * Creates a new HDRCubeTextureAssetTask object
  56318. * @param name defines the name of the task
  56319. * @param url defines the location of the file to load
  56320. * @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.
  56321. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56322. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56323. * @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)
  56324. * @param reserved Internal use only
  56325. */
  56326. constructor(
  56327. /**
  56328. * Defines the name of the task
  56329. */
  56330. name: string,
  56331. /**
  56332. * Defines the location of the file to load
  56333. */
  56334. url: string,
  56335. /**
  56336. * Defines the desired size (the more it increases the longer the generation will be)
  56337. */
  56338. size: number,
  56339. /**
  56340. * Defines if mipmaps should not be generated (default is false)
  56341. */
  56342. noMipmap?: boolean,
  56343. /**
  56344. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56345. */
  56346. generateHarmonics?: boolean,
  56347. /**
  56348. * 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)
  56349. */
  56350. gammaSpace?: boolean,
  56351. /**
  56352. * Internal Use Only
  56353. */
  56354. reserved?: boolean);
  56355. /**
  56356. * Execute the current task
  56357. * @param scene defines the scene where you want your assets to be loaded
  56358. * @param onSuccess is a callback called when the task is successfully executed
  56359. * @param onError is a callback called if an error occurs
  56360. */
  56361. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56362. }
  56363. /**
  56364. * This class can be used to easily import assets into a scene
  56365. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56366. */
  56367. export class AssetsManager {
  56368. private _scene;
  56369. private _isLoading;
  56370. protected _tasks: AbstractAssetTask[];
  56371. protected _waitingTasksCount: number;
  56372. protected _totalTasksCount: number;
  56373. /**
  56374. * Callback called when all tasks are processed
  56375. */
  56376. onFinish: (tasks: AbstractAssetTask[]) => void;
  56377. /**
  56378. * Callback called when a task is successful
  56379. */
  56380. onTaskSuccess: (task: AbstractAssetTask) => void;
  56381. /**
  56382. * Callback called when a task had an error
  56383. */
  56384. onTaskError: (task: AbstractAssetTask) => void;
  56385. /**
  56386. * Callback called when a task is done (whatever the result is)
  56387. */
  56388. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56389. /**
  56390. * Observable called when all tasks are processed
  56391. */
  56392. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56393. /**
  56394. * Observable called when a task had an error
  56395. */
  56396. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56397. /**
  56398. * Observable called when all tasks were executed
  56399. */
  56400. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56401. /**
  56402. * Observable called when a task is done (whatever the result is)
  56403. */
  56404. onProgressObservable: Observable<IAssetsProgressEvent>;
  56405. /**
  56406. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56407. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56408. */
  56409. useDefaultLoadingScreen: boolean;
  56410. /**
  56411. * Creates a new AssetsManager
  56412. * @param scene defines the scene to work on
  56413. */
  56414. constructor(scene: Scene);
  56415. /**
  56416. * Add a MeshAssetTask to the list of active tasks
  56417. * @param taskName defines the name of the new task
  56418. * @param meshesNames defines the name of meshes to load
  56419. * @param rootUrl defines the root url to use to locate files
  56420. * @param sceneFilename defines the filename of the scene file
  56421. * @returns a new MeshAssetTask object
  56422. */
  56423. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56424. /**
  56425. * Add a TextFileAssetTask to the list of active tasks
  56426. * @param taskName defines the name of the new task
  56427. * @param url defines the url of the file to load
  56428. * @returns a new TextFileAssetTask object
  56429. */
  56430. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56431. /**
  56432. * Add a BinaryFileAssetTask to the list of active tasks
  56433. * @param taskName defines the name of the new task
  56434. * @param url defines the url of the file to load
  56435. * @returns a new BinaryFileAssetTask object
  56436. */
  56437. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56438. /**
  56439. * Add a ImageAssetTask to the list of active tasks
  56440. * @param taskName defines the name of the new task
  56441. * @param url defines the url of the file to load
  56442. * @returns a new ImageAssetTask object
  56443. */
  56444. addImageTask(taskName: string, url: string): ImageAssetTask;
  56445. /**
  56446. * Add a TextureAssetTask to the list of active tasks
  56447. * @param taskName defines the name of the new task
  56448. * @param url defines the url of the file to load
  56449. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56450. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56451. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56452. * @returns a new TextureAssetTask object
  56453. */
  56454. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56455. /**
  56456. * Add a CubeTextureAssetTask to the list of active tasks
  56457. * @param taskName defines the name of the new task
  56458. * @param url defines the url of the file to load
  56459. * @param extensions defines the extension to use to load the cube map (can be null)
  56460. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56461. * @param files defines the list of files to load (can be null)
  56462. * @returns a new CubeTextureAssetTask object
  56463. */
  56464. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56465. /**
  56466. *
  56467. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56468. * @param taskName defines the name of the new task
  56469. * @param url defines the url of the file to load
  56470. * @param size defines the size you want for the cubemap (can be null)
  56471. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56472. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56473. * @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)
  56474. * @param reserved Internal use only
  56475. * @returns a new HDRCubeTextureAssetTask object
  56476. */
  56477. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56478. /**
  56479. * Remove a task from the assets manager.
  56480. * @param task the task to remove
  56481. */
  56482. removeTask(task: AbstractAssetTask): void;
  56483. private _decreaseWaitingTasksCount;
  56484. private _runTask;
  56485. /**
  56486. * Reset the AssetsManager and remove all tasks
  56487. * @return the current instance of the AssetsManager
  56488. */
  56489. reset(): AssetsManager;
  56490. /**
  56491. * Start the loading process
  56492. * @return the current instance of the AssetsManager
  56493. */
  56494. load(): AssetsManager;
  56495. /**
  56496. * Start the loading process as an async operation
  56497. * @return a promise returning the list of failed tasks
  56498. */
  56499. loadAsync(): Promise<void>;
  56500. }
  56501. }
  56502. declare module "babylonjs/Misc/deferred" {
  56503. /**
  56504. * Wrapper class for promise with external resolve and reject.
  56505. */
  56506. export class Deferred<T> {
  56507. /**
  56508. * The promise associated with this deferred object.
  56509. */
  56510. readonly promise: Promise<T>;
  56511. private _resolve;
  56512. private _reject;
  56513. /**
  56514. * The resolve method of the promise associated with this deferred object.
  56515. */
  56516. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56517. /**
  56518. * The reject method of the promise associated with this deferred object.
  56519. */
  56520. readonly reject: (reason?: any) => void;
  56521. /**
  56522. * Constructor for this deferred object.
  56523. */
  56524. constructor();
  56525. }
  56526. }
  56527. declare module "babylonjs/Misc/meshExploder" {
  56528. import { Mesh } from "babylonjs/Meshes/mesh";
  56529. /**
  56530. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56531. */
  56532. export class MeshExploder {
  56533. private _centerMesh;
  56534. private _meshes;
  56535. private _meshesOrigins;
  56536. private _toCenterVectors;
  56537. private _scaledDirection;
  56538. private _newPosition;
  56539. private _centerPosition;
  56540. /**
  56541. * Explodes meshes from a center mesh.
  56542. * @param meshes The meshes to explode.
  56543. * @param centerMesh The mesh to be center of explosion.
  56544. */
  56545. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56546. private _setCenterMesh;
  56547. /**
  56548. * Get class name
  56549. * @returns "MeshExploder"
  56550. */
  56551. getClassName(): string;
  56552. /**
  56553. * "Exploded meshes"
  56554. * @returns Array of meshes with the centerMesh at index 0.
  56555. */
  56556. getMeshes(): Array<Mesh>;
  56557. /**
  56558. * Explodes meshes giving a specific direction
  56559. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56560. */
  56561. explode(direction?: number): void;
  56562. }
  56563. }
  56564. declare module "babylonjs/Misc/filesInput" {
  56565. import { Engine } from "babylonjs/Engines/engine";
  56566. import { Scene } from "babylonjs/scene";
  56567. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56568. /**
  56569. * Class used to help managing file picking and drag'n'drop
  56570. */
  56571. export class FilesInput {
  56572. /**
  56573. * List of files ready to be loaded
  56574. */
  56575. static readonly FilesToLoad: {
  56576. [key: string]: File;
  56577. };
  56578. /**
  56579. * Callback called when a file is processed
  56580. */
  56581. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56582. private _engine;
  56583. private _currentScene;
  56584. private _sceneLoadedCallback;
  56585. private _progressCallback;
  56586. private _additionalRenderLoopLogicCallback;
  56587. private _textureLoadingCallback;
  56588. private _startingProcessingFilesCallback;
  56589. private _onReloadCallback;
  56590. private _errorCallback;
  56591. private _elementToMonitor;
  56592. private _sceneFileToLoad;
  56593. private _filesToLoad;
  56594. /**
  56595. * Creates a new FilesInput
  56596. * @param engine defines the rendering engine
  56597. * @param scene defines the hosting scene
  56598. * @param sceneLoadedCallback callback called when scene is loaded
  56599. * @param progressCallback callback called to track progress
  56600. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56601. * @param textureLoadingCallback callback called when a texture is loading
  56602. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56603. * @param onReloadCallback callback called when a reload is requested
  56604. * @param errorCallback callback call if an error occurs
  56605. */
  56606. 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);
  56607. private _dragEnterHandler;
  56608. private _dragOverHandler;
  56609. private _dropHandler;
  56610. /**
  56611. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56612. * @param elementToMonitor defines the DOM element to track
  56613. */
  56614. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56615. /**
  56616. * Release all associated resources
  56617. */
  56618. dispose(): void;
  56619. private renderFunction;
  56620. private drag;
  56621. private drop;
  56622. private _traverseFolder;
  56623. private _processFiles;
  56624. /**
  56625. * Load files from a drop event
  56626. * @param event defines the drop event to use as source
  56627. */
  56628. loadFiles(event: any): void;
  56629. private _processReload;
  56630. /**
  56631. * Reload the current scene from the loaded files
  56632. */
  56633. reload(): void;
  56634. }
  56635. }
  56636. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56637. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56638. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56639. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56640. }
  56641. declare module "babylonjs/Misc/sceneOptimizer" {
  56642. import { Scene, IDisposable } from "babylonjs/scene";
  56643. import { Observable } from "babylonjs/Misc/observable";
  56644. /**
  56645. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56647. */
  56648. export class SceneOptimization {
  56649. /**
  56650. * Defines the priority of this optimization (0 by default which means first in the list)
  56651. */
  56652. priority: number;
  56653. /**
  56654. * Gets a string describing the action executed by the current optimization
  56655. * @returns description string
  56656. */
  56657. getDescription(): string;
  56658. /**
  56659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56660. * @param scene defines the current scene where to apply this optimization
  56661. * @param optimizer defines the current optimizer
  56662. * @returns true if everything that can be done was applied
  56663. */
  56664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56665. /**
  56666. * Creates the SceneOptimization object
  56667. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56668. * @param desc defines the description associated with the optimization
  56669. */
  56670. constructor(
  56671. /**
  56672. * Defines the priority of this optimization (0 by default which means first in the list)
  56673. */
  56674. priority?: number);
  56675. }
  56676. /**
  56677. * Defines an optimization used to reduce the size of render target textures
  56678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56679. */
  56680. export class TextureOptimization extends SceneOptimization {
  56681. /**
  56682. * Defines the priority of this optimization (0 by default which means first in the list)
  56683. */
  56684. priority: number;
  56685. /**
  56686. * 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
  56687. */
  56688. maximumSize: number;
  56689. /**
  56690. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56691. */
  56692. step: number;
  56693. /**
  56694. * Gets a string describing the action executed by the current optimization
  56695. * @returns description string
  56696. */
  56697. getDescription(): string;
  56698. /**
  56699. * Creates the TextureOptimization object
  56700. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56701. * @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
  56702. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56703. */
  56704. constructor(
  56705. /**
  56706. * Defines the priority of this optimization (0 by default which means first in the list)
  56707. */
  56708. priority?: number,
  56709. /**
  56710. * 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
  56711. */
  56712. maximumSize?: number,
  56713. /**
  56714. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56715. */
  56716. step?: number);
  56717. /**
  56718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56719. * @param scene defines the current scene where to apply this optimization
  56720. * @param optimizer defines the current optimizer
  56721. * @returns true if everything that can be done was applied
  56722. */
  56723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56724. }
  56725. /**
  56726. * Defines an optimization used to increase or decrease the rendering resolution
  56727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56728. */
  56729. export class HardwareScalingOptimization extends SceneOptimization {
  56730. /**
  56731. * Defines the priority of this optimization (0 by default which means first in the list)
  56732. */
  56733. priority: number;
  56734. /**
  56735. * Defines the maximum scale to use (2 by default)
  56736. */
  56737. maximumScale: number;
  56738. /**
  56739. * Defines the step to use between two passes (0.5 by default)
  56740. */
  56741. step: number;
  56742. private _currentScale;
  56743. private _directionOffset;
  56744. /**
  56745. * Gets a string describing the action executed by the current optimization
  56746. * @return description string
  56747. */
  56748. getDescription(): string;
  56749. /**
  56750. * Creates the HardwareScalingOptimization object
  56751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56752. * @param maximumScale defines the maximum scale to use (2 by default)
  56753. * @param step defines the step to use between two passes (0.5 by default)
  56754. */
  56755. constructor(
  56756. /**
  56757. * Defines the priority of this optimization (0 by default which means first in the list)
  56758. */
  56759. priority?: number,
  56760. /**
  56761. * Defines the maximum scale to use (2 by default)
  56762. */
  56763. maximumScale?: number,
  56764. /**
  56765. * Defines the step to use between two passes (0.5 by default)
  56766. */
  56767. step?: number);
  56768. /**
  56769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56770. * @param scene defines the current scene where to apply this optimization
  56771. * @param optimizer defines the current optimizer
  56772. * @returns true if everything that can be done was applied
  56773. */
  56774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56775. }
  56776. /**
  56777. * Defines an optimization used to remove shadows
  56778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56779. */
  56780. export class ShadowsOptimization extends SceneOptimization {
  56781. /**
  56782. * Gets a string describing the action executed by the current optimization
  56783. * @return description string
  56784. */
  56785. getDescription(): string;
  56786. /**
  56787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56788. * @param scene defines the current scene where to apply this optimization
  56789. * @param optimizer defines the current optimizer
  56790. * @returns true if everything that can be done was applied
  56791. */
  56792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56793. }
  56794. /**
  56795. * Defines an optimization used to turn post-processes off
  56796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56797. */
  56798. export class PostProcessesOptimization extends SceneOptimization {
  56799. /**
  56800. * Gets a string describing the action executed by the current optimization
  56801. * @return description string
  56802. */
  56803. getDescription(): string;
  56804. /**
  56805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56806. * @param scene defines the current scene where to apply this optimization
  56807. * @param optimizer defines the current optimizer
  56808. * @returns true if everything that can be done was applied
  56809. */
  56810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56811. }
  56812. /**
  56813. * Defines an optimization used to turn lens flares off
  56814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56815. */
  56816. export class LensFlaresOptimization extends SceneOptimization {
  56817. /**
  56818. * Gets a string describing the action executed by the current optimization
  56819. * @return description string
  56820. */
  56821. getDescription(): string;
  56822. /**
  56823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56824. * @param scene defines the current scene where to apply this optimization
  56825. * @param optimizer defines the current optimizer
  56826. * @returns true if everything that can be done was applied
  56827. */
  56828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56829. }
  56830. /**
  56831. * Defines an optimization based on user defined callback.
  56832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56833. */
  56834. export class CustomOptimization extends SceneOptimization {
  56835. /**
  56836. * Callback called to apply the custom optimization.
  56837. */
  56838. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56839. /**
  56840. * Callback called to get custom description
  56841. */
  56842. onGetDescription: () => string;
  56843. /**
  56844. * Gets a string describing the action executed by the current optimization
  56845. * @returns description string
  56846. */
  56847. getDescription(): string;
  56848. /**
  56849. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56850. * @param scene defines the current scene where to apply this optimization
  56851. * @param optimizer defines the current optimizer
  56852. * @returns true if everything that can be done was applied
  56853. */
  56854. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56855. }
  56856. /**
  56857. * Defines an optimization used to turn particles off
  56858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56859. */
  56860. export class ParticlesOptimization extends SceneOptimization {
  56861. /**
  56862. * Gets a string describing the action executed by the current optimization
  56863. * @return description string
  56864. */
  56865. getDescription(): string;
  56866. /**
  56867. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56868. * @param scene defines the current scene where to apply this optimization
  56869. * @param optimizer defines the current optimizer
  56870. * @returns true if everything that can be done was applied
  56871. */
  56872. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56873. }
  56874. /**
  56875. * Defines an optimization used to turn render targets off
  56876. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56877. */
  56878. export class RenderTargetsOptimization extends SceneOptimization {
  56879. /**
  56880. * Gets a string describing the action executed by the current optimization
  56881. * @return description string
  56882. */
  56883. getDescription(): string;
  56884. /**
  56885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56886. * @param scene defines the current scene where to apply this optimization
  56887. * @param optimizer defines the current optimizer
  56888. * @returns true if everything that can be done was applied
  56889. */
  56890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56891. }
  56892. /**
  56893. * Defines an optimization used to merge meshes with compatible materials
  56894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56895. */
  56896. export class MergeMeshesOptimization extends SceneOptimization {
  56897. private static _UpdateSelectionTree;
  56898. /**
  56899. * Gets or sets a boolean which defines if optimization octree has to be updated
  56900. */
  56901. /**
  56902. * Gets or sets a boolean which defines if optimization octree has to be updated
  56903. */
  56904. static UpdateSelectionTree: boolean;
  56905. /**
  56906. * Gets a string describing the action executed by the current optimization
  56907. * @return description string
  56908. */
  56909. getDescription(): string;
  56910. private _canBeMerged;
  56911. /**
  56912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56913. * @param scene defines the current scene where to apply this optimization
  56914. * @param optimizer defines the current optimizer
  56915. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56916. * @returns true if everything that can be done was applied
  56917. */
  56918. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56919. }
  56920. /**
  56921. * Defines a list of options used by SceneOptimizer
  56922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56923. */
  56924. export class SceneOptimizerOptions {
  56925. /**
  56926. * Defines the target frame rate to reach (60 by default)
  56927. */
  56928. targetFrameRate: number;
  56929. /**
  56930. * Defines the interval between two checkes (2000ms by default)
  56931. */
  56932. trackerDuration: number;
  56933. /**
  56934. * Gets the list of optimizations to apply
  56935. */
  56936. optimizations: SceneOptimization[];
  56937. /**
  56938. * Creates a new list of options used by SceneOptimizer
  56939. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56940. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56941. */
  56942. constructor(
  56943. /**
  56944. * Defines the target frame rate to reach (60 by default)
  56945. */
  56946. targetFrameRate?: number,
  56947. /**
  56948. * Defines the interval between two checkes (2000ms by default)
  56949. */
  56950. trackerDuration?: number);
  56951. /**
  56952. * Add a new optimization
  56953. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56954. * @returns the current SceneOptimizerOptions
  56955. */
  56956. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56957. /**
  56958. * Add a new custom optimization
  56959. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56960. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56961. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56962. * @returns the current SceneOptimizerOptions
  56963. */
  56964. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56965. /**
  56966. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56967. * @param targetFrameRate defines the target frame rate (60 by default)
  56968. * @returns a SceneOptimizerOptions object
  56969. */
  56970. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56971. /**
  56972. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56973. * @param targetFrameRate defines the target frame rate (60 by default)
  56974. * @returns a SceneOptimizerOptions object
  56975. */
  56976. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56977. /**
  56978. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56979. * @param targetFrameRate defines the target frame rate (60 by default)
  56980. * @returns a SceneOptimizerOptions object
  56981. */
  56982. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56983. }
  56984. /**
  56985. * Class used to run optimizations in order to reach a target frame rate
  56986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56987. */
  56988. export class SceneOptimizer implements IDisposable {
  56989. private _isRunning;
  56990. private _options;
  56991. private _scene;
  56992. private _currentPriorityLevel;
  56993. private _targetFrameRate;
  56994. private _trackerDuration;
  56995. private _currentFrameRate;
  56996. private _sceneDisposeObserver;
  56997. private _improvementMode;
  56998. /**
  56999. * Defines an observable called when the optimizer reaches the target frame rate
  57000. */
  57001. onSuccessObservable: Observable<SceneOptimizer>;
  57002. /**
  57003. * Defines an observable called when the optimizer enables an optimization
  57004. */
  57005. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57006. /**
  57007. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57008. */
  57009. onFailureObservable: Observable<SceneOptimizer>;
  57010. /**
  57011. * Gets a boolean indicating if the optimizer is in improvement mode
  57012. */
  57013. readonly isInImprovementMode: boolean;
  57014. /**
  57015. * Gets the current priority level (0 at start)
  57016. */
  57017. readonly currentPriorityLevel: number;
  57018. /**
  57019. * Gets the current frame rate checked by the SceneOptimizer
  57020. */
  57021. readonly currentFrameRate: number;
  57022. /**
  57023. * Gets or sets the current target frame rate (60 by default)
  57024. */
  57025. /**
  57026. * Gets or sets the current target frame rate (60 by default)
  57027. */
  57028. targetFrameRate: number;
  57029. /**
  57030. * Gets or sets the current interval between two checks (every 2000ms by default)
  57031. */
  57032. /**
  57033. * Gets or sets the current interval between two checks (every 2000ms by default)
  57034. */
  57035. trackerDuration: number;
  57036. /**
  57037. * Gets the list of active optimizations
  57038. */
  57039. readonly optimizations: SceneOptimization[];
  57040. /**
  57041. * Creates a new SceneOptimizer
  57042. * @param scene defines the scene to work on
  57043. * @param options defines the options to use with the SceneOptimizer
  57044. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57045. * @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)
  57046. */
  57047. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57048. /**
  57049. * Stops the current optimizer
  57050. */
  57051. stop(): void;
  57052. /**
  57053. * Reset the optimizer to initial step (current priority level = 0)
  57054. */
  57055. reset(): void;
  57056. /**
  57057. * Start the optimizer. By default it will try to reach a specific framerate
  57058. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57059. */
  57060. start(): void;
  57061. private _checkCurrentState;
  57062. /**
  57063. * Release all resources
  57064. */
  57065. dispose(): void;
  57066. /**
  57067. * Helper function to create a SceneOptimizer with one single line of code
  57068. * @param scene defines the scene to work on
  57069. * @param options defines the options to use with the SceneOptimizer
  57070. * @param onSuccess defines a callback to call on success
  57071. * @param onFailure defines a callback to call on failure
  57072. * @returns the new SceneOptimizer object
  57073. */
  57074. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57075. }
  57076. }
  57077. declare module "babylonjs/Misc/sceneSerializer" {
  57078. import { Scene } from "babylonjs/scene";
  57079. /**
  57080. * Class used to serialize a scene into a string
  57081. */
  57082. export class SceneSerializer {
  57083. /**
  57084. * Clear cache used by a previous serialization
  57085. */
  57086. static ClearCache(): void;
  57087. /**
  57088. * Serialize a scene into a JSON compatible object
  57089. * @param scene defines the scene to serialize
  57090. * @returns a JSON compatible object
  57091. */
  57092. static Serialize(scene: Scene): any;
  57093. /**
  57094. * Serialize a mesh into a JSON compatible object
  57095. * @param toSerialize defines the mesh to serialize
  57096. * @param withParents defines if parents must be serialized as well
  57097. * @param withChildren defines if children must be serialized as well
  57098. * @returns a JSON compatible object
  57099. */
  57100. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57101. }
  57102. }
  57103. declare module "babylonjs/Misc/videoRecorder" {
  57104. import { Nullable } from "babylonjs/types";
  57105. import { Engine } from "babylonjs/Engines/engine";
  57106. /**
  57107. * This represents the different options avilable for the video capture.
  57108. */
  57109. export interface VideoRecorderOptions {
  57110. /** Defines the mime type of the video */
  57111. mimeType: string;
  57112. /** Defines the video the video should be recorded at */
  57113. fps: number;
  57114. /** Defines the chunk size for the recording data */
  57115. recordChunckSize: number;
  57116. /** The audio tracks to attach to the record */
  57117. audioTracks?: MediaStreamTrack[];
  57118. }
  57119. /**
  57120. * This can helps recording videos from BabylonJS.
  57121. * This is based on the available WebRTC functionalities of the browser.
  57122. *
  57123. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57124. */
  57125. export class VideoRecorder {
  57126. private static readonly _defaultOptions;
  57127. /**
  57128. * Returns wehther or not the VideoRecorder is available in your browser.
  57129. * @param engine Defines the Babylon Engine to check the support for
  57130. * @returns true if supported otherwise false
  57131. */
  57132. static IsSupported(engine: Engine): boolean;
  57133. private readonly _options;
  57134. private _canvas;
  57135. private _mediaRecorder;
  57136. private _recordedChunks;
  57137. private _fileName;
  57138. private _resolve;
  57139. private _reject;
  57140. /**
  57141. * True wether a recording is already in progress.
  57142. */
  57143. readonly isRecording: boolean;
  57144. /**
  57145. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57146. * a video file.
  57147. * @param engine Defines the BabylonJS Engine you wish to record
  57148. * @param options Defines options that can be used to customized the capture
  57149. */
  57150. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57151. /**
  57152. * Stops the current recording before the default capture timeout passed in the startRecording
  57153. * functions.
  57154. */
  57155. stopRecording(): void;
  57156. /**
  57157. * Starts recording the canvas for a max duration specified in parameters.
  57158. * @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.
  57159. * @param maxDuration Defines the maximum recording time in seconds.
  57160. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57161. * @return a promise callback at the end of the recording with the video data in Blob.
  57162. */
  57163. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57164. /**
  57165. * Releases internal resources used during the recording.
  57166. */
  57167. dispose(): void;
  57168. private _handleDataAvailable;
  57169. private _handleError;
  57170. private _handleStop;
  57171. }
  57172. }
  57173. declare module "babylonjs/Misc/workerPool" {
  57174. import { IDisposable } from "babylonjs/scene";
  57175. /**
  57176. * Helper class to push actions to a pool of workers.
  57177. */
  57178. export class WorkerPool implements IDisposable {
  57179. private _workerInfos;
  57180. private _pendingActions;
  57181. /**
  57182. * Constructor
  57183. * @param workers Array of workers to use for actions
  57184. */
  57185. constructor(workers: Array<Worker>);
  57186. /**
  57187. * Terminates all workers and clears any pending actions.
  57188. */
  57189. dispose(): void;
  57190. /**
  57191. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57192. * pended until a worker has completed its action.
  57193. * @param action The action to perform. Call onComplete when the action is complete.
  57194. */
  57195. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57196. private _execute;
  57197. }
  57198. }
  57199. declare module "babylonjs/Misc/screenshotTools" {
  57200. import { Camera } from "babylonjs/Cameras/camera";
  57201. import { Engine } from "babylonjs/Engines/engine";
  57202. /**
  57203. * Class containing a set of static utilities functions for screenshots
  57204. */
  57205. export class ScreenshotTools {
  57206. /**
  57207. * Captures a screenshot of the current rendering
  57208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57209. * @param engine defines the rendering engine
  57210. * @param camera defines the source camera
  57211. * @param size This parameter can be set to a single number or to an object with the
  57212. * following (optional) properties: precision, width, height. If a single number is passed,
  57213. * it will be used for both width and height. If an object is passed, the screenshot size
  57214. * will be derived from the parameters. The precision property is a multiplier allowing
  57215. * rendering at a higher or lower resolution
  57216. * @param successCallback defines the callback receives a single parameter which contains the
  57217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57218. * src parameter of an <img> to display it
  57219. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57220. * Check your browser for supported MIME types
  57221. */
  57222. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57223. /**
  57224. * Generates an image screenshot from the specified camera.
  57225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57226. * @param engine The engine to use for rendering
  57227. * @param camera The camera to use for rendering
  57228. * @param size This parameter can be set to a single number or to an object with the
  57229. * following (optional) properties: precision, width, height. If a single number is passed,
  57230. * it will be used for both width and height. If an object is passed, the screenshot size
  57231. * will be derived from the parameters. The precision property is a multiplier allowing
  57232. * rendering at a higher or lower resolution
  57233. * @param successCallback The callback receives a single parameter which contains the
  57234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57235. * src parameter of an <img> to display it
  57236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57237. * Check your browser for supported MIME types
  57238. * @param samples Texture samples (default: 1)
  57239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57240. * @param fileName A name for for the downloaded file.
  57241. */
  57242. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57243. }
  57244. }
  57245. declare module "babylonjs/Misc/index" {
  57246. export * from "babylonjs/Misc/andOrNotEvaluator";
  57247. export * from "babylonjs/Misc/assetsManager";
  57248. export * from "babylonjs/Misc/dds";
  57249. export * from "babylonjs/Misc/decorators";
  57250. export * from "babylonjs/Misc/deferred";
  57251. export * from "babylonjs/Misc/environmentTextureTools";
  57252. export * from "babylonjs/Misc/meshExploder";
  57253. export * from "babylonjs/Misc/filesInput";
  57254. export * from "babylonjs/Misc/HighDynamicRange/index";
  57255. export * from "babylonjs/Misc/khronosTextureContainer";
  57256. export * from "babylonjs/Misc/observable";
  57257. export * from "babylonjs/Misc/performanceMonitor";
  57258. export * from "babylonjs/Misc/promise";
  57259. export * from "babylonjs/Misc/sceneOptimizer";
  57260. export * from "babylonjs/Misc/sceneSerializer";
  57261. export * from "babylonjs/Misc/smartArray";
  57262. export * from "babylonjs/Misc/stringDictionary";
  57263. export * from "babylonjs/Misc/tags";
  57264. export * from "babylonjs/Misc/textureTools";
  57265. export * from "babylonjs/Misc/tga";
  57266. export * from "babylonjs/Misc/tools";
  57267. export * from "babylonjs/Misc/videoRecorder";
  57268. export * from "babylonjs/Misc/virtualJoystick";
  57269. export * from "babylonjs/Misc/workerPool";
  57270. export * from "babylonjs/Misc/logger";
  57271. export * from "babylonjs/Misc/typeStore";
  57272. export * from "babylonjs/Misc/filesInputStore";
  57273. export * from "babylonjs/Misc/deepCopier";
  57274. export * from "babylonjs/Misc/pivotTools";
  57275. export * from "babylonjs/Misc/precisionDate";
  57276. export * from "babylonjs/Misc/screenshotTools";
  57277. export * from "babylonjs/Misc/typeStore";
  57278. export * from "babylonjs/Misc/webRequest";
  57279. }
  57280. declare module "babylonjs/index" {
  57281. export * from "babylonjs/abstractScene";
  57282. export * from "babylonjs/Actions/index";
  57283. export * from "babylonjs/Animations/index";
  57284. export * from "babylonjs/assetContainer";
  57285. export * from "babylonjs/Audio/index";
  57286. export * from "babylonjs/Behaviors/index";
  57287. export * from "babylonjs/Bones/index";
  57288. export * from "babylonjs/Cameras/index";
  57289. export * from "babylonjs/Collisions/index";
  57290. export * from "babylonjs/Culling/index";
  57291. export * from "babylonjs/Debug/index";
  57292. export * from "babylonjs/Engines/index";
  57293. export * from "babylonjs/Events/index";
  57294. export * from "babylonjs/Gamepads/index";
  57295. export * from "babylonjs/Gizmos/index";
  57296. export * from "babylonjs/Helpers/index";
  57297. export * from "babylonjs/Instrumentation/index";
  57298. export * from "babylonjs/Layers/index";
  57299. export * from "babylonjs/LensFlares/index";
  57300. export * from "babylonjs/Lights/index";
  57301. export * from "babylonjs/Loading/index";
  57302. export * from "babylonjs/Materials/index";
  57303. export * from "babylonjs/Maths/index";
  57304. export * from "babylonjs/Meshes/index";
  57305. export * from "babylonjs/Morph/index";
  57306. export * from "babylonjs/node";
  57307. export * from "babylonjs/Offline/index";
  57308. export * from "babylonjs/Particles/index";
  57309. export * from "babylonjs/Physics/index";
  57310. export * from "babylonjs/PostProcesses/index";
  57311. export * from "babylonjs/Probes/index";
  57312. export * from "babylonjs/Rendering/index";
  57313. export * from "babylonjs/scene";
  57314. export * from "babylonjs/sceneComponent";
  57315. export * from "babylonjs/Sprites/index";
  57316. export * from "babylonjs/States/index";
  57317. export * from "babylonjs/Misc/index";
  57318. export * from "babylonjs/types";
  57319. }
  57320. declare module "babylonjs/Animations/pathCursor" {
  57321. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57322. /**
  57323. * A cursor which tracks a point on a path
  57324. */
  57325. export class PathCursor {
  57326. private path;
  57327. /**
  57328. * Stores path cursor callbacks for when an onchange event is triggered
  57329. */
  57330. private _onchange;
  57331. /**
  57332. * The value of the path cursor
  57333. */
  57334. value: number;
  57335. /**
  57336. * The animation array of the path cursor
  57337. */
  57338. animations: Animation[];
  57339. /**
  57340. * Initializes the path cursor
  57341. * @param path The path to track
  57342. */
  57343. constructor(path: Path2);
  57344. /**
  57345. * Gets the cursor point on the path
  57346. * @returns A point on the path cursor at the cursor location
  57347. */
  57348. getPoint(): Vector3;
  57349. /**
  57350. * Moves the cursor ahead by the step amount
  57351. * @param step The amount to move the cursor forward
  57352. * @returns This path cursor
  57353. */
  57354. moveAhead(step?: number): PathCursor;
  57355. /**
  57356. * Moves the cursor behind by the step amount
  57357. * @param step The amount to move the cursor back
  57358. * @returns This path cursor
  57359. */
  57360. moveBack(step?: number): PathCursor;
  57361. /**
  57362. * Moves the cursor by the step amount
  57363. * If the step amount is greater than one, an exception is thrown
  57364. * @param step The amount to move the cursor
  57365. * @returns This path cursor
  57366. */
  57367. move(step: number): PathCursor;
  57368. /**
  57369. * Ensures that the value is limited between zero and one
  57370. * @returns This path cursor
  57371. */
  57372. private ensureLimits;
  57373. /**
  57374. * Runs onchange callbacks on change (used by the animation engine)
  57375. * @returns This path cursor
  57376. */
  57377. private raiseOnChange;
  57378. /**
  57379. * Executes a function on change
  57380. * @param f A path cursor onchange callback
  57381. * @returns This path cursor
  57382. */
  57383. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57384. }
  57385. }
  57386. declare module "babylonjs/Legacy/legacy" {
  57387. import * as Babylon from "babylonjs/index";
  57388. export * from "babylonjs/index";
  57389. }
  57390. declare module "babylonjs/Shaders/blur.fragment" {
  57391. /** @hidden */
  57392. export var blurPixelShader: {
  57393. name: string;
  57394. shader: string;
  57395. };
  57396. }
  57397. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57398. /** @hidden */
  57399. export var bones300Declaration: {
  57400. name: string;
  57401. shader: string;
  57402. };
  57403. }
  57404. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57405. /** @hidden */
  57406. export var instances300Declaration: {
  57407. name: string;
  57408. shader: string;
  57409. };
  57410. }
  57411. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57412. /** @hidden */
  57413. export var pointCloudVertexDeclaration: {
  57414. name: string;
  57415. shader: string;
  57416. };
  57417. }
  57418. // Mixins
  57419. interface Window {
  57420. mozIndexedDB: IDBFactory;
  57421. webkitIndexedDB: IDBFactory;
  57422. msIndexedDB: IDBFactory;
  57423. webkitURL: typeof URL;
  57424. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57425. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57426. WebGLRenderingContext: WebGLRenderingContext;
  57427. MSGesture: MSGesture;
  57428. CANNON: any;
  57429. AudioContext: AudioContext;
  57430. webkitAudioContext: AudioContext;
  57431. PointerEvent: any;
  57432. Math: Math;
  57433. Uint8Array: Uint8ArrayConstructor;
  57434. Float32Array: Float32ArrayConstructor;
  57435. mozURL: typeof URL;
  57436. msURL: typeof URL;
  57437. VRFrameData: any; // WebVR, from specs 1.1
  57438. DracoDecoderModule: any;
  57439. setImmediate(handler: (...args: any[]) => void): number;
  57440. }
  57441. interface HTMLCanvasElement {
  57442. requestPointerLock(): void;
  57443. msRequestPointerLock?(): void;
  57444. mozRequestPointerLock?(): void;
  57445. webkitRequestPointerLock?(): void;
  57446. /** Track wether a record is in progress */
  57447. isRecording: boolean;
  57448. /** Capture Stream method defined by some browsers */
  57449. captureStream(fps?: number): MediaStream;
  57450. }
  57451. interface CanvasRenderingContext2D {
  57452. msImageSmoothingEnabled: boolean;
  57453. }
  57454. interface MouseEvent {
  57455. mozMovementX: number;
  57456. mozMovementY: number;
  57457. webkitMovementX: number;
  57458. webkitMovementY: number;
  57459. msMovementX: number;
  57460. msMovementY: number;
  57461. }
  57462. interface Navigator {
  57463. mozGetVRDevices: (any: any) => any;
  57464. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57465. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57466. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57467. webkitGetGamepads(): Gamepad[];
  57468. msGetGamepads(): Gamepad[];
  57469. webkitGamepads(): Gamepad[];
  57470. }
  57471. interface HTMLVideoElement {
  57472. mozSrcObject: any;
  57473. }
  57474. interface Math {
  57475. fround(x: number): number;
  57476. imul(a: number, b: number): number;
  57477. }
  57478. interface WebGLProgram {
  57479. context?: WebGLRenderingContext;
  57480. vertexShader?: WebGLShader;
  57481. fragmentShader?: WebGLShader;
  57482. isParallelCompiled: boolean;
  57483. onCompiled?: () => void;
  57484. }
  57485. interface WebGLRenderingContext {
  57486. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57487. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57488. vertexAttribDivisor(index: number, divisor: number): void;
  57489. createVertexArray(): any;
  57490. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57491. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57492. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57493. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57494. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57495. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57496. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57497. // Queries
  57498. createQuery(): WebGLQuery;
  57499. deleteQuery(query: WebGLQuery): void;
  57500. beginQuery(target: number, query: WebGLQuery): void;
  57501. endQuery(target: number): void;
  57502. getQueryParameter(query: WebGLQuery, pname: number): any;
  57503. getQuery(target: number, pname: number): any;
  57504. MAX_SAMPLES: number;
  57505. RGBA8: number;
  57506. READ_FRAMEBUFFER: number;
  57507. DRAW_FRAMEBUFFER: number;
  57508. UNIFORM_BUFFER: number;
  57509. HALF_FLOAT_OES: number;
  57510. RGBA16F: number;
  57511. RGBA32F: number;
  57512. R32F: number;
  57513. RG32F: number;
  57514. RGB32F: number;
  57515. R16F: number;
  57516. RG16F: number;
  57517. RGB16F: number;
  57518. RED: number;
  57519. RG: number;
  57520. R8: number;
  57521. RG8: number;
  57522. UNSIGNED_INT_24_8: number;
  57523. DEPTH24_STENCIL8: number;
  57524. /* Multiple Render Targets */
  57525. drawBuffers(buffers: number[]): void;
  57526. readBuffer(src: number): void;
  57527. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57528. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57529. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57530. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57531. // Occlusion Query
  57532. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57533. ANY_SAMPLES_PASSED: number;
  57534. QUERY_RESULT_AVAILABLE: number;
  57535. QUERY_RESULT: number;
  57536. }
  57537. interface WebGLBuffer {
  57538. references: number;
  57539. capacity: number;
  57540. is32Bits: boolean;
  57541. }
  57542. interface WebGLProgram {
  57543. transformFeedback?: WebGLTransformFeedback | null;
  57544. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57545. }
  57546. interface EXT_disjoint_timer_query {
  57547. QUERY_COUNTER_BITS_EXT: number;
  57548. TIME_ELAPSED_EXT: number;
  57549. TIMESTAMP_EXT: number;
  57550. GPU_DISJOINT_EXT: number;
  57551. QUERY_RESULT_EXT: number;
  57552. QUERY_RESULT_AVAILABLE_EXT: number;
  57553. queryCounterEXT(query: WebGLQuery, target: number): void;
  57554. createQueryEXT(): WebGLQuery;
  57555. beginQueryEXT(target: number, query: WebGLQuery): void;
  57556. endQueryEXT(target: number): void;
  57557. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57558. deleteQueryEXT(query: WebGLQuery): void;
  57559. }
  57560. interface WebGLUniformLocation {
  57561. _currentState: any;
  57562. }
  57563. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57564. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57565. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57566. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57567. interface WebGLRenderingContext {
  57568. readonly RASTERIZER_DISCARD: number;
  57569. readonly DEPTH_COMPONENT24: number;
  57570. readonly TEXTURE_3D: number;
  57571. readonly TEXTURE_2D_ARRAY: number;
  57572. readonly TEXTURE_COMPARE_FUNC: number;
  57573. readonly TEXTURE_COMPARE_MODE: number;
  57574. readonly COMPARE_REF_TO_TEXTURE: number;
  57575. readonly TEXTURE_WRAP_R: number;
  57576. readonly HALF_FLOAT: number;
  57577. readonly RGB8: number;
  57578. readonly RED_INTEGER: number;
  57579. readonly RG_INTEGER: number;
  57580. readonly RGB_INTEGER: number;
  57581. readonly RGBA_INTEGER: number;
  57582. readonly R8_SNORM: number;
  57583. readonly RG8_SNORM: number;
  57584. readonly RGB8_SNORM: number;
  57585. readonly RGBA8_SNORM: number;
  57586. readonly R8I: number;
  57587. readonly RG8I: number;
  57588. readonly RGB8I: number;
  57589. readonly RGBA8I: number;
  57590. readonly R8UI: number;
  57591. readonly RG8UI: number;
  57592. readonly RGB8UI: number;
  57593. readonly RGBA8UI: number;
  57594. readonly R16I: number;
  57595. readonly RG16I: number;
  57596. readonly RGB16I: number;
  57597. readonly RGBA16I: number;
  57598. readonly R16UI: number;
  57599. readonly RG16UI: number;
  57600. readonly RGB16UI: number;
  57601. readonly RGBA16UI: number;
  57602. readonly R32I: number;
  57603. readonly RG32I: number;
  57604. readonly RGB32I: number;
  57605. readonly RGBA32I: number;
  57606. readonly R32UI: number;
  57607. readonly RG32UI: number;
  57608. readonly RGB32UI: number;
  57609. readonly RGBA32UI: number;
  57610. readonly RGB10_A2UI: number;
  57611. readonly R11F_G11F_B10F: number;
  57612. readonly RGB9_E5: number;
  57613. readonly RGB10_A2: number;
  57614. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57615. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57616. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57617. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57618. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57619. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57620. 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;
  57621. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57622. readonly TRANSFORM_FEEDBACK: number;
  57623. readonly INTERLEAVED_ATTRIBS: number;
  57624. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57625. createTransformFeedback(): WebGLTransformFeedback;
  57626. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57627. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57628. beginTransformFeedback(primitiveMode: number): void;
  57629. endTransformFeedback(): void;
  57630. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57631. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57632. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57633. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57634. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57635. }
  57636. interface ImageBitmap {
  57637. readonly width: number;
  57638. readonly height: number;
  57639. close(): void;
  57640. }
  57641. interface WebGLQuery extends WebGLObject {
  57642. }
  57643. declare var WebGLQuery: {
  57644. prototype: WebGLQuery;
  57645. new(): WebGLQuery;
  57646. };
  57647. interface WebGLSampler extends WebGLObject {
  57648. }
  57649. declare var WebGLSampler: {
  57650. prototype: WebGLSampler;
  57651. new(): WebGLSampler;
  57652. };
  57653. interface WebGLSync extends WebGLObject {
  57654. }
  57655. declare var WebGLSync: {
  57656. prototype: WebGLSync;
  57657. new(): WebGLSync;
  57658. };
  57659. interface WebGLTransformFeedback extends WebGLObject {
  57660. }
  57661. declare var WebGLTransformFeedback: {
  57662. prototype: WebGLTransformFeedback;
  57663. new(): WebGLTransformFeedback;
  57664. };
  57665. interface WebGLVertexArrayObject extends WebGLObject {
  57666. }
  57667. declare var WebGLVertexArrayObject: {
  57668. prototype: WebGLVertexArrayObject;
  57669. new(): WebGLVertexArrayObject;
  57670. };
  57671. // Type definitions for WebVR API
  57672. // Project: https://w3c.github.io/webvr/
  57673. // Definitions by: six a <https://github.com/lostfictions>
  57674. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57675. interface VRDisplay extends EventTarget {
  57676. /**
  57677. * Dictionary of capabilities describing the VRDisplay.
  57678. */
  57679. readonly capabilities: VRDisplayCapabilities;
  57680. /**
  57681. * z-depth defining the far plane of the eye view frustum
  57682. * enables mapping of values in the render target depth
  57683. * attachment to scene coordinates. Initially set to 10000.0.
  57684. */
  57685. depthFar: number;
  57686. /**
  57687. * z-depth defining the near plane of the eye view frustum
  57688. * enables mapping of values in the render target depth
  57689. * attachment to scene coordinates. Initially set to 0.01.
  57690. */
  57691. depthNear: number;
  57692. /**
  57693. * An identifier for this distinct VRDisplay. Used as an
  57694. * association point in the Gamepad API.
  57695. */
  57696. readonly displayId: number;
  57697. /**
  57698. * A display name, a user-readable name identifying it.
  57699. */
  57700. readonly displayName: string;
  57701. readonly isConnected: boolean;
  57702. readonly isPresenting: boolean;
  57703. /**
  57704. * If this VRDisplay supports room-scale experiences, the optional
  57705. * stage attribute contains details on the room-scale parameters.
  57706. */
  57707. readonly stageParameters: VRStageParameters | null;
  57708. /**
  57709. * Passing the value returned by `requestAnimationFrame` to
  57710. * `cancelAnimationFrame` will unregister the callback.
  57711. * @param handle Define the hanle of the request to cancel
  57712. */
  57713. cancelAnimationFrame(handle: number): void;
  57714. /**
  57715. * Stops presenting to the VRDisplay.
  57716. * @returns a promise to know when it stopped
  57717. */
  57718. exitPresent(): Promise<void>;
  57719. /**
  57720. * Return the current VREyeParameters for the given eye.
  57721. * @param whichEye Define the eye we want the parameter for
  57722. * @returns the eye parameters
  57723. */
  57724. getEyeParameters(whichEye: string): VREyeParameters;
  57725. /**
  57726. * Populates the passed VRFrameData with the information required to render
  57727. * the current frame.
  57728. * @param frameData Define the data structure to populate
  57729. * @returns true if ok otherwise false
  57730. */
  57731. getFrameData(frameData: VRFrameData): boolean;
  57732. /**
  57733. * Get the layers currently being presented.
  57734. * @returns the list of VR layers
  57735. */
  57736. getLayers(): VRLayer[];
  57737. /**
  57738. * Return a VRPose containing the future predicted pose of the VRDisplay
  57739. * when the current frame will be presented. The value returned will not
  57740. * change until JavaScript has returned control to the browser.
  57741. *
  57742. * The VRPose will contain the position, orientation, velocity,
  57743. * and acceleration of each of these properties.
  57744. * @returns the pose object
  57745. */
  57746. getPose(): VRPose;
  57747. /**
  57748. * Return the current instantaneous pose of the VRDisplay, with no
  57749. * prediction applied.
  57750. * @returns the current instantaneous pose
  57751. */
  57752. getImmediatePose(): VRPose;
  57753. /**
  57754. * The callback passed to `requestAnimationFrame` will be called
  57755. * any time a new frame should be rendered. When the VRDisplay is
  57756. * presenting the callback will be called at the native refresh
  57757. * rate of the HMD. When not presenting this function acts
  57758. * identically to how window.requestAnimationFrame acts. Content should
  57759. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57760. * asynchronously from other displays and at differing refresh rates.
  57761. * @param callback Define the eaction to run next frame
  57762. * @returns the request handle it
  57763. */
  57764. requestAnimationFrame(callback: FrameRequestCallback): number;
  57765. /**
  57766. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57767. * Repeat calls while already presenting will update the VRLayers being displayed.
  57768. * @param layers Define the list of layer to present
  57769. * @returns a promise to know when the request has been fulfilled
  57770. */
  57771. requestPresent(layers: VRLayer[]): Promise<void>;
  57772. /**
  57773. * Reset the pose for this display, treating its current position and
  57774. * orientation as the "origin/zero" values. VRPose.position,
  57775. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57776. * updated when calling resetPose(). This should be called in only
  57777. * sitting-space experiences.
  57778. */
  57779. resetPose(): void;
  57780. /**
  57781. * The VRLayer provided to the VRDisplay will be captured and presented
  57782. * in the HMD. Calling this function has the same effect on the source
  57783. * canvas as any other operation that uses its source image, and canvases
  57784. * created without preserveDrawingBuffer set to true will be cleared.
  57785. * @param pose Define the pose to submit
  57786. */
  57787. submitFrame(pose?: VRPose): void;
  57788. }
  57789. declare var VRDisplay: {
  57790. prototype: VRDisplay;
  57791. new(): VRDisplay;
  57792. };
  57793. interface VRLayer {
  57794. leftBounds?: number[] | Float32Array | null;
  57795. rightBounds?: number[] | Float32Array | null;
  57796. source?: HTMLCanvasElement | null;
  57797. }
  57798. interface VRDisplayCapabilities {
  57799. readonly canPresent: boolean;
  57800. readonly hasExternalDisplay: boolean;
  57801. readonly hasOrientation: boolean;
  57802. readonly hasPosition: boolean;
  57803. readonly maxLayers: number;
  57804. }
  57805. interface VREyeParameters {
  57806. /** @deprecated */
  57807. readonly fieldOfView: VRFieldOfView;
  57808. readonly offset: Float32Array;
  57809. readonly renderHeight: number;
  57810. readonly renderWidth: number;
  57811. }
  57812. interface VRFieldOfView {
  57813. readonly downDegrees: number;
  57814. readonly leftDegrees: number;
  57815. readonly rightDegrees: number;
  57816. readonly upDegrees: number;
  57817. }
  57818. interface VRFrameData {
  57819. readonly leftProjectionMatrix: Float32Array;
  57820. readonly leftViewMatrix: Float32Array;
  57821. readonly pose: VRPose;
  57822. readonly rightProjectionMatrix: Float32Array;
  57823. readonly rightViewMatrix: Float32Array;
  57824. readonly timestamp: number;
  57825. }
  57826. interface VRPose {
  57827. readonly angularAcceleration: Float32Array | null;
  57828. readonly angularVelocity: Float32Array | null;
  57829. readonly linearAcceleration: Float32Array | null;
  57830. readonly linearVelocity: Float32Array | null;
  57831. readonly orientation: Float32Array | null;
  57832. readonly position: Float32Array | null;
  57833. readonly timestamp: number;
  57834. }
  57835. interface VRStageParameters {
  57836. sittingToStandingTransform?: Float32Array;
  57837. sizeX?: number;
  57838. sizeY?: number;
  57839. }
  57840. interface Navigator {
  57841. getVRDisplays(): Promise<VRDisplay[]>;
  57842. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57843. }
  57844. interface Window {
  57845. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57846. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57847. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57848. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57849. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57850. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57851. }
  57852. interface Gamepad {
  57853. readonly displayId: number;
  57854. }
  57855. interface XRDevice {
  57856. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57857. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57858. }
  57859. interface XRSession {
  57860. getInputSources(): Array<any>;
  57861. baseLayer: XRWebGLLayer;
  57862. requestFrameOfReference(type: string): Promise<void>;
  57863. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57864. end(): Promise<void>;
  57865. requestAnimationFrame: Function;
  57866. addEventListener: Function;
  57867. }
  57868. interface XRSessionCreationOptions {
  57869. outputContext?: WebGLRenderingContext | null;
  57870. immersive?: boolean;
  57871. environmentIntegration?: boolean;
  57872. }
  57873. interface XRLayer {
  57874. getViewport: Function;
  57875. framebufferWidth: number;
  57876. framebufferHeight: number;
  57877. }
  57878. interface XRView {
  57879. projectionMatrix: Float32Array;
  57880. }
  57881. interface XRFrame {
  57882. getDevicePose: Function;
  57883. getInputPose: Function;
  57884. views: Array<XRView>;
  57885. baseLayer: XRLayer;
  57886. }
  57887. interface XRFrameOfReference {
  57888. }
  57889. interface XRWebGLLayer extends XRLayer {
  57890. framebuffer: WebGLFramebuffer;
  57891. }
  57892. declare var XRWebGLLayer: {
  57893. prototype: XRWebGLLayer;
  57894. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57895. };
  57896. declare module "babylonjs" {
  57897. export * from "babylonjs/Legacy/legacy";
  57898. }
  57899. declare module BABYLON {
  57900. /** Alias type for value that can be null */
  57901. export type Nullable<T> = T | null;
  57902. /**
  57903. * Alias type for number that are floats
  57904. * @ignorenaming
  57905. */
  57906. export type float = number;
  57907. /**
  57908. * Alias type for number that are doubles.
  57909. * @ignorenaming
  57910. */
  57911. export type double = number;
  57912. /**
  57913. * Alias type for number that are integer
  57914. * @ignorenaming
  57915. */
  57916. export type int = number;
  57917. /** Alias type for number array or Float32Array */
  57918. export type FloatArray = number[] | Float32Array;
  57919. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57920. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57921. /**
  57922. * Alias for types that can be used by a Buffer or VertexBuffer.
  57923. */
  57924. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57925. /**
  57926. * Alias type for primitive types
  57927. * @ignorenaming
  57928. */
  57929. type Primitive = undefined | null | boolean | string | number | Function;
  57930. /**
  57931. * Type modifier to make all the properties of an object Readonly
  57932. */
  57933. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57934. /**
  57935. * Type modifier to make all the properties of an object Readonly recursively
  57936. */
  57937. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57938. /** @hidden */
  57939. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57940. }
  57941. /** @hidden */
  57942. /** @hidden */
  57943. type DeepImmutableObject<T> = {
  57944. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57945. };
  57946. }
  57947. declare module BABYLON {
  57948. /**
  57949. * Class containing a set of static utilities functions for arrays.
  57950. */
  57951. export class ArrayTools {
  57952. /**
  57953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57954. * @param size the number of element to construct and put in the array
  57955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57956. * @returns a new array filled with new objects
  57957. */
  57958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57959. }
  57960. }
  57961. declare module BABYLON {
  57962. /**
  57963. * Scalar computation library
  57964. */
  57965. export class Scalar {
  57966. /**
  57967. * Two pi constants convenient for computation.
  57968. */
  57969. static TwoPi: number;
  57970. /**
  57971. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57972. * @param a number
  57973. * @param b number
  57974. * @param epsilon (default = 1.401298E-45)
  57975. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57976. */
  57977. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57978. /**
  57979. * Returns a string : the upper case translation of the number i to hexadecimal.
  57980. * @param i number
  57981. * @returns the upper case translation of the number i to hexadecimal.
  57982. */
  57983. static ToHex(i: number): string;
  57984. /**
  57985. * Returns -1 if value is negative and +1 is value is positive.
  57986. * @param value the value
  57987. * @returns the value itself if it's equal to zero.
  57988. */
  57989. static Sign(value: number): number;
  57990. /**
  57991. * Returns the value itself if it's between min and max.
  57992. * Returns min if the value is lower than min.
  57993. * Returns max if the value is greater than max.
  57994. * @param value the value to clmap
  57995. * @param min the min value to clamp to (default: 0)
  57996. * @param max the max value to clamp to (default: 1)
  57997. * @returns the clamped value
  57998. */
  57999. static Clamp(value: number, min?: number, max?: number): number;
  58000. /**
  58001. * the log2 of value.
  58002. * @param value the value to compute log2 of
  58003. * @returns the log2 of value.
  58004. */
  58005. static Log2(value: number): number;
  58006. /**
  58007. * Loops the value, so that it is never larger than length and never smaller than 0.
  58008. *
  58009. * This is similar to the modulo operator but it works with floating point numbers.
  58010. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58011. * With t = 5 and length = 2.5, the result would be 0.0.
  58012. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58013. * @param value the value
  58014. * @param length the length
  58015. * @returns the looped value
  58016. */
  58017. static Repeat(value: number, length: number): number;
  58018. /**
  58019. * Normalize the value between 0.0 and 1.0 using min and max values
  58020. * @param value value to normalize
  58021. * @param min max to normalize between
  58022. * @param max min to normalize between
  58023. * @returns the normalized value
  58024. */
  58025. static Normalize(value: number, min: number, max: number): number;
  58026. /**
  58027. * Denormalize the value from 0.0 and 1.0 using min and max values
  58028. * @param normalized value to denormalize
  58029. * @param min max to denormalize between
  58030. * @param max min to denormalize between
  58031. * @returns the denormalized value
  58032. */
  58033. static Denormalize(normalized: number, min: number, max: number): number;
  58034. /**
  58035. * Calculates the shortest difference between two given angles given in degrees.
  58036. * @param current current angle in degrees
  58037. * @param target target angle in degrees
  58038. * @returns the delta
  58039. */
  58040. static DeltaAngle(current: number, target: number): number;
  58041. /**
  58042. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58043. * @param tx value
  58044. * @param length length
  58045. * @returns The returned value will move back and forth between 0 and length
  58046. */
  58047. static PingPong(tx: number, length: number): number;
  58048. /**
  58049. * Interpolates between min and max with smoothing at the limits.
  58050. *
  58051. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58052. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58053. * @param from from
  58054. * @param to to
  58055. * @param tx value
  58056. * @returns the smooth stepped value
  58057. */
  58058. static SmoothStep(from: number, to: number, tx: number): number;
  58059. /**
  58060. * Moves a value current towards target.
  58061. *
  58062. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58063. * Negative values of maxDelta pushes the value away from target.
  58064. * @param current current value
  58065. * @param target target value
  58066. * @param maxDelta max distance to move
  58067. * @returns resulting value
  58068. */
  58069. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58070. /**
  58071. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58072. *
  58073. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58074. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58075. * @param current current value
  58076. * @param target target value
  58077. * @param maxDelta max distance to move
  58078. * @returns resulting angle
  58079. */
  58080. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58081. /**
  58082. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58083. * @param start start value
  58084. * @param end target value
  58085. * @param amount amount to lerp between
  58086. * @returns the lerped value
  58087. */
  58088. static Lerp(start: number, end: number, amount: number): number;
  58089. /**
  58090. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58091. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58092. * @param start start value
  58093. * @param end target value
  58094. * @param amount amount to lerp between
  58095. * @returns the lerped value
  58096. */
  58097. static LerpAngle(start: number, end: number, amount: number): number;
  58098. /**
  58099. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58100. * @param a start value
  58101. * @param b target value
  58102. * @param value value between a and b
  58103. * @returns the inverseLerp value
  58104. */
  58105. static InverseLerp(a: number, b: number, value: number): number;
  58106. /**
  58107. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58108. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58109. * @param value1 spline value
  58110. * @param tangent1 spline value
  58111. * @param value2 spline value
  58112. * @param tangent2 spline value
  58113. * @param amount input value
  58114. * @returns hermite result
  58115. */
  58116. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58117. /**
  58118. * Returns a random float number between and min and max values
  58119. * @param min min value of random
  58120. * @param max max value of random
  58121. * @returns random value
  58122. */
  58123. static RandomRange(min: number, max: number): number;
  58124. /**
  58125. * This function returns percentage of a number in a given range.
  58126. *
  58127. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58128. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58129. * @param number to convert to percentage
  58130. * @param min min range
  58131. * @param max max range
  58132. * @returns the percentage
  58133. */
  58134. static RangeToPercent(number: number, min: number, max: number): number;
  58135. /**
  58136. * This function returns number that corresponds to the percentage in a given range.
  58137. *
  58138. * PercentToRange(0.34,0,100) will return 34.
  58139. * @param percent to convert to number
  58140. * @param min min range
  58141. * @param max max range
  58142. * @returns the number
  58143. */
  58144. static PercentToRange(percent: number, min: number, max: number): number;
  58145. /**
  58146. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58147. * @param angle The angle to normalize in radian.
  58148. * @return The converted angle.
  58149. */
  58150. static NormalizeRadians(angle: number): number;
  58151. }
  58152. }
  58153. declare module BABYLON {
  58154. /**
  58155. * Constant used to convert a value to gamma space
  58156. * @ignorenaming
  58157. */
  58158. export const ToGammaSpace: number;
  58159. /**
  58160. * Constant used to convert a value to linear space
  58161. * @ignorenaming
  58162. */
  58163. export const ToLinearSpace = 2.2;
  58164. /**
  58165. * Constant used to define the minimal number value in Babylon.js
  58166. * @ignorenaming
  58167. */
  58168. export const Epsilon = 0.001;
  58169. /**
  58170. * Class used to hold a RBG color
  58171. */
  58172. export class Color3 {
  58173. /**
  58174. * Defines the red component (between 0 and 1, default is 0)
  58175. */
  58176. r: number;
  58177. /**
  58178. * Defines the green component (between 0 and 1, default is 0)
  58179. */
  58180. g: number;
  58181. /**
  58182. * Defines the blue component (between 0 and 1, default is 0)
  58183. */
  58184. b: number;
  58185. /**
  58186. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58187. * @param r defines the red component (between 0 and 1, default is 0)
  58188. * @param g defines the green component (between 0 and 1, default is 0)
  58189. * @param b defines the blue component (between 0 and 1, default is 0)
  58190. */
  58191. constructor(
  58192. /**
  58193. * Defines the red component (between 0 and 1, default is 0)
  58194. */
  58195. r?: number,
  58196. /**
  58197. * Defines the green component (between 0 and 1, default is 0)
  58198. */
  58199. g?: number,
  58200. /**
  58201. * Defines the blue component (between 0 and 1, default is 0)
  58202. */
  58203. b?: number);
  58204. /**
  58205. * Creates a string with the Color3 current values
  58206. * @returns the string representation of the Color3 object
  58207. */
  58208. toString(): string;
  58209. /**
  58210. * Returns the string "Color3"
  58211. * @returns "Color3"
  58212. */
  58213. getClassName(): string;
  58214. /**
  58215. * Compute the Color3 hash code
  58216. * @returns an unique number that can be used to hash Color3 objects
  58217. */
  58218. getHashCode(): number;
  58219. /**
  58220. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58221. * @param array defines the array where to store the r,g,b components
  58222. * @param index defines an optional index in the target array to define where to start storing values
  58223. * @returns the current Color3 object
  58224. */
  58225. toArray(array: FloatArray, index?: number): Color3;
  58226. /**
  58227. * Returns a new Color4 object from the current Color3 and the given alpha
  58228. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58229. * @returns a new Color4 object
  58230. */
  58231. toColor4(alpha?: number): Color4;
  58232. /**
  58233. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58234. * @returns the new array
  58235. */
  58236. asArray(): number[];
  58237. /**
  58238. * Returns the luminance value
  58239. * @returns a float value
  58240. */
  58241. toLuminance(): number;
  58242. /**
  58243. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58244. * @param otherColor defines the second operand
  58245. * @returns the new Color3 object
  58246. */
  58247. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58248. /**
  58249. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58250. * @param otherColor defines the second operand
  58251. * @param result defines the Color3 object where to store the result
  58252. * @returns the current Color3
  58253. */
  58254. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58255. /**
  58256. * Determines equality between Color3 objects
  58257. * @param otherColor defines the second operand
  58258. * @returns true if the rgb values are equal to the given ones
  58259. */
  58260. equals(otherColor: DeepImmutable<Color3>): boolean;
  58261. /**
  58262. * Determines equality between the current Color3 object and a set of r,b,g values
  58263. * @param r defines the red component to check
  58264. * @param g defines the green component to check
  58265. * @param b defines the blue component to check
  58266. * @returns true if the rgb values are equal to the given ones
  58267. */
  58268. equalsFloats(r: number, g: number, b: number): boolean;
  58269. /**
  58270. * Multiplies in place each rgb value by scale
  58271. * @param scale defines the scaling factor
  58272. * @returns the updated Color3
  58273. */
  58274. scale(scale: number): Color3;
  58275. /**
  58276. * Multiplies the rgb values by scale and stores the result into "result"
  58277. * @param scale defines the scaling factor
  58278. * @param result defines the Color3 object where to store the result
  58279. * @returns the unmodified current Color3
  58280. */
  58281. scaleToRef(scale: number, result: Color3): Color3;
  58282. /**
  58283. * Scale the current Color3 values by a factor and add the result to a given Color3
  58284. * @param scale defines the scale factor
  58285. * @param result defines color to store the result into
  58286. * @returns the unmodified current Color3
  58287. */
  58288. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58289. /**
  58290. * Clamps the rgb values by the min and max values and stores the result into "result"
  58291. * @param min defines minimum clamping value (default is 0)
  58292. * @param max defines maximum clamping value (default is 1)
  58293. * @param result defines color to store the result into
  58294. * @returns the original Color3
  58295. */
  58296. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58297. /**
  58298. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58299. * @param otherColor defines the second operand
  58300. * @returns the new Color3
  58301. */
  58302. add(otherColor: DeepImmutable<Color3>): Color3;
  58303. /**
  58304. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58305. * @param otherColor defines the second operand
  58306. * @param result defines Color3 object to store the result into
  58307. * @returns the unmodified current Color3
  58308. */
  58309. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58310. /**
  58311. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58312. * @param otherColor defines the second operand
  58313. * @returns the new Color3
  58314. */
  58315. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58316. /**
  58317. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58318. * @param otherColor defines the second operand
  58319. * @param result defines Color3 object to store the result into
  58320. * @returns the unmodified current Color3
  58321. */
  58322. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58323. /**
  58324. * Copy the current object
  58325. * @returns a new Color3 copied the current one
  58326. */
  58327. clone(): Color3;
  58328. /**
  58329. * Copies the rgb values from the source in the current Color3
  58330. * @param source defines the source Color3 object
  58331. * @returns the updated Color3 object
  58332. */
  58333. copyFrom(source: DeepImmutable<Color3>): Color3;
  58334. /**
  58335. * Updates the Color3 rgb values from the given floats
  58336. * @param r defines the red component to read from
  58337. * @param g defines the green component to read from
  58338. * @param b defines the blue component to read from
  58339. * @returns the current Color3 object
  58340. */
  58341. copyFromFloats(r: number, g: number, b: number): Color3;
  58342. /**
  58343. * Updates the Color3 rgb values from the given floats
  58344. * @param r defines the red component to read from
  58345. * @param g defines the green component to read from
  58346. * @param b defines the blue component to read from
  58347. * @returns the current Color3 object
  58348. */
  58349. set(r: number, g: number, b: number): Color3;
  58350. /**
  58351. * Compute the Color3 hexadecimal code as a string
  58352. * @returns a string containing the hexadecimal representation of the Color3 object
  58353. */
  58354. toHexString(): string;
  58355. /**
  58356. * Computes a new Color3 converted from the current one to linear space
  58357. * @returns a new Color3 object
  58358. */
  58359. toLinearSpace(): Color3;
  58360. /**
  58361. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58362. * @param convertedColor defines the Color3 object where to store the linear space version
  58363. * @returns the unmodified Color3
  58364. */
  58365. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58366. /**
  58367. * Computes a new Color3 converted from the current one to gamma space
  58368. * @returns a new Color3 object
  58369. */
  58370. toGammaSpace(): Color3;
  58371. /**
  58372. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58373. * @param convertedColor defines the Color3 object where to store the gamma space version
  58374. * @returns the unmodified Color3
  58375. */
  58376. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58377. private static _BlackReadOnly;
  58378. /**
  58379. * Creates a new Color3 from the string containing valid hexadecimal values
  58380. * @param hex defines a string containing valid hexadecimal values
  58381. * @returns a new Color3 object
  58382. */
  58383. static FromHexString(hex: string): Color3;
  58384. /**
  58385. * Creates a new Vector3 from the starting index of the given array
  58386. * @param array defines the source array
  58387. * @param offset defines an offset in the source array
  58388. * @returns a new Color3 object
  58389. */
  58390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58391. /**
  58392. * Creates a new Color3 from integer values (< 256)
  58393. * @param r defines the red component to read from (value between 0 and 255)
  58394. * @param g defines the green component to read from (value between 0 and 255)
  58395. * @param b defines the blue component to read from (value between 0 and 255)
  58396. * @returns a new Color3 object
  58397. */
  58398. static FromInts(r: number, g: number, b: number): Color3;
  58399. /**
  58400. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58401. * @param start defines the start Color3 value
  58402. * @param end defines the end Color3 value
  58403. * @param amount defines the gradient value between start and end
  58404. * @returns a new Color3 object
  58405. */
  58406. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58407. /**
  58408. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58409. * @param left defines the start value
  58410. * @param right defines the end value
  58411. * @param amount defines the gradient factor
  58412. * @param result defines the Color3 object where to store the result
  58413. */
  58414. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58415. /**
  58416. * Returns a Color3 value containing a red color
  58417. * @returns a new Color3 object
  58418. */
  58419. static Red(): Color3;
  58420. /**
  58421. * Returns a Color3 value containing a green color
  58422. * @returns a new Color3 object
  58423. */
  58424. static Green(): Color3;
  58425. /**
  58426. * Returns a Color3 value containing a blue color
  58427. * @returns a new Color3 object
  58428. */
  58429. static Blue(): Color3;
  58430. /**
  58431. * Returns a Color3 value containing a black color
  58432. * @returns a new Color3 object
  58433. */
  58434. static Black(): Color3;
  58435. /**
  58436. * Gets a Color3 value containing a black color that must not be updated
  58437. */
  58438. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58439. /**
  58440. * Returns a Color3 value containing a white color
  58441. * @returns a new Color3 object
  58442. */
  58443. static White(): Color3;
  58444. /**
  58445. * Returns a Color3 value containing a purple color
  58446. * @returns a new Color3 object
  58447. */
  58448. static Purple(): Color3;
  58449. /**
  58450. * Returns a Color3 value containing a magenta color
  58451. * @returns a new Color3 object
  58452. */
  58453. static Magenta(): Color3;
  58454. /**
  58455. * Returns a Color3 value containing a yellow color
  58456. * @returns a new Color3 object
  58457. */
  58458. static Yellow(): Color3;
  58459. /**
  58460. * Returns a Color3 value containing a gray color
  58461. * @returns a new Color3 object
  58462. */
  58463. static Gray(): Color3;
  58464. /**
  58465. * Returns a Color3 value containing a teal color
  58466. * @returns a new Color3 object
  58467. */
  58468. static Teal(): Color3;
  58469. /**
  58470. * Returns a Color3 value containing a random color
  58471. * @returns a new Color3 object
  58472. */
  58473. static Random(): Color3;
  58474. }
  58475. /**
  58476. * Class used to hold a RBGA color
  58477. */
  58478. export class Color4 {
  58479. /**
  58480. * Defines the red component (between 0 and 1, default is 0)
  58481. */
  58482. r: number;
  58483. /**
  58484. * Defines the green component (between 0 and 1, default is 0)
  58485. */
  58486. g: number;
  58487. /**
  58488. * Defines the blue component (between 0 and 1, default is 0)
  58489. */
  58490. b: number;
  58491. /**
  58492. * Defines the alpha component (between 0 and 1, default is 1)
  58493. */
  58494. a: number;
  58495. /**
  58496. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58497. * @param r defines the red component (between 0 and 1, default is 0)
  58498. * @param g defines the green component (between 0 and 1, default is 0)
  58499. * @param b defines the blue component (between 0 and 1, default is 0)
  58500. * @param a defines the alpha component (between 0 and 1, default is 1)
  58501. */
  58502. constructor(
  58503. /**
  58504. * Defines the red component (between 0 and 1, default is 0)
  58505. */
  58506. r?: number,
  58507. /**
  58508. * Defines the green component (between 0 and 1, default is 0)
  58509. */
  58510. g?: number,
  58511. /**
  58512. * Defines the blue component (between 0 and 1, default is 0)
  58513. */
  58514. b?: number,
  58515. /**
  58516. * Defines the alpha component (between 0 and 1, default is 1)
  58517. */
  58518. a?: number);
  58519. /**
  58520. * Adds in place the given Color4 values to the current Color4 object
  58521. * @param right defines the second operand
  58522. * @returns the current updated Color4 object
  58523. */
  58524. addInPlace(right: DeepImmutable<Color4>): Color4;
  58525. /**
  58526. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58527. * @returns the new array
  58528. */
  58529. asArray(): number[];
  58530. /**
  58531. * Stores from the starting index in the given array the Color4 successive values
  58532. * @param array defines the array where to store the r,g,b components
  58533. * @param index defines an optional index in the target array to define where to start storing values
  58534. * @returns the current Color4 object
  58535. */
  58536. toArray(array: number[], index?: number): Color4;
  58537. /**
  58538. * Determines equality between Color4 objects
  58539. * @param otherColor defines the second operand
  58540. * @returns true if the rgba values are equal to the given ones
  58541. */
  58542. equals(otherColor: DeepImmutable<Color4>): boolean;
  58543. /**
  58544. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58545. * @param right defines the second operand
  58546. * @returns a new Color4 object
  58547. */
  58548. add(right: DeepImmutable<Color4>): Color4;
  58549. /**
  58550. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58551. * @param right defines the second operand
  58552. * @returns a new Color4 object
  58553. */
  58554. subtract(right: DeepImmutable<Color4>): Color4;
  58555. /**
  58556. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58557. * @param right defines the second operand
  58558. * @param result defines the Color4 object where to store the result
  58559. * @returns the current Color4 object
  58560. */
  58561. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58562. /**
  58563. * Creates a new Color4 with the current Color4 values multiplied by scale
  58564. * @param scale defines the scaling factor to apply
  58565. * @returns a new Color4 object
  58566. */
  58567. scale(scale: number): Color4;
  58568. /**
  58569. * Multiplies the current Color4 values by scale and stores the result in "result"
  58570. * @param scale defines the scaling factor to apply
  58571. * @param result defines the Color4 object where to store the result
  58572. * @returns the current unmodified Color4
  58573. */
  58574. scaleToRef(scale: number, result: Color4): Color4;
  58575. /**
  58576. * Scale the current Color4 values by a factor and add the result to a given Color4
  58577. * @param scale defines the scale factor
  58578. * @param result defines the Color4 object where to store the result
  58579. * @returns the unmodified current Color4
  58580. */
  58581. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58582. /**
  58583. * Clamps the rgb values by the min and max values and stores the result into "result"
  58584. * @param min defines minimum clamping value (default is 0)
  58585. * @param max defines maximum clamping value (default is 1)
  58586. * @param result defines color to store the result into.
  58587. * @returns the cuurent Color4
  58588. */
  58589. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58590. /**
  58591. * Multipy an Color4 value by another and return a new Color4 object
  58592. * @param color defines the Color4 value to multiply by
  58593. * @returns a new Color4 object
  58594. */
  58595. multiply(color: Color4): Color4;
  58596. /**
  58597. * Multipy a Color4 value by another and push the result in a reference value
  58598. * @param color defines the Color4 value to multiply by
  58599. * @param result defines the Color4 to fill the result in
  58600. * @returns the result Color4
  58601. */
  58602. multiplyToRef(color: Color4, result: Color4): Color4;
  58603. /**
  58604. * Creates a string with the Color4 current values
  58605. * @returns the string representation of the Color4 object
  58606. */
  58607. toString(): string;
  58608. /**
  58609. * Returns the string "Color4"
  58610. * @returns "Color4"
  58611. */
  58612. getClassName(): string;
  58613. /**
  58614. * Compute the Color4 hash code
  58615. * @returns an unique number that can be used to hash Color4 objects
  58616. */
  58617. getHashCode(): number;
  58618. /**
  58619. * Creates a new Color4 copied from the current one
  58620. * @returns a new Color4 object
  58621. */
  58622. clone(): Color4;
  58623. /**
  58624. * Copies the given Color4 values into the current one
  58625. * @param source defines the source Color4 object
  58626. * @returns the current updated Color4 object
  58627. */
  58628. copyFrom(source: Color4): Color4;
  58629. /**
  58630. * Copies the given float values into the current one
  58631. * @param r defines the red component to read from
  58632. * @param g defines the green component to read from
  58633. * @param b defines the blue component to read from
  58634. * @param a defines the alpha component to read from
  58635. * @returns the current updated Color4 object
  58636. */
  58637. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58638. /**
  58639. * Copies the given float values into the current one
  58640. * @param r defines the red component to read from
  58641. * @param g defines the green component to read from
  58642. * @param b defines the blue component to read from
  58643. * @param a defines the alpha component to read from
  58644. * @returns the current updated Color4 object
  58645. */
  58646. set(r: number, g: number, b: number, a: number): Color4;
  58647. /**
  58648. * Compute the Color4 hexadecimal code as a string
  58649. * @returns a string containing the hexadecimal representation of the Color4 object
  58650. */
  58651. toHexString(): string;
  58652. /**
  58653. * Computes a new Color4 converted from the current one to linear space
  58654. * @returns a new Color4 object
  58655. */
  58656. toLinearSpace(): Color4;
  58657. /**
  58658. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58659. * @param convertedColor defines the Color4 object where to store the linear space version
  58660. * @returns the unmodified Color4
  58661. */
  58662. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58663. /**
  58664. * Computes a new Color4 converted from the current one to gamma space
  58665. * @returns a new Color4 object
  58666. */
  58667. toGammaSpace(): Color4;
  58668. /**
  58669. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58670. * @param convertedColor defines the Color4 object where to store the gamma space version
  58671. * @returns the unmodified Color4
  58672. */
  58673. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58674. /**
  58675. * Creates a new Color4 from the string containing valid hexadecimal values
  58676. * @param hex defines a string containing valid hexadecimal values
  58677. * @returns a new Color4 object
  58678. */
  58679. static FromHexString(hex: string): Color4;
  58680. /**
  58681. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58682. * @param left defines the start value
  58683. * @param right defines the end value
  58684. * @param amount defines the gradient factor
  58685. * @returns a new Color4 object
  58686. */
  58687. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58688. /**
  58689. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58690. * @param left defines the start value
  58691. * @param right defines the end value
  58692. * @param amount defines the gradient factor
  58693. * @param result defines the Color4 object where to store data
  58694. */
  58695. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58696. /**
  58697. * Creates a new Color4 from a Color3 and an alpha value
  58698. * @param color3 defines the source Color3 to read from
  58699. * @param alpha defines the alpha component (1.0 by default)
  58700. * @returns a new Color4 object
  58701. */
  58702. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58703. /**
  58704. * Creates a new Color4 from the starting index element of the given array
  58705. * @param array defines the source array to read from
  58706. * @param offset defines the offset in the source array
  58707. * @returns a new Color4 object
  58708. */
  58709. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58710. /**
  58711. * Creates a new Color3 from integer values (< 256)
  58712. * @param r defines the red component to read from (value between 0 and 255)
  58713. * @param g defines the green component to read from (value between 0 and 255)
  58714. * @param b defines the blue component to read from (value between 0 and 255)
  58715. * @param a defines the alpha component to read from (value between 0 and 255)
  58716. * @returns a new Color3 object
  58717. */
  58718. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58719. /**
  58720. * Check the content of a given array and convert it to an array containing RGBA data
  58721. * If the original array was already containing count * 4 values then it is returned directly
  58722. * @param colors defines the array to check
  58723. * @param count defines the number of RGBA data to expect
  58724. * @returns an array containing count * 4 values (RGBA)
  58725. */
  58726. static CheckColors4(colors: number[], count: number): number[];
  58727. }
  58728. /**
  58729. * Class representing a vector containing 2 coordinates
  58730. */
  58731. export class Vector2 {
  58732. /** defines the first coordinate */
  58733. x: number;
  58734. /** defines the second coordinate */
  58735. y: number;
  58736. /**
  58737. * Creates a new Vector2 from the given x and y coordinates
  58738. * @param x defines the first coordinate
  58739. * @param y defines the second coordinate
  58740. */
  58741. constructor(
  58742. /** defines the first coordinate */
  58743. x?: number,
  58744. /** defines the second coordinate */
  58745. y?: number);
  58746. /**
  58747. * Gets a string with the Vector2 coordinates
  58748. * @returns a string with the Vector2 coordinates
  58749. */
  58750. toString(): string;
  58751. /**
  58752. * Gets class name
  58753. * @returns the string "Vector2"
  58754. */
  58755. getClassName(): string;
  58756. /**
  58757. * Gets current vector hash code
  58758. * @returns the Vector2 hash code as a number
  58759. */
  58760. getHashCode(): number;
  58761. /**
  58762. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58763. * @param array defines the source array
  58764. * @param index defines the offset in source array
  58765. * @returns the current Vector2
  58766. */
  58767. toArray(array: FloatArray, index?: number): Vector2;
  58768. /**
  58769. * Copy the current vector to an array
  58770. * @returns a new array with 2 elements: the Vector2 coordinates.
  58771. */
  58772. asArray(): number[];
  58773. /**
  58774. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58775. * @param source defines the source Vector2
  58776. * @returns the current updated Vector2
  58777. */
  58778. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58779. /**
  58780. * Sets the Vector2 coordinates with the given floats
  58781. * @param x defines the first coordinate
  58782. * @param y defines the second coordinate
  58783. * @returns the current updated Vector2
  58784. */
  58785. copyFromFloats(x: number, y: number): Vector2;
  58786. /**
  58787. * Sets the Vector2 coordinates with the given floats
  58788. * @param x defines the first coordinate
  58789. * @param y defines the second coordinate
  58790. * @returns the current updated Vector2
  58791. */
  58792. set(x: number, y: number): Vector2;
  58793. /**
  58794. * Add another vector with the current one
  58795. * @param otherVector defines the other vector
  58796. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58797. */
  58798. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58799. /**
  58800. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58801. * @param otherVector defines the other vector
  58802. * @param result defines the target vector
  58803. * @returns the unmodified current Vector2
  58804. */
  58805. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58806. /**
  58807. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58808. * @param otherVector defines the other vector
  58809. * @returns the current updated Vector2
  58810. */
  58811. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58812. /**
  58813. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58814. * @param otherVector defines the other vector
  58815. * @returns a new Vector2
  58816. */
  58817. addVector3(otherVector: Vector3): Vector2;
  58818. /**
  58819. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58820. * @param otherVector defines the other vector
  58821. * @returns a new Vector2
  58822. */
  58823. subtract(otherVector: Vector2): Vector2;
  58824. /**
  58825. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58826. * @param otherVector defines the other vector
  58827. * @param result defines the target vector
  58828. * @returns the unmodified current Vector2
  58829. */
  58830. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58831. /**
  58832. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58833. * @param otherVector defines the other vector
  58834. * @returns the current updated Vector2
  58835. */
  58836. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58837. /**
  58838. * Multiplies in place the current Vector2 coordinates by the given ones
  58839. * @param otherVector defines the other vector
  58840. * @returns the current updated Vector2
  58841. */
  58842. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58843. /**
  58844. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58845. * @param otherVector defines the other vector
  58846. * @returns a new Vector2
  58847. */
  58848. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58849. /**
  58850. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58851. * @param otherVector defines the other vector
  58852. * @param result defines the target vector
  58853. * @returns the unmodified current Vector2
  58854. */
  58855. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58856. /**
  58857. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58858. * @param x defines the first coordinate
  58859. * @param y defines the second coordinate
  58860. * @returns a new Vector2
  58861. */
  58862. multiplyByFloats(x: number, y: number): Vector2;
  58863. /**
  58864. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58865. * @param otherVector defines the other vector
  58866. * @returns a new Vector2
  58867. */
  58868. divide(otherVector: Vector2): Vector2;
  58869. /**
  58870. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58871. * @param otherVector defines the other vector
  58872. * @param result defines the target vector
  58873. * @returns the unmodified current Vector2
  58874. */
  58875. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58876. /**
  58877. * Divides the current Vector2 coordinates by the given ones
  58878. * @param otherVector defines the other vector
  58879. * @returns the current updated Vector2
  58880. */
  58881. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58882. /**
  58883. * Gets a new Vector2 with current Vector2 negated coordinates
  58884. * @returns a new Vector2
  58885. */
  58886. negate(): Vector2;
  58887. /**
  58888. * Multiply the Vector2 coordinates by scale
  58889. * @param scale defines the scaling factor
  58890. * @returns the current updated Vector2
  58891. */
  58892. scaleInPlace(scale: number): Vector2;
  58893. /**
  58894. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58895. * @param scale defines the scaling factor
  58896. * @returns a new Vector2
  58897. */
  58898. scale(scale: number): Vector2;
  58899. /**
  58900. * Scale the current Vector2 values by a factor to a given Vector2
  58901. * @param scale defines the scale factor
  58902. * @param result defines the Vector2 object where to store the result
  58903. * @returns the unmodified current Vector2
  58904. */
  58905. scaleToRef(scale: number, result: Vector2): Vector2;
  58906. /**
  58907. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58908. * @param scale defines the scale factor
  58909. * @param result defines the Vector2 object where to store the result
  58910. * @returns the unmodified current Vector2
  58911. */
  58912. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58913. /**
  58914. * Gets a boolean if two vectors are equals
  58915. * @param otherVector defines the other vector
  58916. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58917. */
  58918. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58919. /**
  58920. * Gets a boolean if two vectors are equals (using an epsilon value)
  58921. * @param otherVector defines the other vector
  58922. * @param epsilon defines the minimal distance to consider equality
  58923. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58924. */
  58925. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58926. /**
  58927. * Gets a new Vector2 from current Vector2 floored values
  58928. * @returns a new Vector2
  58929. */
  58930. floor(): Vector2;
  58931. /**
  58932. * Gets a new Vector2 from current Vector2 floored values
  58933. * @returns a new Vector2
  58934. */
  58935. fract(): Vector2;
  58936. /**
  58937. * Gets the length of the vector
  58938. * @returns the vector length (float)
  58939. */
  58940. length(): number;
  58941. /**
  58942. * Gets the vector squared length
  58943. * @returns the vector squared length (float)
  58944. */
  58945. lengthSquared(): number;
  58946. /**
  58947. * Normalize the vector
  58948. * @returns the current updated Vector2
  58949. */
  58950. normalize(): Vector2;
  58951. /**
  58952. * Gets a new Vector2 copied from the Vector2
  58953. * @returns a new Vector2
  58954. */
  58955. clone(): Vector2;
  58956. /**
  58957. * Gets a new Vector2(0, 0)
  58958. * @returns a new Vector2
  58959. */
  58960. static Zero(): Vector2;
  58961. /**
  58962. * Gets a new Vector2(1, 1)
  58963. * @returns a new Vector2
  58964. */
  58965. static One(): Vector2;
  58966. /**
  58967. * Gets a new Vector2 set from the given index element of the given array
  58968. * @param array defines the data source
  58969. * @param offset defines the offset in the data source
  58970. * @returns a new Vector2
  58971. */
  58972. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58973. /**
  58974. * Sets "result" from the given index element of the given array
  58975. * @param array defines the data source
  58976. * @param offset defines the offset in the data source
  58977. * @param result defines the target vector
  58978. */
  58979. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58980. /**
  58981. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58982. * @param value1 defines 1st point of control
  58983. * @param value2 defines 2nd point of control
  58984. * @param value3 defines 3rd point of control
  58985. * @param value4 defines 4th point of control
  58986. * @param amount defines the interpolation factor
  58987. * @returns a new Vector2
  58988. */
  58989. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58990. /**
  58991. * 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".
  58992. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58993. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58994. * @param value defines the value to clamp
  58995. * @param min defines the lower limit
  58996. * @param max defines the upper limit
  58997. * @returns a new Vector2
  58998. */
  58999. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59000. /**
  59001. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59002. * @param value1 defines the 1st control point
  59003. * @param tangent1 defines the outgoing tangent
  59004. * @param value2 defines the 2nd control point
  59005. * @param tangent2 defines the incoming tangent
  59006. * @param amount defines the interpolation factor
  59007. * @returns a new Vector2
  59008. */
  59009. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59010. /**
  59011. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59012. * @param start defines the start vector
  59013. * @param end defines the end vector
  59014. * @param amount defines the interpolation factor
  59015. * @returns a new Vector2
  59016. */
  59017. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59018. /**
  59019. * Gets the dot product of the vector "left" and the vector "right"
  59020. * @param left defines first vector
  59021. * @param right defines second vector
  59022. * @returns the dot product (float)
  59023. */
  59024. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59025. /**
  59026. * Returns a new Vector2 equal to the normalized given vector
  59027. * @param vector defines the vector to normalize
  59028. * @returns a new Vector2
  59029. */
  59030. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59031. /**
  59032. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59033. * @param left defines 1st vector
  59034. * @param right defines 2nd vector
  59035. * @returns a new Vector2
  59036. */
  59037. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59038. /**
  59039. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59040. * @param left defines 1st vector
  59041. * @param right defines 2nd vector
  59042. * @returns a new Vector2
  59043. */
  59044. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59045. /**
  59046. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59047. * @param vector defines the vector to transform
  59048. * @param transformation defines the matrix to apply
  59049. * @returns a new Vector2
  59050. */
  59051. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59052. /**
  59053. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59054. * @param vector defines the vector to transform
  59055. * @param transformation defines the matrix to apply
  59056. * @param result defines the target vector
  59057. */
  59058. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59059. /**
  59060. * Determines if a given vector is included in a triangle
  59061. * @param p defines the vector to test
  59062. * @param p0 defines 1st triangle point
  59063. * @param p1 defines 2nd triangle point
  59064. * @param p2 defines 3rd triangle point
  59065. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59066. */
  59067. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59068. /**
  59069. * Gets the distance between the vectors "value1" and "value2"
  59070. * @param value1 defines first vector
  59071. * @param value2 defines second vector
  59072. * @returns the distance between vectors
  59073. */
  59074. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59075. /**
  59076. * Returns the squared distance between the vectors "value1" and "value2"
  59077. * @param value1 defines first vector
  59078. * @param value2 defines second vector
  59079. * @returns the squared distance between vectors
  59080. */
  59081. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59082. /**
  59083. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59084. * @param value1 defines first vector
  59085. * @param value2 defines second vector
  59086. * @returns a new Vector2
  59087. */
  59088. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59089. /**
  59090. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59091. * @param p defines the middle point
  59092. * @param segA defines one point of the segment
  59093. * @param segB defines the other point of the segment
  59094. * @returns the shortest distance
  59095. */
  59096. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59097. }
  59098. /**
  59099. * Classed used to store (x,y,z) vector representation
  59100. * A Vector3 is the main object used in 3D geometry
  59101. * It can represent etiher the coordinates of a point the space, either a direction
  59102. * Reminder: js uses a left handed forward facing system
  59103. */
  59104. export class Vector3 {
  59105. /**
  59106. * Defines the first coordinates (on X axis)
  59107. */
  59108. x: number;
  59109. /**
  59110. * Defines the second coordinates (on Y axis)
  59111. */
  59112. y: number;
  59113. /**
  59114. * Defines the third coordinates (on Z axis)
  59115. */
  59116. z: number;
  59117. private static _UpReadOnly;
  59118. /**
  59119. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59120. * @param x defines the first coordinates (on X axis)
  59121. * @param y defines the second coordinates (on Y axis)
  59122. * @param z defines the third coordinates (on Z axis)
  59123. */
  59124. constructor(
  59125. /**
  59126. * Defines the first coordinates (on X axis)
  59127. */
  59128. x?: number,
  59129. /**
  59130. * Defines the second coordinates (on Y axis)
  59131. */
  59132. y?: number,
  59133. /**
  59134. * Defines the third coordinates (on Z axis)
  59135. */
  59136. z?: number);
  59137. /**
  59138. * Creates a string representation of the Vector3
  59139. * @returns a string with the Vector3 coordinates.
  59140. */
  59141. toString(): string;
  59142. /**
  59143. * Gets the class name
  59144. * @returns the string "Vector3"
  59145. */
  59146. getClassName(): string;
  59147. /**
  59148. * Creates the Vector3 hash code
  59149. * @returns a number which tends to be unique between Vector3 instances
  59150. */
  59151. getHashCode(): number;
  59152. /**
  59153. * Creates an array containing three elements : the coordinates of the Vector3
  59154. * @returns a new array of numbers
  59155. */
  59156. asArray(): number[];
  59157. /**
  59158. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59159. * @param array defines the destination array
  59160. * @param index defines the offset in the destination array
  59161. * @returns the current Vector3
  59162. */
  59163. toArray(array: FloatArray, index?: number): Vector3;
  59164. /**
  59165. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59166. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59167. */
  59168. toQuaternion(): Quaternion;
  59169. /**
  59170. * Adds the given vector to the current Vector3
  59171. * @param otherVector defines the second operand
  59172. * @returns the current updated Vector3
  59173. */
  59174. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59175. /**
  59176. * Adds the given coordinates to the current Vector3
  59177. * @param x defines the x coordinate of the operand
  59178. * @param y defines the y coordinate of the operand
  59179. * @param z defines the z coordinate of the operand
  59180. * @returns the current updated Vector3
  59181. */
  59182. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59183. /**
  59184. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59185. * @param otherVector defines the second operand
  59186. * @returns the resulting Vector3
  59187. */
  59188. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59189. /**
  59190. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59191. * @param otherVector defines the second operand
  59192. * @param result defines the Vector3 object where to store the result
  59193. * @returns the current Vector3
  59194. */
  59195. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59196. /**
  59197. * Subtract the given vector from the current Vector3
  59198. * @param otherVector defines the second operand
  59199. * @returns the current updated Vector3
  59200. */
  59201. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59202. /**
  59203. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59204. * @param otherVector defines the second operand
  59205. * @returns the resulting Vector3
  59206. */
  59207. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59208. /**
  59209. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59210. * @param otherVector defines the second operand
  59211. * @param result defines the Vector3 object where to store the result
  59212. * @returns the current Vector3
  59213. */
  59214. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59215. /**
  59216. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59217. * @param x defines the x coordinate of the operand
  59218. * @param y defines the y coordinate of the operand
  59219. * @param z defines the z coordinate of the operand
  59220. * @returns the resulting Vector3
  59221. */
  59222. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59223. /**
  59224. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59225. * @param x defines the x coordinate of the operand
  59226. * @param y defines the y coordinate of the operand
  59227. * @param z defines the z coordinate of the operand
  59228. * @param result defines the Vector3 object where to store the result
  59229. * @returns the current Vector3
  59230. */
  59231. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59232. /**
  59233. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59234. * @returns a new Vector3
  59235. */
  59236. negate(): Vector3;
  59237. /**
  59238. * Multiplies the Vector3 coordinates by the float "scale"
  59239. * @param scale defines the multiplier factor
  59240. * @returns the current updated Vector3
  59241. */
  59242. scaleInPlace(scale: number): Vector3;
  59243. /**
  59244. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59245. * @param scale defines the multiplier factor
  59246. * @returns a new Vector3
  59247. */
  59248. scale(scale: number): Vector3;
  59249. /**
  59250. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59251. * @param scale defines the multiplier factor
  59252. * @param result defines the Vector3 object where to store the result
  59253. * @returns the current Vector3
  59254. */
  59255. scaleToRef(scale: number, result: Vector3): Vector3;
  59256. /**
  59257. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59258. * @param scale defines the scale factor
  59259. * @param result defines the Vector3 object where to store the result
  59260. * @returns the unmodified current Vector3
  59261. */
  59262. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59263. /**
  59264. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59265. * @param otherVector defines the second operand
  59266. * @returns true if both vectors are equals
  59267. */
  59268. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59269. /**
  59270. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59271. * @param otherVector defines the second operand
  59272. * @param epsilon defines the minimal distance to define values as equals
  59273. * @returns true if both vectors are distant less than epsilon
  59274. */
  59275. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59276. /**
  59277. * Returns true if the current Vector3 coordinates equals the given floats
  59278. * @param x defines the x coordinate of the operand
  59279. * @param y defines the y coordinate of the operand
  59280. * @param z defines the z coordinate of the operand
  59281. * @returns true if both vectors are equals
  59282. */
  59283. equalsToFloats(x: number, y: number, z: number): boolean;
  59284. /**
  59285. * Multiplies the current Vector3 coordinates by the given ones
  59286. * @param otherVector defines the second operand
  59287. * @returns the current updated Vector3
  59288. */
  59289. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59290. /**
  59291. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59292. * @param otherVector defines the second operand
  59293. * @returns the new Vector3
  59294. */
  59295. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59296. /**
  59297. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59298. * @param otherVector defines the second operand
  59299. * @param result defines the Vector3 object where to store the result
  59300. * @returns the current Vector3
  59301. */
  59302. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59303. /**
  59304. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59305. * @param x defines the x coordinate of the operand
  59306. * @param y defines the y coordinate of the operand
  59307. * @param z defines the z coordinate of the operand
  59308. * @returns the new Vector3
  59309. */
  59310. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59311. /**
  59312. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59313. * @param otherVector defines the second operand
  59314. * @returns the new Vector3
  59315. */
  59316. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59317. /**
  59318. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59319. * @param otherVector defines the second operand
  59320. * @param result defines the Vector3 object where to store the result
  59321. * @returns the current Vector3
  59322. */
  59323. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59324. /**
  59325. * Divides the current Vector3 coordinates by the given ones.
  59326. * @param otherVector defines the second operand
  59327. * @returns the current updated Vector3
  59328. */
  59329. divideInPlace(otherVector: Vector3): Vector3;
  59330. /**
  59331. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59332. * @param other defines the second operand
  59333. * @returns the current updated Vector3
  59334. */
  59335. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59336. /**
  59337. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59338. * @param other defines the second operand
  59339. * @returns the current updated Vector3
  59340. */
  59341. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59342. /**
  59343. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59344. * @param x defines the x coordinate of the operand
  59345. * @param y defines the y coordinate of the operand
  59346. * @param z defines the z coordinate of the operand
  59347. * @returns the current updated Vector3
  59348. */
  59349. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59350. /**
  59351. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59352. * @param x defines the x coordinate of the operand
  59353. * @param y defines the y coordinate of the operand
  59354. * @param z defines the z coordinate of the operand
  59355. * @returns the current updated Vector3
  59356. */
  59357. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59358. /**
  59359. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59360. * Check if is non uniform within a certain amount of decimal places to account for this
  59361. * @param epsilon the amount the values can differ
  59362. * @returns if the the vector is non uniform to a certain number of decimal places
  59363. */
  59364. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59365. /**
  59366. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59367. */
  59368. readonly isNonUniform: boolean;
  59369. /**
  59370. * Gets a new Vector3 from current Vector3 floored values
  59371. * @returns a new Vector3
  59372. */
  59373. floor(): Vector3;
  59374. /**
  59375. * Gets a new Vector3 from current Vector3 floored values
  59376. * @returns a new Vector3
  59377. */
  59378. fract(): Vector3;
  59379. /**
  59380. * Gets the length of the Vector3
  59381. * @returns the length of the Vecto3
  59382. */
  59383. length(): number;
  59384. /**
  59385. * Gets the squared length of the Vector3
  59386. * @returns squared length of the Vector3
  59387. */
  59388. lengthSquared(): number;
  59389. /**
  59390. * Normalize the current Vector3.
  59391. * Please note that this is an in place operation.
  59392. * @returns the current updated Vector3
  59393. */
  59394. normalize(): Vector3;
  59395. /**
  59396. * Reorders the x y z properties of the vector in place
  59397. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59398. * @returns the current updated vector
  59399. */
  59400. reorderInPlace(order: string): this;
  59401. /**
  59402. * Rotates the vector around 0,0,0 by a quaternion
  59403. * @param quaternion the rotation quaternion
  59404. * @param result vector to store the result
  59405. * @returns the resulting vector
  59406. */
  59407. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59408. /**
  59409. * Rotates a vector around a given point
  59410. * @param quaternion the rotation quaternion
  59411. * @param point the point to rotate around
  59412. * @param result vector to store the result
  59413. * @returns the resulting vector
  59414. */
  59415. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59416. /**
  59417. * Normalize the current Vector3 with the given input length.
  59418. * Please note that this is an in place operation.
  59419. * @param len the length of the vector
  59420. * @returns the current updated Vector3
  59421. */
  59422. normalizeFromLength(len: number): Vector3;
  59423. /**
  59424. * Normalize the current Vector3 to a new vector
  59425. * @returns the new Vector3
  59426. */
  59427. normalizeToNew(): Vector3;
  59428. /**
  59429. * Normalize the current Vector3 to the reference
  59430. * @param reference define the Vector3 to update
  59431. * @returns the updated Vector3
  59432. */
  59433. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59434. /**
  59435. * Creates a new Vector3 copied from the current Vector3
  59436. * @returns the new Vector3
  59437. */
  59438. clone(): Vector3;
  59439. /**
  59440. * Copies the given vector coordinates to the current Vector3 ones
  59441. * @param source defines the source Vector3
  59442. * @returns the current updated Vector3
  59443. */
  59444. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59445. /**
  59446. * Copies the given floats to the current Vector3 coordinates
  59447. * @param x defines the x coordinate of the operand
  59448. * @param y defines the y coordinate of the operand
  59449. * @param z defines the z coordinate of the operand
  59450. * @returns the current updated Vector3
  59451. */
  59452. copyFromFloats(x: number, y: number, z: number): Vector3;
  59453. /**
  59454. * Copies the given floats to the current Vector3 coordinates
  59455. * @param x defines the x coordinate of the operand
  59456. * @param y defines the y coordinate of the operand
  59457. * @param z defines the z coordinate of the operand
  59458. * @returns the current updated Vector3
  59459. */
  59460. set(x: number, y: number, z: number): Vector3;
  59461. /**
  59462. * Copies the given float to the current Vector3 coordinates
  59463. * @param v defines the x, y and z coordinates of the operand
  59464. * @returns the current updated Vector3
  59465. */
  59466. setAll(v: number): Vector3;
  59467. /**
  59468. * Get the clip factor between two vectors
  59469. * @param vector0 defines the first operand
  59470. * @param vector1 defines the second operand
  59471. * @param axis defines the axis to use
  59472. * @param size defines the size along the axis
  59473. * @returns the clip factor
  59474. */
  59475. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59476. /**
  59477. * Get angle between two vectors
  59478. * @param vector0 angle between vector0 and vector1
  59479. * @param vector1 angle between vector0 and vector1
  59480. * @param normal direction of the normal
  59481. * @return the angle between vector0 and vector1
  59482. */
  59483. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59484. /**
  59485. * Returns a new Vector3 set from the index "offset" of the given array
  59486. * @param array defines the source array
  59487. * @param offset defines the offset in the source array
  59488. * @returns the new Vector3
  59489. */
  59490. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59491. /**
  59492. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59493. * This function is deprecated. Use FromArray instead
  59494. * @param array defines the source array
  59495. * @param offset defines the offset in the source array
  59496. * @returns the new Vector3
  59497. */
  59498. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59499. /**
  59500. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59501. * @param array defines the source array
  59502. * @param offset defines the offset in the source array
  59503. * @param result defines the Vector3 where to store the result
  59504. */
  59505. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59506. /**
  59507. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59508. * This function is deprecated. Use FromArrayToRef instead.
  59509. * @param array defines the source array
  59510. * @param offset defines the offset in the source array
  59511. * @param result defines the Vector3 where to store the result
  59512. */
  59513. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59514. /**
  59515. * Sets the given vector "result" with the given floats.
  59516. * @param x defines the x coordinate of the source
  59517. * @param y defines the y coordinate of the source
  59518. * @param z defines the z coordinate of the source
  59519. * @param result defines the Vector3 where to store the result
  59520. */
  59521. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59522. /**
  59523. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59524. * @returns a new empty Vector3
  59525. */
  59526. static Zero(): Vector3;
  59527. /**
  59528. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59529. * @returns a new unit Vector3
  59530. */
  59531. static One(): Vector3;
  59532. /**
  59533. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59534. * @returns a new up Vector3
  59535. */
  59536. static Up(): Vector3;
  59537. /**
  59538. * Gets a up Vector3 that must not be updated
  59539. */
  59540. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59541. /**
  59542. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59543. * @returns a new down Vector3
  59544. */
  59545. static Down(): Vector3;
  59546. /**
  59547. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59548. * @returns a new forward Vector3
  59549. */
  59550. static Forward(): Vector3;
  59551. /**
  59552. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59553. * @returns a new forward Vector3
  59554. */
  59555. static Backward(): Vector3;
  59556. /**
  59557. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59558. * @returns a new right Vector3
  59559. */
  59560. static Right(): Vector3;
  59561. /**
  59562. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59563. * @returns a new left Vector3
  59564. */
  59565. static Left(): Vector3;
  59566. /**
  59567. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59568. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59569. * @param vector defines the Vector3 to transform
  59570. * @param transformation defines the transformation matrix
  59571. * @returns the transformed Vector3
  59572. */
  59573. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59574. /**
  59575. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59576. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59577. * @param vector defines the Vector3 to transform
  59578. * @param transformation defines the transformation matrix
  59579. * @param result defines the Vector3 where to store the result
  59580. */
  59581. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59582. /**
  59583. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59584. * This method computes tranformed coordinates only, not transformed direction vectors
  59585. * @param x define the x coordinate of the source vector
  59586. * @param y define the y coordinate of the source vector
  59587. * @param z define the z coordinate of the source vector
  59588. * @param transformation defines the transformation matrix
  59589. * @param result defines the Vector3 where to store the result
  59590. */
  59591. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59592. /**
  59593. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59594. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59595. * @param vector defines the Vector3 to transform
  59596. * @param transformation defines the transformation matrix
  59597. * @returns the new Vector3
  59598. */
  59599. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59600. /**
  59601. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59602. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59603. * @param vector defines the Vector3 to transform
  59604. * @param transformation defines the transformation matrix
  59605. * @param result defines the Vector3 where to store the result
  59606. */
  59607. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59608. /**
  59609. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59610. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59611. * @param x define the x coordinate of the source vector
  59612. * @param y define the y coordinate of the source vector
  59613. * @param z define the z coordinate of the source vector
  59614. * @param transformation defines the transformation matrix
  59615. * @param result defines the Vector3 where to store the result
  59616. */
  59617. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59618. /**
  59619. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59620. * @param value1 defines the first control point
  59621. * @param value2 defines the second control point
  59622. * @param value3 defines the third control point
  59623. * @param value4 defines the fourth control point
  59624. * @param amount defines the amount on the spline to use
  59625. * @returns the new Vector3
  59626. */
  59627. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59628. /**
  59629. * 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"
  59630. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59631. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59632. * @param value defines the current value
  59633. * @param min defines the lower range value
  59634. * @param max defines the upper range value
  59635. * @returns the new Vector3
  59636. */
  59637. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59638. /**
  59639. * 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"
  59640. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59641. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59642. * @param value defines the current value
  59643. * @param min defines the lower range value
  59644. * @param max defines the upper range value
  59645. * @param result defines the Vector3 where to store the result
  59646. */
  59647. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59648. /**
  59649. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59650. * @param value1 defines the first control point
  59651. * @param tangent1 defines the first tangent vector
  59652. * @param value2 defines the second control point
  59653. * @param tangent2 defines the second tangent vector
  59654. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59655. * @returns the new Vector3
  59656. */
  59657. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59658. /**
  59659. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59660. * @param start defines the start value
  59661. * @param end defines the end value
  59662. * @param amount max defines amount between both (between 0 and 1)
  59663. * @returns the new Vector3
  59664. */
  59665. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59666. /**
  59667. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59668. * @param start defines the start value
  59669. * @param end defines the end value
  59670. * @param amount max defines amount between both (between 0 and 1)
  59671. * @param result defines the Vector3 where to store the result
  59672. */
  59673. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59674. /**
  59675. * Returns the dot product (float) between the vectors "left" and "right"
  59676. * @param left defines the left operand
  59677. * @param right defines the right operand
  59678. * @returns the dot product
  59679. */
  59680. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59681. /**
  59682. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59683. * The cross product is then orthogonal to both "left" and "right"
  59684. * @param left defines the left operand
  59685. * @param right defines the right operand
  59686. * @returns the cross product
  59687. */
  59688. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59689. /**
  59690. * Sets the given vector "result" with the cross product of "left" and "right"
  59691. * The cross product is then orthogonal to both "left" and "right"
  59692. * @param left defines the left operand
  59693. * @param right defines the right operand
  59694. * @param result defines the Vector3 where to store the result
  59695. */
  59696. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59697. /**
  59698. * Returns a new Vector3 as the normalization of the given vector
  59699. * @param vector defines the Vector3 to normalize
  59700. * @returns the new Vector3
  59701. */
  59702. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59703. /**
  59704. * Sets the given vector "result" with the normalization of the given first vector
  59705. * @param vector defines the Vector3 to normalize
  59706. * @param result defines the Vector3 where to store the result
  59707. */
  59708. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59709. /**
  59710. * Project a Vector3 onto screen space
  59711. * @param vector defines the Vector3 to project
  59712. * @param world defines the world matrix to use
  59713. * @param transform defines the transform (view x projection) matrix to use
  59714. * @param viewport defines the screen viewport to use
  59715. * @returns the new Vector3
  59716. */
  59717. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59718. /** @hidden */
  59719. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59720. /**
  59721. * Unproject from screen space to object space
  59722. * @param source defines the screen space Vector3 to use
  59723. * @param viewportWidth defines the current width of the viewport
  59724. * @param viewportHeight defines the current height of the viewport
  59725. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59726. * @param transform defines the transform (view x projection) matrix to use
  59727. * @returns the new Vector3
  59728. */
  59729. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59730. /**
  59731. * Unproject from screen space to object space
  59732. * @param source defines the screen space Vector3 to use
  59733. * @param viewportWidth defines the current width of the viewport
  59734. * @param viewportHeight defines the current height of the viewport
  59735. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59736. * @param view defines the view matrix to use
  59737. * @param projection defines the projection matrix to use
  59738. * @returns the new Vector3
  59739. */
  59740. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59741. /**
  59742. * Unproject from screen space to object space
  59743. * @param source defines the screen space Vector3 to use
  59744. * @param viewportWidth defines the current width of the viewport
  59745. * @param viewportHeight defines the current height of the viewport
  59746. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59747. * @param view defines the view matrix to use
  59748. * @param projection defines the projection matrix to use
  59749. * @param result defines the Vector3 where to store the result
  59750. */
  59751. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59752. /**
  59753. * Unproject from screen space to object space
  59754. * @param sourceX defines the screen space x coordinate to use
  59755. * @param sourceY defines the screen space y coordinate to use
  59756. * @param sourceZ defines the screen space z coordinate to use
  59757. * @param viewportWidth defines the current width of the viewport
  59758. * @param viewportHeight defines the current height of the viewport
  59759. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59760. * @param view defines the view matrix to use
  59761. * @param projection defines the projection matrix to use
  59762. * @param result defines the Vector3 where to store the result
  59763. */
  59764. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59765. /**
  59766. * Gets the minimal coordinate values between two Vector3
  59767. * @param left defines the first operand
  59768. * @param right defines the second operand
  59769. * @returns the new Vector3
  59770. */
  59771. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59772. /**
  59773. * Gets the maximal coordinate values between two Vector3
  59774. * @param left defines the first operand
  59775. * @param right defines the second operand
  59776. * @returns the new Vector3
  59777. */
  59778. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59779. /**
  59780. * Returns the distance between the vectors "value1" and "value2"
  59781. * @param value1 defines the first operand
  59782. * @param value2 defines the second operand
  59783. * @returns the distance
  59784. */
  59785. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59786. /**
  59787. * Returns the squared distance between the vectors "value1" and "value2"
  59788. * @param value1 defines the first operand
  59789. * @param value2 defines the second operand
  59790. * @returns the squared distance
  59791. */
  59792. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59793. /**
  59794. * Returns a new Vector3 located at the center between "value1" and "value2"
  59795. * @param value1 defines the first operand
  59796. * @param value2 defines the second operand
  59797. * @returns the new Vector3
  59798. */
  59799. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59800. /**
  59801. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59802. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59803. * to something in order to rotate it from its local system to the given target system
  59804. * Note: axis1, axis2 and axis3 are normalized during this operation
  59805. * @param axis1 defines the first axis
  59806. * @param axis2 defines the second axis
  59807. * @param axis3 defines the third axis
  59808. * @returns a new Vector3
  59809. */
  59810. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59811. /**
  59812. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59813. * @param axis1 defines the first axis
  59814. * @param axis2 defines the second axis
  59815. * @param axis3 defines the third axis
  59816. * @param ref defines the Vector3 where to store the result
  59817. */
  59818. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59819. }
  59820. /**
  59821. * Vector4 class created for EulerAngle class conversion to Quaternion
  59822. */
  59823. export class Vector4 {
  59824. /** x value of the vector */
  59825. x: number;
  59826. /** y value of the vector */
  59827. y: number;
  59828. /** z value of the vector */
  59829. z: number;
  59830. /** w value of the vector */
  59831. w: number;
  59832. /**
  59833. * Creates a Vector4 object from the given floats.
  59834. * @param x x value of the vector
  59835. * @param y y value of the vector
  59836. * @param z z value of the vector
  59837. * @param w w value of the vector
  59838. */
  59839. constructor(
  59840. /** x value of the vector */
  59841. x: number,
  59842. /** y value of the vector */
  59843. y: number,
  59844. /** z value of the vector */
  59845. z: number,
  59846. /** w value of the vector */
  59847. w: number);
  59848. /**
  59849. * Returns the string with the Vector4 coordinates.
  59850. * @returns a string containing all the vector values
  59851. */
  59852. toString(): string;
  59853. /**
  59854. * Returns the string "Vector4".
  59855. * @returns "Vector4"
  59856. */
  59857. getClassName(): string;
  59858. /**
  59859. * Returns the Vector4 hash code.
  59860. * @returns a unique hash code
  59861. */
  59862. getHashCode(): number;
  59863. /**
  59864. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59865. * @returns the resulting array
  59866. */
  59867. asArray(): number[];
  59868. /**
  59869. * Populates the given array from the given index with the Vector4 coordinates.
  59870. * @param array array to populate
  59871. * @param index index of the array to start at (default: 0)
  59872. * @returns the Vector4.
  59873. */
  59874. toArray(array: FloatArray, index?: number): Vector4;
  59875. /**
  59876. * Adds the given vector to the current Vector4.
  59877. * @param otherVector the vector to add
  59878. * @returns the updated Vector4.
  59879. */
  59880. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59881. /**
  59882. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59883. * @param otherVector the vector to add
  59884. * @returns the resulting vector
  59885. */
  59886. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59887. /**
  59888. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59889. * @param otherVector the vector to add
  59890. * @param result the vector to store the result
  59891. * @returns the current Vector4.
  59892. */
  59893. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59894. /**
  59895. * Subtract in place the given vector from the current Vector4.
  59896. * @param otherVector the vector to subtract
  59897. * @returns the updated Vector4.
  59898. */
  59899. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59900. /**
  59901. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59902. * @param otherVector the vector to add
  59903. * @returns the new vector with the result
  59904. */
  59905. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59906. /**
  59907. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59908. * @param otherVector the vector to subtract
  59909. * @param result the vector to store the result
  59910. * @returns the current Vector4.
  59911. */
  59912. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59913. /**
  59914. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59915. */
  59916. /**
  59917. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59918. * @param x value to subtract
  59919. * @param y value to subtract
  59920. * @param z value to subtract
  59921. * @param w value to subtract
  59922. * @returns new vector containing the result
  59923. */
  59924. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59925. /**
  59926. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59927. * @param x value to subtract
  59928. * @param y value to subtract
  59929. * @param z value to subtract
  59930. * @param w value to subtract
  59931. * @param result the vector to store the result in
  59932. * @returns the current Vector4.
  59933. */
  59934. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59935. /**
  59936. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59937. * @returns a new vector with the negated values
  59938. */
  59939. negate(): Vector4;
  59940. /**
  59941. * Multiplies the current Vector4 coordinates by scale (float).
  59942. * @param scale the number to scale with
  59943. * @returns the updated Vector4.
  59944. */
  59945. scaleInPlace(scale: number): Vector4;
  59946. /**
  59947. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59948. * @param scale the number to scale with
  59949. * @returns a new vector with the result
  59950. */
  59951. scale(scale: number): Vector4;
  59952. /**
  59953. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59954. * @param scale the number to scale with
  59955. * @param result a vector to store the result in
  59956. * @returns the current Vector4.
  59957. */
  59958. scaleToRef(scale: number, result: Vector4): Vector4;
  59959. /**
  59960. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59961. * @param scale defines the scale factor
  59962. * @param result defines the Vector4 object where to store the result
  59963. * @returns the unmodified current Vector4
  59964. */
  59965. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59966. /**
  59967. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59968. * @param otherVector the vector to compare against
  59969. * @returns true if they are equal
  59970. */
  59971. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59972. /**
  59973. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59974. * @param otherVector vector to compare against
  59975. * @param epsilon (Default: very small number)
  59976. * @returns true if they are equal
  59977. */
  59978. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59979. /**
  59980. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59981. * @param x x value to compare against
  59982. * @param y y value to compare against
  59983. * @param z z value to compare against
  59984. * @param w w value to compare against
  59985. * @returns true if equal
  59986. */
  59987. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59988. /**
  59989. * Multiplies in place the current Vector4 by the given one.
  59990. * @param otherVector vector to multiple with
  59991. * @returns the updated Vector4.
  59992. */
  59993. multiplyInPlace(otherVector: Vector4): Vector4;
  59994. /**
  59995. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59996. * @param otherVector vector to multiple with
  59997. * @returns resulting new vector
  59998. */
  59999. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60000. /**
  60001. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60002. * @param otherVector vector to multiple with
  60003. * @param result vector to store the result
  60004. * @returns the current Vector4.
  60005. */
  60006. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60007. /**
  60008. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60009. * @param x x value multiply with
  60010. * @param y y value multiply with
  60011. * @param z z value multiply with
  60012. * @param w w value multiply with
  60013. * @returns resulting new vector
  60014. */
  60015. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60016. /**
  60017. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60018. * @param otherVector vector to devide with
  60019. * @returns resulting new vector
  60020. */
  60021. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60022. /**
  60023. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60024. * @param otherVector vector to devide with
  60025. * @param result vector to store the result
  60026. * @returns the current Vector4.
  60027. */
  60028. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60029. /**
  60030. * Divides the current Vector3 coordinates by the given ones.
  60031. * @param otherVector vector to devide with
  60032. * @returns the updated Vector3.
  60033. */
  60034. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60035. /**
  60036. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60037. * @param other defines the second operand
  60038. * @returns the current updated Vector4
  60039. */
  60040. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60041. /**
  60042. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60043. * @param other defines the second operand
  60044. * @returns the current updated Vector4
  60045. */
  60046. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60047. /**
  60048. * Gets a new Vector4 from current Vector4 floored values
  60049. * @returns a new Vector4
  60050. */
  60051. floor(): Vector4;
  60052. /**
  60053. * Gets a new Vector4 from current Vector3 floored values
  60054. * @returns a new Vector4
  60055. */
  60056. fract(): Vector4;
  60057. /**
  60058. * Returns the Vector4 length (float).
  60059. * @returns the length
  60060. */
  60061. length(): number;
  60062. /**
  60063. * Returns the Vector4 squared length (float).
  60064. * @returns the length squared
  60065. */
  60066. lengthSquared(): number;
  60067. /**
  60068. * Normalizes in place the Vector4.
  60069. * @returns the updated Vector4.
  60070. */
  60071. normalize(): Vector4;
  60072. /**
  60073. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60074. * @returns this converted to a new vector3
  60075. */
  60076. toVector3(): Vector3;
  60077. /**
  60078. * Returns a new Vector4 copied from the current one.
  60079. * @returns the new cloned vector
  60080. */
  60081. clone(): Vector4;
  60082. /**
  60083. * Updates the current Vector4 with the given one coordinates.
  60084. * @param source the source vector to copy from
  60085. * @returns the updated Vector4.
  60086. */
  60087. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60088. /**
  60089. * Updates the current Vector4 coordinates with the given floats.
  60090. * @param x float to copy from
  60091. * @param y float to copy from
  60092. * @param z float to copy from
  60093. * @param w float to copy from
  60094. * @returns the updated Vector4.
  60095. */
  60096. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60097. /**
  60098. * Updates the current Vector4 coordinates with the given floats.
  60099. * @param x float to set from
  60100. * @param y float to set from
  60101. * @param z float to set from
  60102. * @param w float to set from
  60103. * @returns the updated Vector4.
  60104. */
  60105. set(x: number, y: number, z: number, w: number): Vector4;
  60106. /**
  60107. * Copies the given float to the current Vector3 coordinates
  60108. * @param v defines the x, y, z and w coordinates of the operand
  60109. * @returns the current updated Vector3
  60110. */
  60111. setAll(v: number): Vector4;
  60112. /**
  60113. * Returns a new Vector4 set from the starting index of the given array.
  60114. * @param array the array to pull values from
  60115. * @param offset the offset into the array to start at
  60116. * @returns the new vector
  60117. */
  60118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60119. /**
  60120. * Updates the given vector "result" from the starting index of the given array.
  60121. * @param array the array to pull values from
  60122. * @param offset the offset into the array to start at
  60123. * @param result the vector to store the result in
  60124. */
  60125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60126. /**
  60127. * Updates the given vector "result" from the starting index of the given Float32Array.
  60128. * @param array the array to pull values from
  60129. * @param offset the offset into the array to start at
  60130. * @param result the vector to store the result in
  60131. */
  60132. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60133. /**
  60134. * Updates the given vector "result" coordinates from the given floats.
  60135. * @param x float to set from
  60136. * @param y float to set from
  60137. * @param z float to set from
  60138. * @param w float to set from
  60139. * @param result the vector to the floats in
  60140. */
  60141. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60142. /**
  60143. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60144. * @returns the new vector
  60145. */
  60146. static Zero(): Vector4;
  60147. /**
  60148. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60149. * @returns the new vector
  60150. */
  60151. static One(): Vector4;
  60152. /**
  60153. * Returns a new normalized Vector4 from the given one.
  60154. * @param vector the vector to normalize
  60155. * @returns the vector
  60156. */
  60157. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60158. /**
  60159. * Updates the given vector "result" from the normalization of the given one.
  60160. * @param vector the vector to normalize
  60161. * @param result the vector to store the result in
  60162. */
  60163. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60164. /**
  60165. * Returns a vector with the minimum values from the left and right vectors
  60166. * @param left left vector to minimize
  60167. * @param right right vector to minimize
  60168. * @returns a new vector with the minimum of the left and right vector values
  60169. */
  60170. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60171. /**
  60172. * Returns a vector with the maximum values from the left and right vectors
  60173. * @param left left vector to maximize
  60174. * @param right right vector to maximize
  60175. * @returns a new vector with the maximum of the left and right vector values
  60176. */
  60177. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60178. /**
  60179. * Returns the distance (float) between the vectors "value1" and "value2".
  60180. * @param value1 value to calulate the distance between
  60181. * @param value2 value to calulate the distance between
  60182. * @return the distance between the two vectors
  60183. */
  60184. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60185. /**
  60186. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60187. * @param value1 value to calulate the distance between
  60188. * @param value2 value to calulate the distance between
  60189. * @return the distance between the two vectors squared
  60190. */
  60191. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60192. /**
  60193. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60194. * @param value1 value to calulate the center between
  60195. * @param value2 value to calulate the center between
  60196. * @return the center between the two vectors
  60197. */
  60198. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60199. /**
  60200. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60201. * This methods computes transformed normalized direction vectors only.
  60202. * @param vector the vector to transform
  60203. * @param transformation the transformation matrix to apply
  60204. * @returns the new vector
  60205. */
  60206. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60207. /**
  60208. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60209. * This methods computes transformed normalized direction vectors only.
  60210. * @param vector the vector to transform
  60211. * @param transformation the transformation matrix to apply
  60212. * @param result the vector to store the result in
  60213. */
  60214. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60215. /**
  60216. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60217. * This methods computes transformed normalized direction vectors only.
  60218. * @param x value to transform
  60219. * @param y value to transform
  60220. * @param z value to transform
  60221. * @param w value to transform
  60222. * @param transformation the transformation matrix to apply
  60223. * @param result the vector to store the results in
  60224. */
  60225. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60226. /**
  60227. * Creates a new Vector4 from a Vector3
  60228. * @param source defines the source data
  60229. * @param w defines the 4th component (default is 0)
  60230. * @returns a new Vector4
  60231. */
  60232. static FromVector3(source: Vector3, w?: number): Vector4;
  60233. }
  60234. /**
  60235. * Interface for the size containing width and height
  60236. */
  60237. export interface ISize {
  60238. /**
  60239. * Width
  60240. */
  60241. width: number;
  60242. /**
  60243. * Heighht
  60244. */
  60245. height: number;
  60246. }
  60247. /**
  60248. * Size containing widht and height
  60249. */
  60250. export class Size implements ISize {
  60251. /**
  60252. * Width
  60253. */
  60254. width: number;
  60255. /**
  60256. * Height
  60257. */
  60258. height: number;
  60259. /**
  60260. * Creates a Size object from the given width and height (floats).
  60261. * @param width width of the new size
  60262. * @param height height of the new size
  60263. */
  60264. constructor(width: number, height: number);
  60265. /**
  60266. * Returns a string with the Size width and height
  60267. * @returns a string with the Size width and height
  60268. */
  60269. toString(): string;
  60270. /**
  60271. * "Size"
  60272. * @returns the string "Size"
  60273. */
  60274. getClassName(): string;
  60275. /**
  60276. * Returns the Size hash code.
  60277. * @returns a hash code for a unique width and height
  60278. */
  60279. getHashCode(): number;
  60280. /**
  60281. * Updates the current size from the given one.
  60282. * @param src the given size
  60283. */
  60284. copyFrom(src: Size): void;
  60285. /**
  60286. * Updates in place the current Size from the given floats.
  60287. * @param width width of the new size
  60288. * @param height height of the new size
  60289. * @returns the updated Size.
  60290. */
  60291. copyFromFloats(width: number, height: number): Size;
  60292. /**
  60293. * Updates in place the current Size from the given floats.
  60294. * @param width width to set
  60295. * @param height height to set
  60296. * @returns the updated Size.
  60297. */
  60298. set(width: number, height: number): Size;
  60299. /**
  60300. * Multiplies the width and height by numbers
  60301. * @param w factor to multiple the width by
  60302. * @param h factor to multiple the height by
  60303. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60304. */
  60305. multiplyByFloats(w: number, h: number): Size;
  60306. /**
  60307. * Clones the size
  60308. * @returns a new Size copied from the given one.
  60309. */
  60310. clone(): Size;
  60311. /**
  60312. * True if the current Size and the given one width and height are strictly equal.
  60313. * @param other the other size to compare against
  60314. * @returns True if the current Size and the given one width and height are strictly equal.
  60315. */
  60316. equals(other: Size): boolean;
  60317. /**
  60318. * The surface of the Size : width * height (float).
  60319. */
  60320. readonly surface: number;
  60321. /**
  60322. * Create a new size of zero
  60323. * @returns a new Size set to (0.0, 0.0)
  60324. */
  60325. static Zero(): Size;
  60326. /**
  60327. * Sums the width and height of two sizes
  60328. * @param otherSize size to add to this size
  60329. * @returns a new Size set as the addition result of the current Size and the given one.
  60330. */
  60331. add(otherSize: Size): Size;
  60332. /**
  60333. * Subtracts the width and height of two
  60334. * @param otherSize size to subtract to this size
  60335. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60336. */
  60337. subtract(otherSize: Size): Size;
  60338. /**
  60339. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60340. * @param start starting size to lerp between
  60341. * @param end end size to lerp between
  60342. * @param amount amount to lerp between the start and end values
  60343. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60344. */
  60345. static Lerp(start: Size, end: Size, amount: number): Size;
  60346. }
  60347. /**
  60348. * Class used to store quaternion data
  60349. * @see https://en.wikipedia.org/wiki/Quaternion
  60350. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60351. */
  60352. export class Quaternion {
  60353. /** defines the first component (0 by default) */
  60354. x: number;
  60355. /** defines the second component (0 by default) */
  60356. y: number;
  60357. /** defines the third component (0 by default) */
  60358. z: number;
  60359. /** defines the fourth component (1.0 by default) */
  60360. w: number;
  60361. /**
  60362. * Creates a new Quaternion from the given floats
  60363. * @param x defines the first component (0 by default)
  60364. * @param y defines the second component (0 by default)
  60365. * @param z defines the third component (0 by default)
  60366. * @param w defines the fourth component (1.0 by default)
  60367. */
  60368. constructor(
  60369. /** defines the first component (0 by default) */
  60370. x?: number,
  60371. /** defines the second component (0 by default) */
  60372. y?: number,
  60373. /** defines the third component (0 by default) */
  60374. z?: number,
  60375. /** defines the fourth component (1.0 by default) */
  60376. w?: number);
  60377. /**
  60378. * Gets a string representation for the current quaternion
  60379. * @returns a string with the Quaternion coordinates
  60380. */
  60381. toString(): string;
  60382. /**
  60383. * Gets the class name of the quaternion
  60384. * @returns the string "Quaternion"
  60385. */
  60386. getClassName(): string;
  60387. /**
  60388. * Gets a hash code for this quaternion
  60389. * @returns the quaternion hash code
  60390. */
  60391. getHashCode(): number;
  60392. /**
  60393. * Copy the quaternion to an array
  60394. * @returns a new array populated with 4 elements from the quaternion coordinates
  60395. */
  60396. asArray(): number[];
  60397. /**
  60398. * Check if two quaternions are equals
  60399. * @param otherQuaternion defines the second operand
  60400. * @return true if the current quaternion and the given one coordinates are strictly equals
  60401. */
  60402. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60403. /**
  60404. * Clone the current quaternion
  60405. * @returns a new quaternion copied from the current one
  60406. */
  60407. clone(): Quaternion;
  60408. /**
  60409. * Copy a quaternion to the current one
  60410. * @param other defines the other quaternion
  60411. * @returns the updated current quaternion
  60412. */
  60413. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60414. /**
  60415. * Updates the current quaternion with the given float coordinates
  60416. * @param x defines the x coordinate
  60417. * @param y defines the y coordinate
  60418. * @param z defines the z coordinate
  60419. * @param w defines the w coordinate
  60420. * @returns the updated current quaternion
  60421. */
  60422. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60423. /**
  60424. * Updates the current quaternion from the given float coordinates
  60425. * @param x defines the x coordinate
  60426. * @param y defines the y coordinate
  60427. * @param z defines the z coordinate
  60428. * @param w defines the w coordinate
  60429. * @returns the updated current quaternion
  60430. */
  60431. set(x: number, y: number, z: number, w: number): Quaternion;
  60432. /**
  60433. * Adds two quaternions
  60434. * @param other defines the second operand
  60435. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60436. */
  60437. add(other: DeepImmutable<Quaternion>): Quaternion;
  60438. /**
  60439. * Add a quaternion to the current one
  60440. * @param other defines the quaternion to add
  60441. * @returns the current quaternion
  60442. */
  60443. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60444. /**
  60445. * Subtract two quaternions
  60446. * @param other defines the second operand
  60447. * @returns a new quaternion as the subtraction result of the given one from the current one
  60448. */
  60449. subtract(other: Quaternion): Quaternion;
  60450. /**
  60451. * Multiplies the current quaternion by a scale factor
  60452. * @param value defines the scale factor
  60453. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60454. */
  60455. scale(value: number): Quaternion;
  60456. /**
  60457. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60458. * @param scale defines the scale factor
  60459. * @param result defines the Quaternion object where to store the result
  60460. * @returns the unmodified current quaternion
  60461. */
  60462. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60463. /**
  60464. * Multiplies in place the current quaternion by a scale factor
  60465. * @param value defines the scale factor
  60466. * @returns the current modified quaternion
  60467. */
  60468. scaleInPlace(value: number): Quaternion;
  60469. /**
  60470. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60471. * @param scale defines the scale factor
  60472. * @param result defines the Quaternion object where to store the result
  60473. * @returns the unmodified current quaternion
  60474. */
  60475. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60476. /**
  60477. * Multiplies two quaternions
  60478. * @param q1 defines the second operand
  60479. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60480. */
  60481. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60482. /**
  60483. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60484. * @param q1 defines the second operand
  60485. * @param result defines the target quaternion
  60486. * @returns the current quaternion
  60487. */
  60488. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60489. /**
  60490. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60491. * @param q1 defines the second operand
  60492. * @returns the currentupdated quaternion
  60493. */
  60494. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60495. /**
  60496. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60497. * @param ref defines the target quaternion
  60498. * @returns the current quaternion
  60499. */
  60500. conjugateToRef(ref: Quaternion): Quaternion;
  60501. /**
  60502. * Conjugates in place (1-q) the current quaternion
  60503. * @returns the current updated quaternion
  60504. */
  60505. conjugateInPlace(): Quaternion;
  60506. /**
  60507. * Conjugates in place (1-q) the current quaternion
  60508. * @returns a new quaternion
  60509. */
  60510. conjugate(): Quaternion;
  60511. /**
  60512. * Gets length of current quaternion
  60513. * @returns the quaternion length (float)
  60514. */
  60515. length(): number;
  60516. /**
  60517. * Normalize in place the current quaternion
  60518. * @returns the current updated quaternion
  60519. */
  60520. normalize(): Quaternion;
  60521. /**
  60522. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60523. * @param order is a reserved parameter and is ignore for now
  60524. * @returns a new Vector3 containing the Euler angles
  60525. */
  60526. toEulerAngles(order?: string): Vector3;
  60527. /**
  60528. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60529. * @param result defines the vector which will be filled with the Euler angles
  60530. * @param order is a reserved parameter and is ignore for now
  60531. * @returns the current unchanged quaternion
  60532. */
  60533. toEulerAnglesToRef(result: Vector3): Quaternion;
  60534. /**
  60535. * Updates the given rotation matrix with the current quaternion values
  60536. * @param result defines the target matrix
  60537. * @returns the current unchanged quaternion
  60538. */
  60539. toRotationMatrix(result: Matrix): Quaternion;
  60540. /**
  60541. * Updates the current quaternion from the given rotation matrix values
  60542. * @param matrix defines the source matrix
  60543. * @returns the current updated quaternion
  60544. */
  60545. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60546. /**
  60547. * Creates a new quaternion from a rotation matrix
  60548. * @param matrix defines the source matrix
  60549. * @returns a new quaternion created from the given rotation matrix values
  60550. */
  60551. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60552. /**
  60553. * Updates the given quaternion with the given rotation matrix values
  60554. * @param matrix defines the source matrix
  60555. * @param result defines the target quaternion
  60556. */
  60557. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60558. /**
  60559. * Returns the dot product (float) between the quaternions "left" and "right"
  60560. * @param left defines the left operand
  60561. * @param right defines the right operand
  60562. * @returns the dot product
  60563. */
  60564. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60565. /**
  60566. * Checks if the two quaternions are close to each other
  60567. * @param quat0 defines the first quaternion to check
  60568. * @param quat1 defines the second quaternion to check
  60569. * @returns true if the two quaternions are close to each other
  60570. */
  60571. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60572. /**
  60573. * Creates an empty quaternion
  60574. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60575. */
  60576. static Zero(): Quaternion;
  60577. /**
  60578. * Inverse a given quaternion
  60579. * @param q defines the source quaternion
  60580. * @returns a new quaternion as the inverted current quaternion
  60581. */
  60582. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60583. /**
  60584. * Inverse a given quaternion
  60585. * @param q defines the source quaternion
  60586. * @param result the quaternion the result will be stored in
  60587. * @returns the result quaternion
  60588. */
  60589. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60590. /**
  60591. * Creates an identity quaternion
  60592. * @returns the identity quaternion
  60593. */
  60594. static Identity(): Quaternion;
  60595. /**
  60596. * Gets a boolean indicating if the given quaternion is identity
  60597. * @param quaternion defines the quaternion to check
  60598. * @returns true if the quaternion is identity
  60599. */
  60600. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60601. /**
  60602. * Creates a quaternion from a rotation around an axis
  60603. * @param axis defines the axis to use
  60604. * @param angle defines the angle to use
  60605. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60606. */
  60607. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60608. /**
  60609. * Creates a rotation around an axis and stores it into the given quaternion
  60610. * @param axis defines the axis to use
  60611. * @param angle defines the angle to use
  60612. * @param result defines the target quaternion
  60613. * @returns the target quaternion
  60614. */
  60615. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60616. /**
  60617. * Creates a new quaternion from data stored into an array
  60618. * @param array defines the data source
  60619. * @param offset defines the offset in the source array where the data starts
  60620. * @returns a new quaternion
  60621. */
  60622. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60623. /**
  60624. * Create a quaternion from Euler rotation angles
  60625. * @param x Pitch
  60626. * @param y Yaw
  60627. * @param z Roll
  60628. * @returns the new Quaternion
  60629. */
  60630. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60631. /**
  60632. * Updates a quaternion from Euler rotation angles
  60633. * @param x Pitch
  60634. * @param y Yaw
  60635. * @param z Roll
  60636. * @param result the quaternion to store the result
  60637. * @returns the updated quaternion
  60638. */
  60639. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60640. /**
  60641. * Create a quaternion from Euler rotation vector
  60642. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60643. * @returns the new Quaternion
  60644. */
  60645. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60646. /**
  60647. * Updates a quaternion from Euler rotation vector
  60648. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60649. * @param result the quaternion to store the result
  60650. * @returns the updated quaternion
  60651. */
  60652. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60653. /**
  60654. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60655. * @param yaw defines the rotation around Y axis
  60656. * @param pitch defines the rotation around X axis
  60657. * @param roll defines the rotation around Z axis
  60658. * @returns the new quaternion
  60659. */
  60660. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60661. /**
  60662. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60663. * @param yaw defines the rotation around Y axis
  60664. * @param pitch defines the rotation around X axis
  60665. * @param roll defines the rotation around Z axis
  60666. * @param result defines the target quaternion
  60667. */
  60668. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60669. /**
  60670. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60671. * @param alpha defines the rotation around first axis
  60672. * @param beta defines the rotation around second axis
  60673. * @param gamma defines the rotation around third axis
  60674. * @returns the new quaternion
  60675. */
  60676. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60677. /**
  60678. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60679. * @param alpha defines the rotation around first axis
  60680. * @param beta defines the rotation around second axis
  60681. * @param gamma defines the rotation around third axis
  60682. * @param result defines the target quaternion
  60683. */
  60684. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60685. /**
  60686. * 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)
  60687. * @param axis1 defines the first axis
  60688. * @param axis2 defines the second axis
  60689. * @param axis3 defines the third axis
  60690. * @returns the new quaternion
  60691. */
  60692. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60693. /**
  60694. * 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
  60695. * @param axis1 defines the first axis
  60696. * @param axis2 defines the second axis
  60697. * @param axis3 defines the third axis
  60698. * @param ref defines the target quaternion
  60699. */
  60700. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60701. /**
  60702. * Interpolates between two quaternions
  60703. * @param left defines first quaternion
  60704. * @param right defines second quaternion
  60705. * @param amount defines the gradient to use
  60706. * @returns the new interpolated quaternion
  60707. */
  60708. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60709. /**
  60710. * Interpolates between two quaternions and stores it into a target quaternion
  60711. * @param left defines first quaternion
  60712. * @param right defines second quaternion
  60713. * @param amount defines the gradient to use
  60714. * @param result defines the target quaternion
  60715. */
  60716. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60717. /**
  60718. * Interpolate between two quaternions using Hermite interpolation
  60719. * @param value1 defines first quaternion
  60720. * @param tangent1 defines the incoming tangent
  60721. * @param value2 defines second quaternion
  60722. * @param tangent2 defines the outgoing tangent
  60723. * @param amount defines the target quaternion
  60724. * @returns the new interpolated quaternion
  60725. */
  60726. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60727. }
  60728. /**
  60729. * Class used to store matrix data (4x4)
  60730. */
  60731. export class Matrix {
  60732. private static _updateFlagSeed;
  60733. private static _identityReadOnly;
  60734. private _isIdentity;
  60735. private _isIdentityDirty;
  60736. private _isIdentity3x2;
  60737. private _isIdentity3x2Dirty;
  60738. /**
  60739. * Gets the update flag of the matrix which is an unique number for the matrix.
  60740. * It will be incremented every time the matrix data change.
  60741. * You can use it to speed the comparison between two versions of the same matrix.
  60742. */
  60743. updateFlag: number;
  60744. private readonly _m;
  60745. /**
  60746. * Gets the internal data of the matrix
  60747. */
  60748. readonly m: DeepImmutable<Float32Array>;
  60749. /** @hidden */
  60750. _markAsUpdated(): void;
  60751. /** @hidden */
  60752. private _updateIdentityStatus;
  60753. /**
  60754. * Creates an empty matrix (filled with zeros)
  60755. */
  60756. constructor();
  60757. /**
  60758. * Check if the current matrix is identity
  60759. * @returns true is the matrix is the identity matrix
  60760. */
  60761. isIdentity(): boolean;
  60762. /**
  60763. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60764. * @returns true is the matrix is the identity matrix
  60765. */
  60766. isIdentityAs3x2(): boolean;
  60767. /**
  60768. * Gets the determinant of the matrix
  60769. * @returns the matrix determinant
  60770. */
  60771. determinant(): number;
  60772. /**
  60773. * Returns the matrix as a Float32Array
  60774. * @returns the matrix underlying array
  60775. */
  60776. toArray(): DeepImmutable<Float32Array>;
  60777. /**
  60778. * Returns the matrix as a Float32Array
  60779. * @returns the matrix underlying array.
  60780. */
  60781. asArray(): DeepImmutable<Float32Array>;
  60782. /**
  60783. * Inverts the current matrix in place
  60784. * @returns the current inverted matrix
  60785. */
  60786. invert(): Matrix;
  60787. /**
  60788. * Sets all the matrix elements to zero
  60789. * @returns the current matrix
  60790. */
  60791. reset(): Matrix;
  60792. /**
  60793. * Adds the current matrix with a second one
  60794. * @param other defines the matrix to add
  60795. * @returns a new matrix as the addition of the current matrix and the given one
  60796. */
  60797. add(other: DeepImmutable<Matrix>): Matrix;
  60798. /**
  60799. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60800. * @param other defines the matrix to add
  60801. * @param result defines the target matrix
  60802. * @returns the current matrix
  60803. */
  60804. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60805. /**
  60806. * Adds in place the given matrix to the current matrix
  60807. * @param other defines the second operand
  60808. * @returns the current updated matrix
  60809. */
  60810. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60811. /**
  60812. * Sets the given matrix to the current inverted Matrix
  60813. * @param other defines the target matrix
  60814. * @returns the unmodified current matrix
  60815. */
  60816. invertToRef(other: Matrix): Matrix;
  60817. /**
  60818. * add a value at the specified position in the current Matrix
  60819. * @param index the index of the value within the matrix. between 0 and 15.
  60820. * @param value the value to be added
  60821. * @returns the current updated matrix
  60822. */
  60823. addAtIndex(index: number, value: number): Matrix;
  60824. /**
  60825. * mutiply the specified position in the current Matrix by a value
  60826. * @param index the index of the value within the matrix. between 0 and 15.
  60827. * @param value the value to be added
  60828. * @returns the current updated matrix
  60829. */
  60830. multiplyAtIndex(index: number, value: number): Matrix;
  60831. /**
  60832. * Inserts the translation vector (using 3 floats) in the current matrix
  60833. * @param x defines the 1st component of the translation
  60834. * @param y defines the 2nd component of the translation
  60835. * @param z defines the 3rd component of the translation
  60836. * @returns the current updated matrix
  60837. */
  60838. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60839. /**
  60840. * Inserts the translation vector in the current matrix
  60841. * @param vector3 defines the translation to insert
  60842. * @returns the current updated matrix
  60843. */
  60844. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60845. /**
  60846. * Gets the translation value of the current matrix
  60847. * @returns a new Vector3 as the extracted translation from the matrix
  60848. */
  60849. getTranslation(): Vector3;
  60850. /**
  60851. * Fill a Vector3 with the extracted translation from the matrix
  60852. * @param result defines the Vector3 where to store the translation
  60853. * @returns the current matrix
  60854. */
  60855. getTranslationToRef(result: Vector3): Matrix;
  60856. /**
  60857. * Remove rotation and scaling part from the matrix
  60858. * @returns the updated matrix
  60859. */
  60860. removeRotationAndScaling(): Matrix;
  60861. /**
  60862. * Multiply two matrices
  60863. * @param other defines the second operand
  60864. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60865. */
  60866. multiply(other: DeepImmutable<Matrix>): Matrix;
  60867. /**
  60868. * Copy the current matrix from the given one
  60869. * @param other defines the source matrix
  60870. * @returns the current updated matrix
  60871. */
  60872. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60873. /**
  60874. * Populates the given array from the starting index with the current matrix values
  60875. * @param array defines the target array
  60876. * @param offset defines the offset in the target array where to start storing values
  60877. * @returns the current matrix
  60878. */
  60879. copyToArray(array: Float32Array, offset?: number): Matrix;
  60880. /**
  60881. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60882. * @param other defines the second operand
  60883. * @param result defines the matrix where to store the multiplication
  60884. * @returns the current matrix
  60885. */
  60886. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60887. /**
  60888. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60889. * @param other defines the second operand
  60890. * @param result defines the array where to store the multiplication
  60891. * @param offset defines the offset in the target array where to start storing values
  60892. * @returns the current matrix
  60893. */
  60894. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60895. /**
  60896. * Check equality between this matrix and a second one
  60897. * @param value defines the second matrix to compare
  60898. * @returns true is the current matrix and the given one values are strictly equal
  60899. */
  60900. equals(value: DeepImmutable<Matrix>): boolean;
  60901. /**
  60902. * Clone the current matrix
  60903. * @returns a new matrix from the current matrix
  60904. */
  60905. clone(): Matrix;
  60906. /**
  60907. * Returns the name of the current matrix class
  60908. * @returns the string "Matrix"
  60909. */
  60910. getClassName(): string;
  60911. /**
  60912. * Gets the hash code of the current matrix
  60913. * @returns the hash code
  60914. */
  60915. getHashCode(): number;
  60916. /**
  60917. * Decomposes the current Matrix into a translation, rotation and scaling components
  60918. * @param scale defines the scale vector3 given as a reference to update
  60919. * @param rotation defines the rotation quaternion given as a reference to update
  60920. * @param translation defines the translation vector3 given as a reference to update
  60921. * @returns true if operation was successful
  60922. */
  60923. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60924. /**
  60925. * Gets specific row of the matrix
  60926. * @param index defines the number of the row to get
  60927. * @returns the index-th row of the current matrix as a new Vector4
  60928. */
  60929. getRow(index: number): Nullable<Vector4>;
  60930. /**
  60931. * Sets the index-th row of the current matrix to the vector4 values
  60932. * @param index defines the number of the row to set
  60933. * @param row defines the target vector4
  60934. * @returns the updated current matrix
  60935. */
  60936. setRow(index: number, row: Vector4): Matrix;
  60937. /**
  60938. * Compute the transpose of the matrix
  60939. * @returns the new transposed matrix
  60940. */
  60941. transpose(): Matrix;
  60942. /**
  60943. * Compute the transpose of the matrix and store it in a given matrix
  60944. * @param result defines the target matrix
  60945. * @returns the current matrix
  60946. */
  60947. transposeToRef(result: Matrix): Matrix;
  60948. /**
  60949. * Sets the index-th row of the current matrix with the given 4 x float values
  60950. * @param index defines the row index
  60951. * @param x defines the x component to set
  60952. * @param y defines the y component to set
  60953. * @param z defines the z component to set
  60954. * @param w defines the w component to set
  60955. * @returns the updated current matrix
  60956. */
  60957. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60958. /**
  60959. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60960. * @param scale defines the scale factor
  60961. * @returns a new matrix
  60962. */
  60963. scale(scale: number): Matrix;
  60964. /**
  60965. * Scale the current matrix values by a factor to a given result matrix
  60966. * @param scale defines the scale factor
  60967. * @param result defines the matrix to store the result
  60968. * @returns the current matrix
  60969. */
  60970. scaleToRef(scale: number, result: Matrix): Matrix;
  60971. /**
  60972. * Scale the current matrix values by a factor and add the result to a given matrix
  60973. * @param scale defines the scale factor
  60974. * @param result defines the Matrix to store the result
  60975. * @returns the current matrix
  60976. */
  60977. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60978. /**
  60979. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60980. * @param ref matrix to store the result
  60981. */
  60982. toNormalMatrix(ref: Matrix): void;
  60983. /**
  60984. * Gets only rotation part of the current matrix
  60985. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60986. */
  60987. getRotationMatrix(): Matrix;
  60988. /**
  60989. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60990. * @param result defines the target matrix to store data to
  60991. * @returns the current matrix
  60992. */
  60993. getRotationMatrixToRef(result: Matrix): Matrix;
  60994. /**
  60995. * Toggles model matrix from being right handed to left handed in place and vice versa
  60996. */
  60997. toggleModelMatrixHandInPlace(): void;
  60998. /**
  60999. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61000. */
  61001. toggleProjectionMatrixHandInPlace(): void;
  61002. /**
  61003. * Creates a matrix from an array
  61004. * @param array defines the source array
  61005. * @param offset defines an offset in the source array
  61006. * @returns a new Matrix set from the starting index of the given array
  61007. */
  61008. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61009. /**
  61010. * Copy the content of an array into a given matrix
  61011. * @param array defines the source array
  61012. * @param offset defines an offset in the source array
  61013. * @param result defines the target matrix
  61014. */
  61015. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61016. /**
  61017. * Stores an array into a matrix after having multiplied each component by a given factor
  61018. * @param array defines the source array
  61019. * @param offset defines the offset in the source array
  61020. * @param scale defines the scaling factor
  61021. * @param result defines the target matrix
  61022. */
  61023. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61024. /**
  61025. * Gets an identity matrix that must not be updated
  61026. */
  61027. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61028. /**
  61029. * Stores a list of values (16) inside a given matrix
  61030. * @param initialM11 defines 1st value of 1st row
  61031. * @param initialM12 defines 2nd value of 1st row
  61032. * @param initialM13 defines 3rd value of 1st row
  61033. * @param initialM14 defines 4th value of 1st row
  61034. * @param initialM21 defines 1st value of 2nd row
  61035. * @param initialM22 defines 2nd value of 2nd row
  61036. * @param initialM23 defines 3rd value of 2nd row
  61037. * @param initialM24 defines 4th value of 2nd row
  61038. * @param initialM31 defines 1st value of 3rd row
  61039. * @param initialM32 defines 2nd value of 3rd row
  61040. * @param initialM33 defines 3rd value of 3rd row
  61041. * @param initialM34 defines 4th value of 3rd row
  61042. * @param initialM41 defines 1st value of 4th row
  61043. * @param initialM42 defines 2nd value of 4th row
  61044. * @param initialM43 defines 3rd value of 4th row
  61045. * @param initialM44 defines 4th value of 4th row
  61046. * @param result defines the target matrix
  61047. */
  61048. 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;
  61049. /**
  61050. * Creates new matrix from a list of values (16)
  61051. * @param initialM11 defines 1st value of 1st row
  61052. * @param initialM12 defines 2nd value of 1st row
  61053. * @param initialM13 defines 3rd value of 1st row
  61054. * @param initialM14 defines 4th value of 1st row
  61055. * @param initialM21 defines 1st value of 2nd row
  61056. * @param initialM22 defines 2nd value of 2nd row
  61057. * @param initialM23 defines 3rd value of 2nd row
  61058. * @param initialM24 defines 4th value of 2nd row
  61059. * @param initialM31 defines 1st value of 3rd row
  61060. * @param initialM32 defines 2nd value of 3rd row
  61061. * @param initialM33 defines 3rd value of 3rd row
  61062. * @param initialM34 defines 4th value of 3rd row
  61063. * @param initialM41 defines 1st value of 4th row
  61064. * @param initialM42 defines 2nd value of 4th row
  61065. * @param initialM43 defines 3rd value of 4th row
  61066. * @param initialM44 defines 4th value of 4th row
  61067. * @returns the new matrix
  61068. */
  61069. 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;
  61070. /**
  61071. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61072. * @param scale defines the scale vector3
  61073. * @param rotation defines the rotation quaternion
  61074. * @param translation defines the translation vector3
  61075. * @returns a new matrix
  61076. */
  61077. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61078. /**
  61079. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61080. * @param scale defines the scale vector3
  61081. * @param rotation defines the rotation quaternion
  61082. * @param translation defines the translation vector3
  61083. * @param result defines the target matrix
  61084. */
  61085. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61086. /**
  61087. * Creates a new identity matrix
  61088. * @returns a new identity matrix
  61089. */
  61090. static Identity(): Matrix;
  61091. /**
  61092. * Creates a new identity matrix and stores the result in a given matrix
  61093. * @param result defines the target matrix
  61094. */
  61095. static IdentityToRef(result: Matrix): void;
  61096. /**
  61097. * Creates a new zero matrix
  61098. * @returns a new zero matrix
  61099. */
  61100. static Zero(): Matrix;
  61101. /**
  61102. * Creates a new rotation matrix for "angle" radians around the X axis
  61103. * @param angle defines the angle (in radians) to use
  61104. * @return the new matrix
  61105. */
  61106. static RotationX(angle: number): Matrix;
  61107. /**
  61108. * Creates a new matrix as the invert of a given matrix
  61109. * @param source defines the source matrix
  61110. * @returns the new matrix
  61111. */
  61112. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61113. /**
  61114. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61115. * @param angle defines the angle (in radians) to use
  61116. * @param result defines the target matrix
  61117. */
  61118. static RotationXToRef(angle: number, result: Matrix): void;
  61119. /**
  61120. * Creates a new rotation matrix for "angle" radians around the Y axis
  61121. * @param angle defines the angle (in radians) to use
  61122. * @return the new matrix
  61123. */
  61124. static RotationY(angle: number): Matrix;
  61125. /**
  61126. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61127. * @param angle defines the angle (in radians) to use
  61128. * @param result defines the target matrix
  61129. */
  61130. static RotationYToRef(angle: number, result: Matrix): void;
  61131. /**
  61132. * Creates a new rotation matrix for "angle" radians around the Z axis
  61133. * @param angle defines the angle (in radians) to use
  61134. * @return the new matrix
  61135. */
  61136. static RotationZ(angle: number): Matrix;
  61137. /**
  61138. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61139. * @param angle defines the angle (in radians) to use
  61140. * @param result defines the target matrix
  61141. */
  61142. static RotationZToRef(angle: number, result: Matrix): void;
  61143. /**
  61144. * Creates a new rotation matrix for "angle" radians around the given axis
  61145. * @param axis defines the axis to use
  61146. * @param angle defines the angle (in radians) to use
  61147. * @return the new matrix
  61148. */
  61149. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61150. /**
  61151. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61152. * @param axis defines the axis to use
  61153. * @param angle defines the angle (in radians) to use
  61154. * @param result defines the target matrix
  61155. */
  61156. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61157. /**
  61158. * Creates a rotation matrix
  61159. * @param yaw defines the yaw angle in radians (Y axis)
  61160. * @param pitch defines the pitch angle in radians (X axis)
  61161. * @param roll defines the roll angle in radians (X axis)
  61162. * @returns the new rotation matrix
  61163. */
  61164. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61165. /**
  61166. * Creates a rotation matrix and stores it in a given matrix
  61167. * @param yaw defines the yaw angle in radians (Y axis)
  61168. * @param pitch defines the pitch angle in radians (X axis)
  61169. * @param roll defines the roll angle in radians (X axis)
  61170. * @param result defines the target matrix
  61171. */
  61172. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61173. /**
  61174. * Creates a scaling matrix
  61175. * @param x defines the scale factor on X axis
  61176. * @param y defines the scale factor on Y axis
  61177. * @param z defines the scale factor on Z axis
  61178. * @returns the new matrix
  61179. */
  61180. static Scaling(x: number, y: number, z: number): Matrix;
  61181. /**
  61182. * Creates a scaling matrix and stores it in a given matrix
  61183. * @param x defines the scale factor on X axis
  61184. * @param y defines the scale factor on Y axis
  61185. * @param z defines the scale factor on Z axis
  61186. * @param result defines the target matrix
  61187. */
  61188. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61189. /**
  61190. * Creates a translation matrix
  61191. * @param x defines the translation on X axis
  61192. * @param y defines the translation on Y axis
  61193. * @param z defines the translationon Z axis
  61194. * @returns the new matrix
  61195. */
  61196. static Translation(x: number, y: number, z: number): Matrix;
  61197. /**
  61198. * Creates a translation matrix and stores it in a given matrix
  61199. * @param x defines the translation on X axis
  61200. * @param y defines the translation on Y axis
  61201. * @param z defines the translationon Z axis
  61202. * @param result defines the target matrix
  61203. */
  61204. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61205. /**
  61206. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61207. * @param startValue defines the start value
  61208. * @param endValue defines the end value
  61209. * @param gradient defines the gradient factor
  61210. * @returns the new matrix
  61211. */
  61212. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61213. /**
  61214. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61215. * @param startValue defines the start value
  61216. * @param endValue defines the end value
  61217. * @param gradient defines the gradient factor
  61218. * @param result defines the Matrix object where to store data
  61219. */
  61220. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61221. /**
  61222. * Builds a new matrix whose values are computed by:
  61223. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61224. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61225. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61226. * @param startValue defines the first matrix
  61227. * @param endValue defines the second matrix
  61228. * @param gradient defines the gradient between the two matrices
  61229. * @returns the new matrix
  61230. */
  61231. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61232. /**
  61233. * Update a matrix to values which are computed by:
  61234. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61235. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61236. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61237. * @param startValue defines the first matrix
  61238. * @param endValue defines the second matrix
  61239. * @param gradient defines the gradient between the two matrices
  61240. * @param result defines the target matrix
  61241. */
  61242. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61243. /**
  61244. * 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"
  61245. * This function works in left handed mode
  61246. * @param eye defines the final position of the entity
  61247. * @param target defines where the entity should look at
  61248. * @param up defines the up vector for the entity
  61249. * @returns the new matrix
  61250. */
  61251. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61252. /**
  61253. * 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".
  61254. * This function works in left handed mode
  61255. * @param eye defines the final position of the entity
  61256. * @param target defines where the entity should look at
  61257. * @param up defines the up vector for the entity
  61258. * @param result defines the target matrix
  61259. */
  61260. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61261. /**
  61262. * 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"
  61263. * This function works in right handed mode
  61264. * @param eye defines the final position of the entity
  61265. * @param target defines where the entity should look at
  61266. * @param up defines the up vector for the entity
  61267. * @returns the new matrix
  61268. */
  61269. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61270. /**
  61271. * 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".
  61272. * This function works in right handed mode
  61273. * @param eye defines the final position of the entity
  61274. * @param target defines where the entity should look at
  61275. * @param up defines the up vector for the entity
  61276. * @param result defines the target matrix
  61277. */
  61278. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61279. /**
  61280. * Create a left-handed orthographic projection matrix
  61281. * @param width defines the viewport width
  61282. * @param height defines the viewport height
  61283. * @param znear defines the near clip plane
  61284. * @param zfar defines the far clip plane
  61285. * @returns a new matrix as a left-handed orthographic projection matrix
  61286. */
  61287. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61288. /**
  61289. * Store a left-handed orthographic projection to a given matrix
  61290. * @param width defines the viewport width
  61291. * @param height defines the viewport height
  61292. * @param znear defines the near clip plane
  61293. * @param zfar defines the far clip plane
  61294. * @param result defines the target matrix
  61295. */
  61296. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61297. /**
  61298. * Create a left-handed orthographic projection matrix
  61299. * @param left defines the viewport left coordinate
  61300. * @param right defines the viewport right coordinate
  61301. * @param bottom defines the viewport bottom coordinate
  61302. * @param top defines the viewport top coordinate
  61303. * @param znear defines the near clip plane
  61304. * @param zfar defines the far clip plane
  61305. * @returns a new matrix as a left-handed orthographic projection matrix
  61306. */
  61307. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61308. /**
  61309. * Stores a left-handed orthographic projection into a given matrix
  61310. * @param left defines the viewport left coordinate
  61311. * @param right defines the viewport right coordinate
  61312. * @param bottom defines the viewport bottom coordinate
  61313. * @param top defines the viewport top coordinate
  61314. * @param znear defines the near clip plane
  61315. * @param zfar defines the far clip plane
  61316. * @param result defines the target matrix
  61317. */
  61318. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61319. /**
  61320. * Creates a right-handed orthographic projection matrix
  61321. * @param left defines the viewport left coordinate
  61322. * @param right defines the viewport right coordinate
  61323. * @param bottom defines the viewport bottom coordinate
  61324. * @param top defines the viewport top coordinate
  61325. * @param znear defines the near clip plane
  61326. * @param zfar defines the far clip plane
  61327. * @returns a new matrix as a right-handed orthographic projection matrix
  61328. */
  61329. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61330. /**
  61331. * Stores a right-handed orthographic projection into a given matrix
  61332. * @param left defines the viewport left coordinate
  61333. * @param right defines the viewport right coordinate
  61334. * @param bottom defines the viewport bottom coordinate
  61335. * @param top defines the viewport top coordinate
  61336. * @param znear defines the near clip plane
  61337. * @param zfar defines the far clip plane
  61338. * @param result defines the target matrix
  61339. */
  61340. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61341. /**
  61342. * Creates a left-handed perspective projection matrix
  61343. * @param width defines the viewport width
  61344. * @param height defines the viewport height
  61345. * @param znear defines the near clip plane
  61346. * @param zfar defines the far clip plane
  61347. * @returns a new matrix as a left-handed perspective projection matrix
  61348. */
  61349. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61350. /**
  61351. * Creates a left-handed perspective projection matrix
  61352. * @param fov defines the horizontal field of view
  61353. * @param aspect defines the aspect ratio
  61354. * @param znear defines the near clip plane
  61355. * @param zfar defines the far clip plane
  61356. * @returns a new matrix as a left-handed perspective projection matrix
  61357. */
  61358. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61359. /**
  61360. * Stores a left-handed perspective projection into a given matrix
  61361. * @param fov defines the horizontal field of view
  61362. * @param aspect defines the aspect ratio
  61363. * @param znear defines the near clip plane
  61364. * @param zfar defines the far clip plane
  61365. * @param result defines the target matrix
  61366. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61367. */
  61368. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61369. /**
  61370. * Creates a right-handed perspective projection matrix
  61371. * @param fov defines the horizontal field of view
  61372. * @param aspect defines the aspect ratio
  61373. * @param znear defines the near clip plane
  61374. * @param zfar defines the far clip plane
  61375. * @returns a new matrix as a right-handed perspective projection matrix
  61376. */
  61377. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61378. /**
  61379. * Stores a right-handed perspective projection into a given matrix
  61380. * @param fov defines the horizontal field of view
  61381. * @param aspect defines the aspect ratio
  61382. * @param znear defines the near clip plane
  61383. * @param zfar defines the far clip plane
  61384. * @param result defines the target matrix
  61385. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61386. */
  61387. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61388. /**
  61389. * Stores a perspective projection for WebVR info a given matrix
  61390. * @param fov defines the field of view
  61391. * @param znear defines the near clip plane
  61392. * @param zfar defines the far clip plane
  61393. * @param result defines the target matrix
  61394. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61395. */
  61396. static PerspectiveFovWebVRToRef(fov: {
  61397. upDegrees: number;
  61398. downDegrees: number;
  61399. leftDegrees: number;
  61400. rightDegrees: number;
  61401. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61402. /**
  61403. * Computes a complete transformation matrix
  61404. * @param viewport defines the viewport to use
  61405. * @param world defines the world matrix
  61406. * @param view defines the view matrix
  61407. * @param projection defines the projection matrix
  61408. * @param zmin defines the near clip plane
  61409. * @param zmax defines the far clip plane
  61410. * @returns the transformation matrix
  61411. */
  61412. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61413. /**
  61414. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61415. * @param matrix defines the matrix to use
  61416. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61417. */
  61418. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61419. /**
  61420. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61421. * @param matrix defines the matrix to use
  61422. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61423. */
  61424. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61425. /**
  61426. * Compute the transpose of a given matrix
  61427. * @param matrix defines the matrix to transpose
  61428. * @returns the new matrix
  61429. */
  61430. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61431. /**
  61432. * Compute the transpose of a matrix and store it in a target matrix
  61433. * @param matrix defines the matrix to transpose
  61434. * @param result defines the target matrix
  61435. */
  61436. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61437. /**
  61438. * Computes a reflection matrix from a plane
  61439. * @param plane defines the reflection plane
  61440. * @returns a new matrix
  61441. */
  61442. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61443. /**
  61444. * Computes a reflection matrix from a plane
  61445. * @param plane defines the reflection plane
  61446. * @param result defines the target matrix
  61447. */
  61448. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61449. /**
  61450. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61451. * @param xaxis defines the value of the 1st axis
  61452. * @param yaxis defines the value of the 2nd axis
  61453. * @param zaxis defines the value of the 3rd axis
  61454. * @param result defines the target matrix
  61455. */
  61456. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61457. /**
  61458. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61459. * @param quat defines the quaternion to use
  61460. * @param result defines the target matrix
  61461. */
  61462. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61463. }
  61464. /**
  61465. * Represens a plane by the equation ax + by + cz + d = 0
  61466. */
  61467. export class Plane {
  61468. /**
  61469. * Normal of the plane (a,b,c)
  61470. */
  61471. normal: Vector3;
  61472. /**
  61473. * d component of the plane
  61474. */
  61475. d: number;
  61476. /**
  61477. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61478. * @param a a component of the plane
  61479. * @param b b component of the plane
  61480. * @param c c component of the plane
  61481. * @param d d component of the plane
  61482. */
  61483. constructor(a: number, b: number, c: number, d: number);
  61484. /**
  61485. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61486. */
  61487. asArray(): number[];
  61488. /**
  61489. * @returns a new plane copied from the current Plane.
  61490. */
  61491. clone(): Plane;
  61492. /**
  61493. * @returns the string "Plane".
  61494. */
  61495. getClassName(): string;
  61496. /**
  61497. * @returns the Plane hash code.
  61498. */
  61499. getHashCode(): number;
  61500. /**
  61501. * Normalize the current Plane in place.
  61502. * @returns the updated Plane.
  61503. */
  61504. normalize(): Plane;
  61505. /**
  61506. * Applies a transformation the plane and returns the result
  61507. * @param transformation the transformation matrix to be applied to the plane
  61508. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61509. */
  61510. transform(transformation: DeepImmutable<Matrix>): Plane;
  61511. /**
  61512. * Calcualtte the dot product between the point and the plane normal
  61513. * @param point point to calculate the dot product with
  61514. * @returns the dot product (float) of the point coordinates and the plane normal.
  61515. */
  61516. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61517. /**
  61518. * Updates the current Plane from the plane defined by the three given points.
  61519. * @param point1 one of the points used to contruct the plane
  61520. * @param point2 one of the points used to contruct the plane
  61521. * @param point3 one of the points used to contruct the plane
  61522. * @returns the updated Plane.
  61523. */
  61524. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61525. /**
  61526. * Checks if the plane is facing a given direction
  61527. * @param direction the direction to check if the plane is facing
  61528. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61529. * @returns True is the vector "direction" is the same side than the plane normal.
  61530. */
  61531. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61532. /**
  61533. * Calculates the distance to a point
  61534. * @param point point to calculate distance to
  61535. * @returns the signed distance (float) from the given point to the Plane.
  61536. */
  61537. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61538. /**
  61539. * Creates a plane from an array
  61540. * @param array the array to create a plane from
  61541. * @returns a new Plane from the given array.
  61542. */
  61543. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61544. /**
  61545. * Creates a plane from three points
  61546. * @param point1 point used to create the plane
  61547. * @param point2 point used to create the plane
  61548. * @param point3 point used to create the plane
  61549. * @returns a new Plane defined by the three given points.
  61550. */
  61551. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61552. /**
  61553. * Creates a plane from an origin point and a normal
  61554. * @param origin origin of the plane to be constructed
  61555. * @param normal normal of the plane to be constructed
  61556. * @returns a new Plane the normal vector to this plane at the given origin point.
  61557. * Note : the vector "normal" is updated because normalized.
  61558. */
  61559. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61560. /**
  61561. * Calculates the distance from a plane and a point
  61562. * @param origin origin of the plane to be constructed
  61563. * @param normal normal of the plane to be constructed
  61564. * @param point point to calculate distance to
  61565. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61566. */
  61567. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61568. }
  61569. /**
  61570. * Class used to represent a viewport on screen
  61571. */
  61572. export class Viewport {
  61573. /** viewport left coordinate */
  61574. x: number;
  61575. /** viewport top coordinate */
  61576. y: number;
  61577. /**viewport width */
  61578. width: number;
  61579. /** viewport height */
  61580. height: number;
  61581. /**
  61582. * Creates a Viewport object located at (x, y) and sized (width, height)
  61583. * @param x defines viewport left coordinate
  61584. * @param y defines viewport top coordinate
  61585. * @param width defines the viewport width
  61586. * @param height defines the viewport height
  61587. */
  61588. constructor(
  61589. /** viewport left coordinate */
  61590. x: number,
  61591. /** viewport top coordinate */
  61592. y: number,
  61593. /**viewport width */
  61594. width: number,
  61595. /** viewport height */
  61596. height: number);
  61597. /**
  61598. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61599. * @param renderWidth defines the rendering width
  61600. * @param renderHeight defines the rendering height
  61601. * @returns a new Viewport
  61602. */
  61603. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61604. /**
  61605. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61606. * @param renderWidth defines the rendering width
  61607. * @param renderHeight defines the rendering height
  61608. * @param ref defines the target viewport
  61609. * @returns the current viewport
  61610. */
  61611. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61612. /**
  61613. * Returns a new Viewport copied from the current one
  61614. * @returns a new Viewport
  61615. */
  61616. clone(): Viewport;
  61617. }
  61618. /**
  61619. * Reprasents a camera frustum
  61620. */
  61621. export class Frustum {
  61622. /**
  61623. * Gets the planes representing the frustum
  61624. * @param transform matrix to be applied to the returned planes
  61625. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61626. */
  61627. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61628. /**
  61629. * Gets the near frustum plane transformed by the transform matrix
  61630. * @param transform transformation matrix to be applied to the resulting frustum plane
  61631. * @param frustumPlane the resuling frustum plane
  61632. */
  61633. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61634. /**
  61635. * Gets the far frustum plane transformed by the transform matrix
  61636. * @param transform transformation matrix to be applied to the resulting frustum plane
  61637. * @param frustumPlane the resuling frustum plane
  61638. */
  61639. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61640. /**
  61641. * Gets the left frustum plane transformed by the transform matrix
  61642. * @param transform transformation matrix to be applied to the resulting frustum plane
  61643. * @param frustumPlane the resuling frustum plane
  61644. */
  61645. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61646. /**
  61647. * Gets the right frustum plane transformed by the transform matrix
  61648. * @param transform transformation matrix to be applied to the resulting frustum plane
  61649. * @param frustumPlane the resuling frustum plane
  61650. */
  61651. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61652. /**
  61653. * Gets the top frustum plane transformed by the transform matrix
  61654. * @param transform transformation matrix to be applied to the resulting frustum plane
  61655. * @param frustumPlane the resuling frustum plane
  61656. */
  61657. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61658. /**
  61659. * Gets the bottom frustum plane transformed by the transform matrix
  61660. * @param transform transformation matrix to be applied to the resulting frustum plane
  61661. * @param frustumPlane the resuling frustum plane
  61662. */
  61663. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61664. /**
  61665. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61666. * @param transform transformation matrix to be applied to the resulting frustum planes
  61667. * @param frustumPlanes the resuling frustum planes
  61668. */
  61669. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61670. }
  61671. /** Defines supported spaces */
  61672. export enum Space {
  61673. /** Local (object) space */
  61674. LOCAL = 0,
  61675. /** World space */
  61676. WORLD = 1,
  61677. /** Bone space */
  61678. BONE = 2
  61679. }
  61680. /** Defines the 3 main axes */
  61681. export class Axis {
  61682. /** X axis */
  61683. static X: Vector3;
  61684. /** Y axis */
  61685. static Y: Vector3;
  61686. /** Z axis */
  61687. static Z: Vector3;
  61688. }
  61689. /** Class used to represent a Bezier curve */
  61690. export class BezierCurve {
  61691. /**
  61692. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61693. * @param t defines the time
  61694. * @param x1 defines the left coordinate on X axis
  61695. * @param y1 defines the left coordinate on Y axis
  61696. * @param x2 defines the right coordinate on X axis
  61697. * @param y2 defines the right coordinate on Y axis
  61698. * @returns the interpolated value
  61699. */
  61700. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61701. }
  61702. /**
  61703. * Defines potential orientation for back face culling
  61704. */
  61705. export enum Orientation {
  61706. /**
  61707. * Clockwise
  61708. */
  61709. CW = 0,
  61710. /** Counter clockwise */
  61711. CCW = 1
  61712. }
  61713. /**
  61714. * Defines angle representation
  61715. */
  61716. export class Angle {
  61717. private _radians;
  61718. /**
  61719. * Creates an Angle object of "radians" radians (float).
  61720. * @param radians the angle in radians
  61721. */
  61722. constructor(radians: number);
  61723. /**
  61724. * Get value in degrees
  61725. * @returns the Angle value in degrees (float)
  61726. */
  61727. degrees(): number;
  61728. /**
  61729. * Get value in radians
  61730. * @returns the Angle value in radians (float)
  61731. */
  61732. radians(): number;
  61733. /**
  61734. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61735. * @param a defines first vector
  61736. * @param b defines second vector
  61737. * @returns a new Angle
  61738. */
  61739. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61740. /**
  61741. * Gets a new Angle object from the given float in radians
  61742. * @param radians defines the angle value in radians
  61743. * @returns a new Angle
  61744. */
  61745. static FromRadians(radians: number): Angle;
  61746. /**
  61747. * Gets a new Angle object from the given float in degrees
  61748. * @param degrees defines the angle value in degrees
  61749. * @returns a new Angle
  61750. */
  61751. static FromDegrees(degrees: number): Angle;
  61752. }
  61753. /**
  61754. * This represents an arc in a 2d space.
  61755. */
  61756. export class Arc2 {
  61757. /** Defines the start point of the arc */
  61758. startPoint: Vector2;
  61759. /** Defines the mid point of the arc */
  61760. midPoint: Vector2;
  61761. /** Defines the end point of the arc */
  61762. endPoint: Vector2;
  61763. /**
  61764. * Defines the center point of the arc.
  61765. */
  61766. centerPoint: Vector2;
  61767. /**
  61768. * Defines the radius of the arc.
  61769. */
  61770. radius: number;
  61771. /**
  61772. * Defines the angle of the arc (from mid point to end point).
  61773. */
  61774. angle: Angle;
  61775. /**
  61776. * Defines the start angle of the arc (from start point to middle point).
  61777. */
  61778. startAngle: Angle;
  61779. /**
  61780. * Defines the orientation of the arc (clock wise/counter clock wise).
  61781. */
  61782. orientation: Orientation;
  61783. /**
  61784. * Creates an Arc object from the three given points : start, middle and end.
  61785. * @param startPoint Defines the start point of the arc
  61786. * @param midPoint Defines the midlle point of the arc
  61787. * @param endPoint Defines the end point of the arc
  61788. */
  61789. constructor(
  61790. /** Defines the start point of the arc */
  61791. startPoint: Vector2,
  61792. /** Defines the mid point of the arc */
  61793. midPoint: Vector2,
  61794. /** Defines the end point of the arc */
  61795. endPoint: Vector2);
  61796. }
  61797. /**
  61798. * Represents a 2D path made up of multiple 2D points
  61799. */
  61800. export class Path2 {
  61801. private _points;
  61802. private _length;
  61803. /**
  61804. * If the path start and end point are the same
  61805. */
  61806. closed: boolean;
  61807. /**
  61808. * Creates a Path2 object from the starting 2D coordinates x and y.
  61809. * @param x the starting points x value
  61810. * @param y the starting points y value
  61811. */
  61812. constructor(x: number, y: number);
  61813. /**
  61814. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61815. * @param x the added points x value
  61816. * @param y the added points y value
  61817. * @returns the updated Path2.
  61818. */
  61819. addLineTo(x: number, y: number): Path2;
  61820. /**
  61821. * 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.
  61822. * @param midX middle point x value
  61823. * @param midY middle point y value
  61824. * @param endX end point x value
  61825. * @param endY end point y value
  61826. * @param numberOfSegments (default: 36)
  61827. * @returns the updated Path2.
  61828. */
  61829. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61830. /**
  61831. * Closes the Path2.
  61832. * @returns the Path2.
  61833. */
  61834. close(): Path2;
  61835. /**
  61836. * Gets the sum of the distance between each sequential point in the path
  61837. * @returns the Path2 total length (float).
  61838. */
  61839. length(): number;
  61840. /**
  61841. * Gets the points which construct the path
  61842. * @returns the Path2 internal array of points.
  61843. */
  61844. getPoints(): Vector2[];
  61845. /**
  61846. * Retreives the point at the distance aways from the starting point
  61847. * @param normalizedLengthPosition the length along the path to retreive the point from
  61848. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61849. */
  61850. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61851. /**
  61852. * Creates a new path starting from an x and y position
  61853. * @param x starting x value
  61854. * @param y starting y value
  61855. * @returns a new Path2 starting at the coordinates (x, y).
  61856. */
  61857. static StartingAt(x: number, y: number): Path2;
  61858. }
  61859. /**
  61860. * Represents a 3D path made up of multiple 3D points
  61861. */
  61862. export class Path3D {
  61863. /**
  61864. * an array of Vector3, the curve axis of the Path3D
  61865. */
  61866. path: Vector3[];
  61867. private _curve;
  61868. private _distances;
  61869. private _tangents;
  61870. private _normals;
  61871. private _binormals;
  61872. private _raw;
  61873. /**
  61874. * new Path3D(path, normal, raw)
  61875. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61876. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61877. * @param path an array of Vector3, the curve axis of the Path3D
  61878. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61879. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61880. */
  61881. constructor(
  61882. /**
  61883. * an array of Vector3, the curve axis of the Path3D
  61884. */
  61885. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61886. /**
  61887. * Returns the Path3D array of successive Vector3 designing its curve.
  61888. * @returns the Path3D array of successive Vector3 designing its curve.
  61889. */
  61890. getCurve(): Vector3[];
  61891. /**
  61892. * Returns an array populated with tangent vectors on each Path3D curve point.
  61893. * @returns an array populated with tangent vectors on each Path3D curve point.
  61894. */
  61895. getTangents(): Vector3[];
  61896. /**
  61897. * Returns an array populated with normal vectors on each Path3D curve point.
  61898. * @returns an array populated with normal vectors on each Path3D curve point.
  61899. */
  61900. getNormals(): Vector3[];
  61901. /**
  61902. * Returns an array populated with binormal vectors on each Path3D curve point.
  61903. * @returns an array populated with binormal vectors on each Path3D curve point.
  61904. */
  61905. getBinormals(): Vector3[];
  61906. /**
  61907. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61908. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61909. */
  61910. getDistances(): number[];
  61911. /**
  61912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61913. * @param path path which all values are copied into the curves points
  61914. * @param firstNormal which should be projected onto the curve
  61915. * @returns the same object updated.
  61916. */
  61917. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61918. private _compute;
  61919. private _getFirstNonNullVector;
  61920. private _getLastNonNullVector;
  61921. private _normalVector;
  61922. }
  61923. /**
  61924. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61925. * A Curve3 is designed from a series of successive Vector3.
  61926. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61927. */
  61928. export class Curve3 {
  61929. private _points;
  61930. private _length;
  61931. /**
  61932. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61933. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61934. * @param v1 (Vector3) the control point
  61935. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61936. * @param nbPoints (integer) the wanted number of points in the curve
  61937. * @returns the created Curve3
  61938. */
  61939. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61940. /**
  61941. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61942. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61943. * @param v1 (Vector3) the first control point
  61944. * @param v2 (Vector3) the second control point
  61945. * @param v3 (Vector3) the end point of the Cubic Bezier
  61946. * @param nbPoints (integer) the wanted number of points in the curve
  61947. * @returns the created Curve3
  61948. */
  61949. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61950. /**
  61951. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61952. * @param p1 (Vector3) the origin point of the Hermite Spline
  61953. * @param t1 (Vector3) the tangent vector at the origin point
  61954. * @param p2 (Vector3) the end point of the Hermite Spline
  61955. * @param t2 (Vector3) the tangent vector at the end point
  61956. * @param nbPoints (integer) the wanted number of points in the curve
  61957. * @returns the created Curve3
  61958. */
  61959. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61960. /**
  61961. * Returns a Curve3 object along a CatmullRom Spline curve :
  61962. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61963. * @param nbPoints (integer) the wanted number of points between each curve control points
  61964. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61965. * @returns the created Curve3
  61966. */
  61967. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61968. /**
  61969. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61970. * A Curve3 is designed from a series of successive Vector3.
  61971. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61972. * @param points points which make up the curve
  61973. */
  61974. constructor(points: Vector3[]);
  61975. /**
  61976. * @returns the Curve3 stored array of successive Vector3
  61977. */
  61978. getPoints(): Vector3[];
  61979. /**
  61980. * @returns the computed length (float) of the curve.
  61981. */
  61982. length(): number;
  61983. /**
  61984. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61985. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61986. * curveA and curveB keep unchanged.
  61987. * @param curve the curve to continue from this curve
  61988. * @returns the newly constructed curve
  61989. */
  61990. continue(curve: DeepImmutable<Curve3>): Curve3;
  61991. private _computeLength;
  61992. }
  61993. /**
  61994. * Contains position and normal vectors for a vertex
  61995. */
  61996. export class PositionNormalVertex {
  61997. /** the position of the vertex (defaut: 0,0,0) */
  61998. position: Vector3;
  61999. /** the normal of the vertex (defaut: 0,1,0) */
  62000. normal: Vector3;
  62001. /**
  62002. * Creates a PositionNormalVertex
  62003. * @param position the position of the vertex (defaut: 0,0,0)
  62004. * @param normal the normal of the vertex (defaut: 0,1,0)
  62005. */
  62006. constructor(
  62007. /** the position of the vertex (defaut: 0,0,0) */
  62008. position?: Vector3,
  62009. /** the normal of the vertex (defaut: 0,1,0) */
  62010. normal?: Vector3);
  62011. /**
  62012. * Clones the PositionNormalVertex
  62013. * @returns the cloned PositionNormalVertex
  62014. */
  62015. clone(): PositionNormalVertex;
  62016. }
  62017. /**
  62018. * Contains position, normal and uv vectors for a vertex
  62019. */
  62020. export class PositionNormalTextureVertex {
  62021. /** the position of the vertex (defaut: 0,0,0) */
  62022. position: Vector3;
  62023. /** the normal of the vertex (defaut: 0,1,0) */
  62024. normal: Vector3;
  62025. /** the uv of the vertex (default: 0,0) */
  62026. uv: Vector2;
  62027. /**
  62028. * Creates a PositionNormalTextureVertex
  62029. * @param position the position of the vertex (defaut: 0,0,0)
  62030. * @param normal the normal of the vertex (defaut: 0,1,0)
  62031. * @param uv the uv of the vertex (default: 0,0)
  62032. */
  62033. constructor(
  62034. /** the position of the vertex (defaut: 0,0,0) */
  62035. position?: Vector3,
  62036. /** the normal of the vertex (defaut: 0,1,0) */
  62037. normal?: Vector3,
  62038. /** the uv of the vertex (default: 0,0) */
  62039. uv?: Vector2);
  62040. /**
  62041. * Clones the PositionNormalTextureVertex
  62042. * @returns the cloned PositionNormalTextureVertex
  62043. */
  62044. clone(): PositionNormalTextureVertex;
  62045. }
  62046. /**
  62047. * @hidden
  62048. */
  62049. export class Tmp {
  62050. static Color3: Color3[];
  62051. static Color4: Color4[];
  62052. static Vector2: Vector2[];
  62053. static Vector3: Vector3[];
  62054. static Vector4: Vector4[];
  62055. static Quaternion: Quaternion[];
  62056. static Matrix: Matrix[];
  62057. }
  62058. }
  62059. declare module BABYLON {
  62060. /**
  62061. * Class used to enable access to offline support
  62062. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62063. */
  62064. export interface IOfflineProvider {
  62065. /**
  62066. * Gets a boolean indicating if scene must be saved in the database
  62067. */
  62068. enableSceneOffline: boolean;
  62069. /**
  62070. * Gets a boolean indicating if textures must be saved in the database
  62071. */
  62072. enableTexturesOffline: boolean;
  62073. /**
  62074. * Open the offline support and make it available
  62075. * @param successCallback defines the callback to call on success
  62076. * @param errorCallback defines the callback to call on error
  62077. */
  62078. open(successCallback: () => void, errorCallback: () => void): void;
  62079. /**
  62080. * Loads an image from the offline support
  62081. * @param url defines the url to load from
  62082. * @param image defines the target DOM image
  62083. */
  62084. loadImage(url: string, image: HTMLImageElement): void;
  62085. /**
  62086. * Loads a file from offline support
  62087. * @param url defines the URL to load from
  62088. * @param sceneLoaded defines a callback to call on success
  62089. * @param progressCallBack defines a callback to call when progress changed
  62090. * @param errorCallback defines a callback to call on error
  62091. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62092. */
  62093. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62094. }
  62095. }
  62096. declare module BABYLON {
  62097. /**
  62098. * A class serves as a medium between the observable and its observers
  62099. */
  62100. export class EventState {
  62101. /**
  62102. * Create a new EventState
  62103. * @param mask defines the mask associated with this state
  62104. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62105. * @param target defines the original target of the state
  62106. * @param currentTarget defines the current target of the state
  62107. */
  62108. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62109. /**
  62110. * Initialize the current event state
  62111. * @param mask defines the mask associated with this state
  62112. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62113. * @param target defines the original target of the state
  62114. * @param currentTarget defines the current target of the state
  62115. * @returns the current event state
  62116. */
  62117. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62118. /**
  62119. * An Observer can set this property to true to prevent subsequent observers of being notified
  62120. */
  62121. skipNextObservers: boolean;
  62122. /**
  62123. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62124. */
  62125. mask: number;
  62126. /**
  62127. * The object that originally notified the event
  62128. */
  62129. target?: any;
  62130. /**
  62131. * The current object in the bubbling phase
  62132. */
  62133. currentTarget?: any;
  62134. /**
  62135. * This will be populated with the return value of the last function that was executed.
  62136. * If it is the first function in the callback chain it will be the event data.
  62137. */
  62138. lastReturnValue?: any;
  62139. }
  62140. /**
  62141. * Represent an Observer registered to a given Observable object.
  62142. */
  62143. export class Observer<T> {
  62144. /**
  62145. * Defines the callback to call when the observer is notified
  62146. */
  62147. callback: (eventData: T, eventState: EventState) => void;
  62148. /**
  62149. * Defines the mask of the observer (used to filter notifications)
  62150. */
  62151. mask: number;
  62152. /**
  62153. * Defines the current scope used to restore the JS context
  62154. */
  62155. scope: any;
  62156. /** @hidden */
  62157. _willBeUnregistered: boolean;
  62158. /**
  62159. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62160. */
  62161. unregisterOnNextCall: boolean;
  62162. /**
  62163. * Creates a new observer
  62164. * @param callback defines the callback to call when the observer is notified
  62165. * @param mask defines the mask of the observer (used to filter notifications)
  62166. * @param scope defines the current scope used to restore the JS context
  62167. */
  62168. constructor(
  62169. /**
  62170. * Defines the callback to call when the observer is notified
  62171. */
  62172. callback: (eventData: T, eventState: EventState) => void,
  62173. /**
  62174. * Defines the mask of the observer (used to filter notifications)
  62175. */
  62176. mask: number,
  62177. /**
  62178. * Defines the current scope used to restore the JS context
  62179. */
  62180. scope?: any);
  62181. }
  62182. /**
  62183. * Represent a list of observers registered to multiple Observables object.
  62184. */
  62185. export class MultiObserver<T> {
  62186. private _observers;
  62187. private _observables;
  62188. /**
  62189. * Release associated resources
  62190. */
  62191. dispose(): void;
  62192. /**
  62193. * Raise a callback when one of the observable will notify
  62194. * @param observables defines a list of observables to watch
  62195. * @param callback defines the callback to call on notification
  62196. * @param mask defines the mask used to filter notifications
  62197. * @param scope defines the current scope used to restore the JS context
  62198. * @returns the new MultiObserver
  62199. */
  62200. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62201. }
  62202. /**
  62203. * The Observable class is a simple implementation of the Observable pattern.
  62204. *
  62205. * 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.
  62206. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62207. * 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).
  62208. * 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.
  62209. */
  62210. export class Observable<T> {
  62211. private _observers;
  62212. private _eventState;
  62213. private _onObserverAdded;
  62214. /**
  62215. * Creates a new observable
  62216. * @param onObserverAdded defines a callback to call when a new observer is added
  62217. */
  62218. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62219. /**
  62220. * Create a new Observer with the specified callback
  62221. * @param callback the callback that will be executed for that Observer
  62222. * @param mask the mask used to filter observers
  62223. * @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.
  62224. * @param scope optional scope for the callback to be called from
  62225. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62226. * @returns the new observer created for the callback
  62227. */
  62228. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62229. /**
  62230. * Create a new Observer with the specified callback and unregisters after the next notification
  62231. * @param callback the callback that will be executed for that Observer
  62232. * @returns the new observer created for the callback
  62233. */
  62234. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62235. /**
  62236. * Remove an Observer from the Observable object
  62237. * @param observer the instance of the Observer to remove
  62238. * @returns false if it doesn't belong to this Observable
  62239. */
  62240. remove(observer: Nullable<Observer<T>>): boolean;
  62241. /**
  62242. * Remove a callback from the Observable object
  62243. * @param callback the callback to remove
  62244. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62245. * @returns false if it doesn't belong to this Observable
  62246. */
  62247. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62248. private _deferUnregister;
  62249. private _remove;
  62250. /**
  62251. * Notify all Observers by calling their respective callback with the given data
  62252. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62253. * @param eventData defines the data to send to all observers
  62254. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62255. * @param target defines the original target of the state
  62256. * @param currentTarget defines the current target of the state
  62257. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62258. */
  62259. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62260. /**
  62261. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62262. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62263. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62264. * and it is crucial that all callbacks will be executed.
  62265. * The order of the callbacks is kept, callbacks are not executed parallel.
  62266. *
  62267. * @param eventData The data to be sent to each callback
  62268. * @param mask is used to filter observers defaults to -1
  62269. * @param target defines the callback target (see EventState)
  62270. * @param currentTarget defines he current object in the bubbling phase
  62271. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62272. */
  62273. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62274. /**
  62275. * Notify a specific observer
  62276. * @param observer defines the observer to notify
  62277. * @param eventData defines the data to be sent to each callback
  62278. * @param mask is used to filter observers defaults to -1
  62279. */
  62280. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62281. /**
  62282. * Gets a boolean indicating if the observable has at least one observer
  62283. * @returns true is the Observable has at least one Observer registered
  62284. */
  62285. hasObservers(): boolean;
  62286. /**
  62287. * Clear the list of observers
  62288. */
  62289. clear(): void;
  62290. /**
  62291. * Clone the current observable
  62292. * @returns a new observable
  62293. */
  62294. clone(): Observable<T>;
  62295. /**
  62296. * Does this observable handles observer registered with a given mask
  62297. * @param mask defines the mask to be tested
  62298. * @return whether or not one observer registered with the given mask is handeled
  62299. **/
  62300. hasSpecificMask(mask?: number): boolean;
  62301. }
  62302. }
  62303. declare module BABYLON {
  62304. /**
  62305. * Class used to help managing file picking and drag'n'drop
  62306. * File Storage
  62307. */
  62308. export class FilesInputStore {
  62309. /**
  62310. * List of files ready to be loaded
  62311. */
  62312. static FilesToLoad: {
  62313. [key: string]: File;
  62314. };
  62315. }
  62316. }
  62317. declare module BABYLON {
  62318. /** Defines the cross module used constants to avoid circular dependncies */
  62319. export class Constants {
  62320. /** Defines that alpha blending is disabled */
  62321. static readonly ALPHA_DISABLE: number;
  62322. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62323. static readonly ALPHA_ADD: number;
  62324. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62325. static readonly ALPHA_COMBINE: number;
  62326. /** Defines that alpha blending to DEST - SRC * DEST */
  62327. static readonly ALPHA_SUBTRACT: number;
  62328. /** Defines that alpha blending to SRC * DEST */
  62329. static readonly ALPHA_MULTIPLY: number;
  62330. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62331. static readonly ALPHA_MAXIMIZED: number;
  62332. /** Defines that alpha blending to SRC + DEST */
  62333. static readonly ALPHA_ONEONE: number;
  62334. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62335. static readonly ALPHA_PREMULTIPLIED: number;
  62336. /**
  62337. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62338. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62339. */
  62340. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62341. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62342. static readonly ALPHA_INTERPOLATE: number;
  62343. /**
  62344. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62345. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62346. */
  62347. static readonly ALPHA_SCREENMODE: number;
  62348. /** Defines that the ressource is not delayed*/
  62349. static readonly DELAYLOADSTATE_NONE: number;
  62350. /** Defines that the ressource was successfully delay loaded */
  62351. static readonly DELAYLOADSTATE_LOADED: number;
  62352. /** Defines that the ressource is currently delay loading */
  62353. static readonly DELAYLOADSTATE_LOADING: number;
  62354. /** Defines that the ressource is delayed and has not started loading */
  62355. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62356. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62357. static readonly NEVER: number;
  62358. /** 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 */
  62359. static readonly ALWAYS: number;
  62360. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62361. static readonly LESS: number;
  62362. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62363. static readonly EQUAL: number;
  62364. /** 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 */
  62365. static readonly LEQUAL: number;
  62366. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62367. static readonly GREATER: number;
  62368. /** 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 */
  62369. static readonly GEQUAL: number;
  62370. /** 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 */
  62371. static readonly NOTEQUAL: number;
  62372. /** Passed to stencilOperation to specify that stencil value must be kept */
  62373. static readonly KEEP: number;
  62374. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62375. static readonly REPLACE: number;
  62376. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62377. static readonly INCR: number;
  62378. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62379. static readonly DECR: number;
  62380. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62381. static readonly INVERT: number;
  62382. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62383. static readonly INCR_WRAP: number;
  62384. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62385. static readonly DECR_WRAP: number;
  62386. /** Texture is not repeating outside of 0..1 UVs */
  62387. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62388. /** Texture is repeating outside of 0..1 UVs */
  62389. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62390. /** Texture is repeating and mirrored */
  62391. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62392. /** ALPHA */
  62393. static readonly TEXTUREFORMAT_ALPHA: number;
  62394. /** LUMINANCE */
  62395. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62396. /** LUMINANCE_ALPHA */
  62397. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62398. /** RGB */
  62399. static readonly TEXTUREFORMAT_RGB: number;
  62400. /** RGBA */
  62401. static readonly TEXTUREFORMAT_RGBA: number;
  62402. /** RED */
  62403. static readonly TEXTUREFORMAT_RED: number;
  62404. /** RED (2nd reference) */
  62405. static readonly TEXTUREFORMAT_R: number;
  62406. /** RG */
  62407. static readonly TEXTUREFORMAT_RG: number;
  62408. /** RED_INTEGER */
  62409. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62410. /** RED_INTEGER (2nd reference) */
  62411. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62412. /** RG_INTEGER */
  62413. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62414. /** RGB_INTEGER */
  62415. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62416. /** RGBA_INTEGER */
  62417. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62418. /** UNSIGNED_BYTE */
  62419. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62420. /** UNSIGNED_BYTE (2nd reference) */
  62421. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62422. /** FLOAT */
  62423. static readonly TEXTURETYPE_FLOAT: number;
  62424. /** HALF_FLOAT */
  62425. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62426. /** BYTE */
  62427. static readonly TEXTURETYPE_BYTE: number;
  62428. /** SHORT */
  62429. static readonly TEXTURETYPE_SHORT: number;
  62430. /** UNSIGNED_SHORT */
  62431. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62432. /** INT */
  62433. static readonly TEXTURETYPE_INT: number;
  62434. /** UNSIGNED_INT */
  62435. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62436. /** UNSIGNED_SHORT_4_4_4_4 */
  62437. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62438. /** UNSIGNED_SHORT_5_5_5_1 */
  62439. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62440. /** UNSIGNED_SHORT_5_6_5 */
  62441. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62442. /** UNSIGNED_INT_2_10_10_10_REV */
  62443. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62444. /** UNSIGNED_INT_24_8 */
  62445. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62446. /** UNSIGNED_INT_10F_11F_11F_REV */
  62447. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62448. /** UNSIGNED_INT_5_9_9_9_REV */
  62449. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62450. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62451. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62452. /** nearest is mag = nearest and min = nearest and mip = linear */
  62453. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62454. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62455. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62456. /** Trilinear is mag = linear and min = linear and mip = linear */
  62457. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62458. /** nearest is mag = nearest and min = nearest and mip = linear */
  62459. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62460. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62461. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62462. /** Trilinear is mag = linear and min = linear and mip = linear */
  62463. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62464. /** mag = nearest and min = nearest and mip = nearest */
  62465. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62466. /** mag = nearest and min = linear and mip = nearest */
  62467. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62468. /** mag = nearest and min = linear and mip = linear */
  62469. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62470. /** mag = nearest and min = linear and mip = none */
  62471. static readonly TEXTURE_NEAREST_LINEAR: number;
  62472. /** mag = nearest and min = nearest and mip = none */
  62473. static readonly TEXTURE_NEAREST_NEAREST: number;
  62474. /** mag = linear and min = nearest and mip = nearest */
  62475. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62476. /** mag = linear and min = nearest and mip = linear */
  62477. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62478. /** mag = linear and min = linear and mip = none */
  62479. static readonly TEXTURE_LINEAR_LINEAR: number;
  62480. /** mag = linear and min = nearest and mip = none */
  62481. static readonly TEXTURE_LINEAR_NEAREST: number;
  62482. /** Explicit coordinates mode */
  62483. static readonly TEXTURE_EXPLICIT_MODE: number;
  62484. /** Spherical coordinates mode */
  62485. static readonly TEXTURE_SPHERICAL_MODE: number;
  62486. /** Planar coordinates mode */
  62487. static readonly TEXTURE_PLANAR_MODE: number;
  62488. /** Cubic coordinates mode */
  62489. static readonly TEXTURE_CUBIC_MODE: number;
  62490. /** Projection coordinates mode */
  62491. static readonly TEXTURE_PROJECTION_MODE: number;
  62492. /** Skybox coordinates mode */
  62493. static readonly TEXTURE_SKYBOX_MODE: number;
  62494. /** Inverse Cubic coordinates mode */
  62495. static readonly TEXTURE_INVCUBIC_MODE: number;
  62496. /** Equirectangular coordinates mode */
  62497. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62498. /** Equirectangular Fixed coordinates mode */
  62499. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62500. /** Equirectangular Fixed Mirrored coordinates mode */
  62501. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62502. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62503. static readonly SCALEMODE_FLOOR: number;
  62504. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62505. static readonly SCALEMODE_NEAREST: number;
  62506. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62507. static readonly SCALEMODE_CEILING: number;
  62508. /**
  62509. * The dirty texture flag value
  62510. */
  62511. static readonly MATERIAL_TextureDirtyFlag: number;
  62512. /**
  62513. * The dirty light flag value
  62514. */
  62515. static readonly MATERIAL_LightDirtyFlag: number;
  62516. /**
  62517. * The dirty fresnel flag value
  62518. */
  62519. static readonly MATERIAL_FresnelDirtyFlag: number;
  62520. /**
  62521. * The dirty attribute flag value
  62522. */
  62523. static readonly MATERIAL_AttributesDirtyFlag: number;
  62524. /**
  62525. * The dirty misc flag value
  62526. */
  62527. static readonly MATERIAL_MiscDirtyFlag: number;
  62528. /**
  62529. * The all dirty flag value
  62530. */
  62531. static readonly MATERIAL_AllDirtyFlag: number;
  62532. /**
  62533. * Returns the triangle fill mode
  62534. */
  62535. static readonly MATERIAL_TriangleFillMode: number;
  62536. /**
  62537. * Returns the wireframe mode
  62538. */
  62539. static readonly MATERIAL_WireFrameFillMode: number;
  62540. /**
  62541. * Returns the point fill mode
  62542. */
  62543. static readonly MATERIAL_PointFillMode: number;
  62544. /**
  62545. * Returns the point list draw mode
  62546. */
  62547. static readonly MATERIAL_PointListDrawMode: number;
  62548. /**
  62549. * Returns the line list draw mode
  62550. */
  62551. static readonly MATERIAL_LineListDrawMode: number;
  62552. /**
  62553. * Returns the line loop draw mode
  62554. */
  62555. static readonly MATERIAL_LineLoopDrawMode: number;
  62556. /**
  62557. * Returns the line strip draw mode
  62558. */
  62559. static readonly MATERIAL_LineStripDrawMode: number;
  62560. /**
  62561. * Returns the triangle strip draw mode
  62562. */
  62563. static readonly MATERIAL_TriangleStripDrawMode: number;
  62564. /**
  62565. * Returns the triangle fan draw mode
  62566. */
  62567. static readonly MATERIAL_TriangleFanDrawMode: number;
  62568. /**
  62569. * Stores the clock-wise side orientation
  62570. */
  62571. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62572. /**
  62573. * Stores the counter clock-wise side orientation
  62574. */
  62575. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62576. /**
  62577. * Nothing
  62578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62579. */
  62580. static readonly ACTION_NothingTrigger: number;
  62581. /**
  62582. * On pick
  62583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62584. */
  62585. static readonly ACTION_OnPickTrigger: number;
  62586. /**
  62587. * On left pick
  62588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62589. */
  62590. static readonly ACTION_OnLeftPickTrigger: number;
  62591. /**
  62592. * On right pick
  62593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62594. */
  62595. static readonly ACTION_OnRightPickTrigger: number;
  62596. /**
  62597. * On center pick
  62598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62599. */
  62600. static readonly ACTION_OnCenterPickTrigger: number;
  62601. /**
  62602. * On pick down
  62603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62604. */
  62605. static readonly ACTION_OnPickDownTrigger: number;
  62606. /**
  62607. * On double pick
  62608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62609. */
  62610. static readonly ACTION_OnDoublePickTrigger: number;
  62611. /**
  62612. * On pick up
  62613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62614. */
  62615. static readonly ACTION_OnPickUpTrigger: number;
  62616. /**
  62617. * On pick out.
  62618. * This trigger will only be raised if you also declared a OnPickDown
  62619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62620. */
  62621. static readonly ACTION_OnPickOutTrigger: number;
  62622. /**
  62623. * On long press
  62624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62625. */
  62626. static readonly ACTION_OnLongPressTrigger: number;
  62627. /**
  62628. * On pointer over
  62629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62630. */
  62631. static readonly ACTION_OnPointerOverTrigger: number;
  62632. /**
  62633. * On pointer out
  62634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62635. */
  62636. static readonly ACTION_OnPointerOutTrigger: number;
  62637. /**
  62638. * On every frame
  62639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62640. */
  62641. static readonly ACTION_OnEveryFrameTrigger: number;
  62642. /**
  62643. * On intersection enter
  62644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62645. */
  62646. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62647. /**
  62648. * On intersection exit
  62649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62650. */
  62651. static readonly ACTION_OnIntersectionExitTrigger: number;
  62652. /**
  62653. * On key down
  62654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62655. */
  62656. static readonly ACTION_OnKeyDownTrigger: number;
  62657. /**
  62658. * On key up
  62659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62660. */
  62661. static readonly ACTION_OnKeyUpTrigger: number;
  62662. /**
  62663. * Billboard mode will only apply to Y axis
  62664. */
  62665. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62666. /**
  62667. * Billboard mode will apply to all axes
  62668. */
  62669. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62670. /**
  62671. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62672. */
  62673. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62674. /**
  62675. * Gets or sets base Assets URL
  62676. */
  62677. static readonly PARTICLES_BaseAssetsUrl: string;
  62678. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62679. * Test order :
  62680. * Is the bounding sphere outside the frustum ?
  62681. * If not, are the bounding box vertices outside the frustum ?
  62682. * It not, then the cullable object is in the frustum.
  62683. */
  62684. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62685. /** Culling strategy : Bounding Sphere Only.
  62686. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62687. * It's also less accurate than the standard because some not visible objects can still be selected.
  62688. * Test : is the bounding sphere outside the frustum ?
  62689. * If not, then the cullable object is in the frustum.
  62690. */
  62691. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62692. /** Culling strategy : Optimistic Inclusion.
  62693. * This in an inclusion test first, then the standard exclusion test.
  62694. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62695. * 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.
  62696. * Anyway, it's as accurate as the standard strategy.
  62697. * Test :
  62698. * Is the cullable object bounding sphere center in the frustum ?
  62699. * If not, apply the default culling strategy.
  62700. */
  62701. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62702. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62703. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62704. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62705. * 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.
  62706. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62707. * Test :
  62708. * Is the cullable object bounding sphere center in the frustum ?
  62709. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62710. */
  62711. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62712. /**
  62713. * No logging while loading
  62714. */
  62715. static readonly SCENELOADER_NO_LOGGING: number;
  62716. /**
  62717. * Minimal logging while loading
  62718. */
  62719. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62720. /**
  62721. * Summary logging while loading
  62722. */
  62723. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62724. /**
  62725. * Detailled logging while loading
  62726. */
  62727. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62733. * Babylon.js
  62734. */
  62735. export class DomManagement {
  62736. /**
  62737. * Checks if the window object exists
  62738. * @returns true if the window object exists
  62739. */
  62740. static IsWindowObjectExist(): boolean;
  62741. /**
  62742. * Extracts text content from a DOM element hierarchy
  62743. * @param element defines the root element
  62744. * @returns a string
  62745. */
  62746. static GetDOMTextContent(element: HTMLElement): string;
  62747. }
  62748. }
  62749. declare module BABYLON {
  62750. /**
  62751. * Logger used througouht the application to allow configuration of
  62752. * the log level required for the messages.
  62753. */
  62754. export class Logger {
  62755. /**
  62756. * No log
  62757. */
  62758. static readonly NoneLogLevel: number;
  62759. /**
  62760. * Only message logs
  62761. */
  62762. static readonly MessageLogLevel: number;
  62763. /**
  62764. * Only warning logs
  62765. */
  62766. static readonly WarningLogLevel: number;
  62767. /**
  62768. * Only error logs
  62769. */
  62770. static readonly ErrorLogLevel: number;
  62771. /**
  62772. * All logs
  62773. */
  62774. static readonly AllLogLevel: number;
  62775. private static _LogCache;
  62776. /**
  62777. * Gets a value indicating the number of loading errors
  62778. * @ignorenaming
  62779. */
  62780. static errorsCount: number;
  62781. /**
  62782. * Callback called when a new log is added
  62783. */
  62784. static OnNewCacheEntry: (entry: string) => void;
  62785. private static _AddLogEntry;
  62786. private static _FormatMessage;
  62787. private static _LogDisabled;
  62788. private static _LogEnabled;
  62789. private static _WarnDisabled;
  62790. private static _WarnEnabled;
  62791. private static _ErrorDisabled;
  62792. private static _ErrorEnabled;
  62793. /**
  62794. * Log a message to the console
  62795. */
  62796. static Log: (message: string) => void;
  62797. /**
  62798. * Write a warning message to the console
  62799. */
  62800. static Warn: (message: string) => void;
  62801. /**
  62802. * Write an error message to the console
  62803. */
  62804. static Error: (message: string) => void;
  62805. /**
  62806. * Gets current log cache (list of logs)
  62807. */
  62808. static readonly LogCache: string;
  62809. /**
  62810. * Clears the log cache
  62811. */
  62812. static ClearLogCache(): void;
  62813. /**
  62814. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62815. */
  62816. static LogLevels: number;
  62817. }
  62818. }
  62819. declare module BABYLON {
  62820. /** @hidden */
  62821. export class _TypeStore {
  62822. /** @hidden */
  62823. static RegisteredTypes: {
  62824. [key: string]: Object;
  62825. };
  62826. /** @hidden */
  62827. static GetClass(fqdn: string): any;
  62828. }
  62829. }
  62830. declare module BABYLON {
  62831. /**
  62832. * Class containing a set of static utilities functions for deep copy.
  62833. */
  62834. export class DeepCopier {
  62835. /**
  62836. * Tries to copy an object by duplicating every property
  62837. * @param source defines the source object
  62838. * @param destination defines the target object
  62839. * @param doNotCopyList defines a list of properties to avoid
  62840. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62841. */
  62842. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62843. }
  62844. }
  62845. declare module BABYLON {
  62846. /**
  62847. * Class containing a set of static utilities functions for precision date
  62848. */
  62849. export class PrecisionDate {
  62850. /**
  62851. * Gets either window.performance.now() if supported or Date.now() else
  62852. */
  62853. static readonly Now: number;
  62854. }
  62855. }
  62856. declare module BABYLON {
  62857. /** @hidden */
  62858. export class _DevTools {
  62859. static WarnImport(name: string): string;
  62860. }
  62861. }
  62862. declare module BABYLON {
  62863. /**
  62864. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  62865. */
  62866. export class WebRequest {
  62867. private _xhr;
  62868. /**
  62869. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  62870. * i.e. when loading files, where the server/service expects an Authorization header
  62871. */
  62872. static CustomRequestHeaders: {
  62873. [key: string]: string;
  62874. };
  62875. /**
  62876. * Add callback functions in this array to update all the requests before they get sent to the network
  62877. */
  62878. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  62879. private _injectCustomRequestHeaders;
  62880. /**
  62881. * Gets or sets a function to be called when loading progress changes
  62882. */
  62883. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  62884. /**
  62885. * Returns client's state
  62886. */
  62887. readonly readyState: number;
  62888. /**
  62889. * Returns client's status
  62890. */
  62891. readonly status: number;
  62892. /**
  62893. * Returns client's status as a text
  62894. */
  62895. readonly statusText: string;
  62896. /**
  62897. * Returns client's response
  62898. */
  62899. readonly response: any;
  62900. /**
  62901. * Returns client's response url
  62902. */
  62903. readonly responseURL: string;
  62904. /**
  62905. * Returns client's response as text
  62906. */
  62907. readonly responseText: string;
  62908. /**
  62909. * Gets or sets the expected response type
  62910. */
  62911. responseType: XMLHttpRequestResponseType;
  62912. /** @hidden */
  62913. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  62914. /** @hidden */
  62915. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  62916. /**
  62917. * Cancels any network activity
  62918. */
  62919. abort(): void;
  62920. /**
  62921. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  62922. * @param body defines an optional request body
  62923. */
  62924. send(body?: Document | BodyInit | null): void;
  62925. /**
  62926. * Sets the request method, request URL
  62927. * @param method defines the method to use (GET, POST, etc..)
  62928. * @param url defines the url to connect with
  62929. */
  62930. open(method: string, url: string): void;
  62931. }
  62932. }
  62933. declare module BABYLON {
  62934. /**
  62935. * Class used to evalaute queries containing `and` and `or` operators
  62936. */
  62937. export class AndOrNotEvaluator {
  62938. /**
  62939. * Evaluate a query
  62940. * @param query defines the query to evaluate
  62941. * @param evaluateCallback defines the callback used to filter result
  62942. * @returns true if the query matches
  62943. */
  62944. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62945. private static _HandleParenthesisContent;
  62946. private static _SimplifyNegation;
  62947. }
  62948. }
  62949. declare module BABYLON {
  62950. /**
  62951. * Class used to store custom tags
  62952. */
  62953. export class Tags {
  62954. /**
  62955. * Adds support for tags on the given object
  62956. * @param obj defines the object to use
  62957. */
  62958. static EnableFor(obj: any): void;
  62959. /**
  62960. * Removes tags support
  62961. * @param obj defines the object to use
  62962. */
  62963. static DisableFor(obj: any): void;
  62964. /**
  62965. * Gets a boolean indicating if the given object has tags
  62966. * @param obj defines the object to use
  62967. * @returns a boolean
  62968. */
  62969. static HasTags(obj: any): boolean;
  62970. /**
  62971. * Gets the tags available on a given object
  62972. * @param obj defines the object to use
  62973. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62974. * @returns the tags
  62975. */
  62976. static GetTags(obj: any, asString?: boolean): any;
  62977. /**
  62978. * Adds tags to an object
  62979. * @param obj defines the object to use
  62980. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62981. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62982. */
  62983. static AddTagsTo(obj: any, tagsString: string): void;
  62984. /**
  62985. * @hidden
  62986. */
  62987. static _AddTagTo(obj: any, tag: string): void;
  62988. /**
  62989. * Removes specific tags from a specific object
  62990. * @param obj defines the object to use
  62991. * @param tagsString defines the tags to remove
  62992. */
  62993. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62994. /**
  62995. * @hidden
  62996. */
  62997. static _RemoveTagFrom(obj: any, tag: string): void;
  62998. /**
  62999. * Defines if tags hosted on an object match a given query
  63000. * @param obj defines the object to use
  63001. * @param tagsQuery defines the tag query
  63002. * @returns a boolean
  63003. */
  63004. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63005. }
  63006. }
  63007. declare module BABYLON {
  63008. /**
  63009. * Manages the defines for the Material
  63010. */
  63011. export class MaterialDefines {
  63012. private _keys;
  63013. private _isDirty;
  63014. /** @hidden */
  63015. _renderId: number;
  63016. /** @hidden */
  63017. _areLightsDirty: boolean;
  63018. /** @hidden */
  63019. _areAttributesDirty: boolean;
  63020. /** @hidden */
  63021. _areTexturesDirty: boolean;
  63022. /** @hidden */
  63023. _areFresnelDirty: boolean;
  63024. /** @hidden */
  63025. _areMiscDirty: boolean;
  63026. /** @hidden */
  63027. _areImageProcessingDirty: boolean;
  63028. /** @hidden */
  63029. _normals: boolean;
  63030. /** @hidden */
  63031. _uvs: boolean;
  63032. /** @hidden */
  63033. _needNormals: boolean;
  63034. /** @hidden */
  63035. _needUVs: boolean;
  63036. /**
  63037. * Specifies if the material needs to be re-calculated
  63038. */
  63039. readonly isDirty: boolean;
  63040. /**
  63041. * Marks the material to indicate that it has been re-calculated
  63042. */
  63043. markAsProcessed(): void;
  63044. /**
  63045. * Marks the material to indicate that it needs to be re-calculated
  63046. */
  63047. markAsUnprocessed(): void;
  63048. /**
  63049. * Marks the material to indicate all of its defines need to be re-calculated
  63050. */
  63051. markAllAsDirty(): void;
  63052. /**
  63053. * Marks the material to indicate that image processing needs to be re-calculated
  63054. */
  63055. markAsImageProcessingDirty(): void;
  63056. /**
  63057. * Marks the material to indicate the lights need to be re-calculated
  63058. */
  63059. markAsLightDirty(): void;
  63060. /**
  63061. * Marks the attribute state as changed
  63062. */
  63063. markAsAttributesDirty(): void;
  63064. /**
  63065. * Marks the texture state as changed
  63066. */
  63067. markAsTexturesDirty(): void;
  63068. /**
  63069. * Marks the fresnel state as changed
  63070. */
  63071. markAsFresnelDirty(): void;
  63072. /**
  63073. * Marks the misc state as changed
  63074. */
  63075. markAsMiscDirty(): void;
  63076. /**
  63077. * Rebuilds the material defines
  63078. */
  63079. rebuild(): void;
  63080. /**
  63081. * Specifies if two material defines are equal
  63082. * @param other - A material define instance to compare to
  63083. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63084. */
  63085. isEqual(other: MaterialDefines): boolean;
  63086. /**
  63087. * Clones this instance's defines to another instance
  63088. * @param other - material defines to clone values to
  63089. */
  63090. cloneTo(other: MaterialDefines): void;
  63091. /**
  63092. * Resets the material define values
  63093. */
  63094. reset(): void;
  63095. /**
  63096. * Converts the material define values to a string
  63097. * @returns - String of material define information
  63098. */
  63099. toString(): string;
  63100. }
  63101. }
  63102. declare module BABYLON {
  63103. /**
  63104. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63105. */
  63106. export class PerformanceMonitor {
  63107. private _enabled;
  63108. private _rollingFrameTime;
  63109. private _lastFrameTimeMs;
  63110. /**
  63111. * constructor
  63112. * @param frameSampleSize The number of samples required to saturate the sliding window
  63113. */
  63114. constructor(frameSampleSize?: number);
  63115. /**
  63116. * Samples current frame
  63117. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63118. */
  63119. sampleFrame(timeMs?: number): void;
  63120. /**
  63121. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63122. */
  63123. readonly averageFrameTime: number;
  63124. /**
  63125. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63126. */
  63127. readonly averageFrameTimeVariance: number;
  63128. /**
  63129. * Returns the frame time of the most recent frame
  63130. */
  63131. readonly instantaneousFrameTime: number;
  63132. /**
  63133. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63134. */
  63135. readonly averageFPS: number;
  63136. /**
  63137. * Returns the average framerate in frames per second using the most recent frame time
  63138. */
  63139. readonly instantaneousFPS: number;
  63140. /**
  63141. * Returns true if enough samples have been taken to completely fill the sliding window
  63142. */
  63143. readonly isSaturated: boolean;
  63144. /**
  63145. * Enables contributions to the sliding window sample set
  63146. */
  63147. enable(): void;
  63148. /**
  63149. * Disables contributions to the sliding window sample set
  63150. * Samples will not be interpolated over the disabled period
  63151. */
  63152. disable(): void;
  63153. /**
  63154. * Returns true if sampling is enabled
  63155. */
  63156. readonly isEnabled: boolean;
  63157. /**
  63158. * Resets performance monitor
  63159. */
  63160. reset(): void;
  63161. }
  63162. /**
  63163. * RollingAverage
  63164. *
  63165. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63166. */
  63167. export class RollingAverage {
  63168. /**
  63169. * Current average
  63170. */
  63171. average: number;
  63172. /**
  63173. * Current variance
  63174. */
  63175. variance: number;
  63176. protected _samples: Array<number>;
  63177. protected _sampleCount: number;
  63178. protected _pos: number;
  63179. protected _m2: number;
  63180. /**
  63181. * constructor
  63182. * @param length The number of samples required to saturate the sliding window
  63183. */
  63184. constructor(length: number);
  63185. /**
  63186. * Adds a sample to the sample set
  63187. * @param v The sample value
  63188. */
  63189. add(v: number): void;
  63190. /**
  63191. * Returns previously added values or null if outside of history or outside the sliding window domain
  63192. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63193. * @return Value previously recorded with add() or null if outside of range
  63194. */
  63195. history(i: number): number;
  63196. /**
  63197. * Returns true if enough samples have been taken to completely fill the sliding window
  63198. * @return true if sample-set saturated
  63199. */
  63200. isSaturated(): boolean;
  63201. /**
  63202. * Resets the rolling average (equivalent to 0 samples taken so far)
  63203. */
  63204. reset(): void;
  63205. /**
  63206. * Wraps a value around the sample range boundaries
  63207. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63208. * @return Wrapped position in sample range
  63209. */
  63210. protected _wrapPosition(i: number): number;
  63211. }
  63212. }
  63213. declare module BABYLON {
  63214. /**
  63215. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63216. * The underlying implementation relies on an associative array to ensure the best performances.
  63217. * The value can be anything including 'null' but except 'undefined'
  63218. */
  63219. export class StringDictionary<T> {
  63220. /**
  63221. * This will clear this dictionary and copy the content from the 'source' one.
  63222. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63223. * @param source the dictionary to take the content from and copy to this dictionary
  63224. */
  63225. copyFrom(source: StringDictionary<T>): void;
  63226. /**
  63227. * Get a value based from its key
  63228. * @param key the given key to get the matching value from
  63229. * @return the value if found, otherwise undefined is returned
  63230. */
  63231. get(key: string): T | undefined;
  63232. /**
  63233. * Get a value from its key or add it if it doesn't exist.
  63234. * This method will ensure you that a given key/data will be present in the dictionary.
  63235. * @param key the given key to get the matching value from
  63236. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63237. * The factory will only be invoked if there's no data for the given key.
  63238. * @return the value corresponding to the key.
  63239. */
  63240. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63241. /**
  63242. * Get a value from its key if present in the dictionary otherwise add it
  63243. * @param key the key to get the value from
  63244. * @param val if there's no such key/value pair in the dictionary add it with this value
  63245. * @return the value corresponding to the key
  63246. */
  63247. getOrAdd(key: string, val: T): T;
  63248. /**
  63249. * Check if there's a given key in the dictionary
  63250. * @param key the key to check for
  63251. * @return true if the key is present, false otherwise
  63252. */
  63253. contains(key: string): boolean;
  63254. /**
  63255. * Add a new key and its corresponding value
  63256. * @param key the key to add
  63257. * @param value the value corresponding to the key
  63258. * @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
  63259. */
  63260. add(key: string, value: T): boolean;
  63261. /**
  63262. * Update a specific value associated to a key
  63263. * @param key defines the key to use
  63264. * @param value defines the value to store
  63265. * @returns true if the value was updated (or false if the key was not found)
  63266. */
  63267. set(key: string, value: T): boolean;
  63268. /**
  63269. * Get the element of the given key and remove it from the dictionary
  63270. * @param key defines the key to search
  63271. * @returns the value associated with the key or null if not found
  63272. */
  63273. getAndRemove(key: string): Nullable<T>;
  63274. /**
  63275. * Remove a key/value from the dictionary.
  63276. * @param key the key to remove
  63277. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63278. */
  63279. remove(key: string): boolean;
  63280. /**
  63281. * Clear the whole content of the dictionary
  63282. */
  63283. clear(): void;
  63284. /**
  63285. * Gets the current count
  63286. */
  63287. readonly count: number;
  63288. /**
  63289. * Execute a callback on each key/val of the dictionary.
  63290. * Note that you can remove any element in this dictionary in the callback implementation
  63291. * @param callback the callback to execute on a given key/value pair
  63292. */
  63293. forEach(callback: (key: string, val: T) => void): void;
  63294. /**
  63295. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63296. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63297. * Note that you can remove any element in this dictionary in the callback implementation
  63298. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63299. * @returns the first item
  63300. */
  63301. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63302. private _count;
  63303. private _data;
  63304. }
  63305. }
  63306. declare module BABYLON {
  63307. /**
  63308. * Helper class that provides a small promise polyfill
  63309. */
  63310. export class PromisePolyfill {
  63311. /**
  63312. * Static function used to check if the polyfill is required
  63313. * If this is the case then the function will inject the polyfill to window.Promise
  63314. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63315. */
  63316. static Apply(force?: boolean): void;
  63317. }
  63318. }
  63319. declare module BABYLON {
  63320. /**
  63321. * Class used to store data that will be store in GPU memory
  63322. */
  63323. export class Buffer {
  63324. private _engine;
  63325. private _buffer;
  63326. /** @hidden */
  63327. _data: Nullable<DataArray>;
  63328. private _updatable;
  63329. private _instanced;
  63330. /**
  63331. * Gets the byte stride.
  63332. */
  63333. readonly byteStride: number;
  63334. /**
  63335. * Constructor
  63336. * @param engine the engine
  63337. * @param data the data to use for this buffer
  63338. * @param updatable whether the data is updatable
  63339. * @param stride the stride (optional)
  63340. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63341. * @param instanced whether the buffer is instanced (optional)
  63342. * @param useBytes set to true if the stride in in bytes (optional)
  63343. */
  63344. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63345. /**
  63346. * Create a new VertexBuffer based on the current buffer
  63347. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63348. * @param offset defines offset in the buffer (0 by default)
  63349. * @param size defines the size in floats of attributes (position is 3 for instance)
  63350. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63351. * @param instanced defines if the vertex buffer contains indexed data
  63352. * @param useBytes defines if the offset and stride are in bytes
  63353. * @returns the new vertex buffer
  63354. */
  63355. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63356. /**
  63357. * Gets a boolean indicating if the Buffer is updatable?
  63358. * @returns true if the buffer is updatable
  63359. */
  63360. isUpdatable(): boolean;
  63361. /**
  63362. * Gets current buffer's data
  63363. * @returns a DataArray or null
  63364. */
  63365. getData(): Nullable<DataArray>;
  63366. /**
  63367. * Gets underlying native buffer
  63368. * @returns underlying native buffer
  63369. */
  63370. getBuffer(): Nullable<WebGLBuffer>;
  63371. /**
  63372. * Gets the stride in float32 units (i.e. byte stride / 4).
  63373. * May not be an integer if the byte stride is not divisible by 4.
  63374. * DEPRECATED. Use byteStride instead.
  63375. * @returns the stride in float32 units
  63376. */
  63377. getStrideSize(): number;
  63378. /**
  63379. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63380. * @param data defines the data to store
  63381. */
  63382. create(data?: Nullable<DataArray>): void;
  63383. /** @hidden */
  63384. _rebuild(): void;
  63385. /**
  63386. * Update current buffer data
  63387. * @param data defines the data to store
  63388. */
  63389. update(data: DataArray): void;
  63390. /**
  63391. * Updates the data directly.
  63392. * @param data the new data
  63393. * @param offset the new offset
  63394. * @param vertexCount the vertex count (optional)
  63395. * @param useBytes set to true if the offset is in bytes
  63396. */
  63397. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63398. /**
  63399. * Release all resources
  63400. */
  63401. dispose(): void;
  63402. }
  63403. /**
  63404. * Specialized buffer used to store vertex data
  63405. */
  63406. export class VertexBuffer {
  63407. /** @hidden */
  63408. _buffer: Buffer;
  63409. private _kind;
  63410. private _size;
  63411. private _ownsBuffer;
  63412. private _instanced;
  63413. private _instanceDivisor;
  63414. /**
  63415. * The byte type.
  63416. */
  63417. static readonly BYTE: number;
  63418. /**
  63419. * The unsigned byte type.
  63420. */
  63421. static readonly UNSIGNED_BYTE: number;
  63422. /**
  63423. * The short type.
  63424. */
  63425. static readonly SHORT: number;
  63426. /**
  63427. * The unsigned short type.
  63428. */
  63429. static readonly UNSIGNED_SHORT: number;
  63430. /**
  63431. * The integer type.
  63432. */
  63433. static readonly INT: number;
  63434. /**
  63435. * The unsigned integer type.
  63436. */
  63437. static readonly UNSIGNED_INT: number;
  63438. /**
  63439. * The float type.
  63440. */
  63441. static readonly FLOAT: number;
  63442. /**
  63443. * Gets or sets the instance divisor when in instanced mode
  63444. */
  63445. instanceDivisor: number;
  63446. /**
  63447. * Gets the byte stride.
  63448. */
  63449. readonly byteStride: number;
  63450. /**
  63451. * Gets the byte offset.
  63452. */
  63453. readonly byteOffset: number;
  63454. /**
  63455. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63456. */
  63457. readonly normalized: boolean;
  63458. /**
  63459. * Gets the data type of each component in the array.
  63460. */
  63461. readonly type: number;
  63462. /**
  63463. * Constructor
  63464. * @param engine the engine
  63465. * @param data the data to use for this vertex buffer
  63466. * @param kind the vertex buffer kind
  63467. * @param updatable whether the data is updatable
  63468. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63469. * @param stride the stride (optional)
  63470. * @param instanced whether the buffer is instanced (optional)
  63471. * @param offset the offset of the data (optional)
  63472. * @param size the number of components (optional)
  63473. * @param type the type of the component (optional)
  63474. * @param normalized whether the data contains normalized data (optional)
  63475. * @param useBytes set to true if stride and offset are in bytes (optional)
  63476. */
  63477. 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);
  63478. /** @hidden */
  63479. _rebuild(): void;
  63480. /**
  63481. * Returns the kind of the VertexBuffer (string)
  63482. * @returns a string
  63483. */
  63484. getKind(): string;
  63485. /**
  63486. * Gets a boolean indicating if the VertexBuffer is updatable?
  63487. * @returns true if the buffer is updatable
  63488. */
  63489. isUpdatable(): boolean;
  63490. /**
  63491. * Gets current buffer's data
  63492. * @returns a DataArray or null
  63493. */
  63494. getData(): Nullable<DataArray>;
  63495. /**
  63496. * Gets underlying native buffer
  63497. * @returns underlying native buffer
  63498. */
  63499. getBuffer(): Nullable<WebGLBuffer>;
  63500. /**
  63501. * Gets the stride in float32 units (i.e. byte stride / 4).
  63502. * May not be an integer if the byte stride is not divisible by 4.
  63503. * DEPRECATED. Use byteStride instead.
  63504. * @returns the stride in float32 units
  63505. */
  63506. getStrideSize(): number;
  63507. /**
  63508. * Returns the offset as a multiple of the type byte length.
  63509. * DEPRECATED. Use byteOffset instead.
  63510. * @returns the offset in bytes
  63511. */
  63512. getOffset(): number;
  63513. /**
  63514. * Returns the number of components per vertex attribute (integer)
  63515. * @returns the size in float
  63516. */
  63517. getSize(): number;
  63518. /**
  63519. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63520. * @returns true if this buffer is instanced
  63521. */
  63522. getIsInstanced(): boolean;
  63523. /**
  63524. * Returns the instancing divisor, zero for non-instanced (integer).
  63525. * @returns a number
  63526. */
  63527. getInstanceDivisor(): number;
  63528. /**
  63529. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63530. * @param data defines the data to store
  63531. */
  63532. create(data?: DataArray): void;
  63533. /**
  63534. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63535. * This function will create a new buffer if the current one is not updatable
  63536. * @param data defines the data to store
  63537. */
  63538. update(data: DataArray): void;
  63539. /**
  63540. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63541. * Returns the directly updated WebGLBuffer.
  63542. * @param data the new data
  63543. * @param offset the new offset
  63544. * @param useBytes set to true if the offset is in bytes
  63545. */
  63546. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63547. /**
  63548. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63549. */
  63550. dispose(): void;
  63551. /**
  63552. * Enumerates each value of this vertex buffer as numbers.
  63553. * @param count the number of values to enumerate
  63554. * @param callback the callback function called for each value
  63555. */
  63556. forEach(count: number, callback: (value: number, index: number) => void): void;
  63557. /**
  63558. * Positions
  63559. */
  63560. static readonly PositionKind: string;
  63561. /**
  63562. * Normals
  63563. */
  63564. static readonly NormalKind: string;
  63565. /**
  63566. * Tangents
  63567. */
  63568. static readonly TangentKind: string;
  63569. /**
  63570. * Texture coordinates
  63571. */
  63572. static readonly UVKind: string;
  63573. /**
  63574. * Texture coordinates 2
  63575. */
  63576. static readonly UV2Kind: string;
  63577. /**
  63578. * Texture coordinates 3
  63579. */
  63580. static readonly UV3Kind: string;
  63581. /**
  63582. * Texture coordinates 4
  63583. */
  63584. static readonly UV4Kind: string;
  63585. /**
  63586. * Texture coordinates 5
  63587. */
  63588. static readonly UV5Kind: string;
  63589. /**
  63590. * Texture coordinates 6
  63591. */
  63592. static readonly UV6Kind: string;
  63593. /**
  63594. * Colors
  63595. */
  63596. static readonly ColorKind: string;
  63597. /**
  63598. * Matrix indices (for bones)
  63599. */
  63600. static readonly MatricesIndicesKind: string;
  63601. /**
  63602. * Matrix weights (for bones)
  63603. */
  63604. static readonly MatricesWeightsKind: string;
  63605. /**
  63606. * Additional matrix indices (for bones)
  63607. */
  63608. static readonly MatricesIndicesExtraKind: string;
  63609. /**
  63610. * Additional matrix weights (for bones)
  63611. */
  63612. static readonly MatricesWeightsExtraKind: string;
  63613. /**
  63614. * Deduces the stride given a kind.
  63615. * @param kind The kind string to deduce
  63616. * @returns The deduced stride
  63617. */
  63618. static DeduceStride(kind: string): number;
  63619. /**
  63620. * Gets the byte length of the given type.
  63621. * @param type the type
  63622. * @returns the number of bytes
  63623. */
  63624. static GetTypeByteLength(type: number): number;
  63625. /**
  63626. * Enumerates each value of the given parameters as numbers.
  63627. * @param data the data to enumerate
  63628. * @param byteOffset the byte offset of the data
  63629. * @param byteStride the byte stride of the data
  63630. * @param componentCount the number of components per element
  63631. * @param componentType the type of the component
  63632. * @param count the total number of components
  63633. * @param normalized whether the data is normalized
  63634. * @param callback the callback function called for each value
  63635. */
  63636. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63637. private static _GetFloatValue;
  63638. }
  63639. }
  63640. declare module BABYLON {
  63641. /**
  63642. * Class representing spherical polynomial coefficients to the 3rd degree
  63643. */
  63644. export class SphericalPolynomial {
  63645. /**
  63646. * The x coefficients of the spherical polynomial
  63647. */
  63648. x: Vector3;
  63649. /**
  63650. * The y coefficients of the spherical polynomial
  63651. */
  63652. y: Vector3;
  63653. /**
  63654. * The z coefficients of the spherical polynomial
  63655. */
  63656. z: Vector3;
  63657. /**
  63658. * The xx coefficients of the spherical polynomial
  63659. */
  63660. xx: Vector3;
  63661. /**
  63662. * The yy coefficients of the spherical polynomial
  63663. */
  63664. yy: Vector3;
  63665. /**
  63666. * The zz coefficients of the spherical polynomial
  63667. */
  63668. zz: Vector3;
  63669. /**
  63670. * The xy coefficients of the spherical polynomial
  63671. */
  63672. xy: Vector3;
  63673. /**
  63674. * The yz coefficients of the spherical polynomial
  63675. */
  63676. yz: Vector3;
  63677. /**
  63678. * The zx coefficients of the spherical polynomial
  63679. */
  63680. zx: Vector3;
  63681. /**
  63682. * Adds an ambient color to the spherical polynomial
  63683. * @param color the color to add
  63684. */
  63685. addAmbient(color: Color3): void;
  63686. /**
  63687. * Scales the spherical polynomial by the given amount
  63688. * @param scale the amount to scale
  63689. */
  63690. scale(scale: number): void;
  63691. /**
  63692. * Gets the spherical polynomial from harmonics
  63693. * @param harmonics the spherical harmonics
  63694. * @returns the spherical polynomial
  63695. */
  63696. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63697. /**
  63698. * Constructs a spherical polynomial from an array.
  63699. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63700. * @returns the spherical polynomial
  63701. */
  63702. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63703. }
  63704. /**
  63705. * Class representing spherical harmonics coefficients to the 3rd degree
  63706. */
  63707. export class SphericalHarmonics {
  63708. /**
  63709. * The l0,0 coefficients of the spherical harmonics
  63710. */
  63711. l00: Vector3;
  63712. /**
  63713. * The l1,-1 coefficients of the spherical harmonics
  63714. */
  63715. l1_1: Vector3;
  63716. /**
  63717. * The l1,0 coefficients of the spherical harmonics
  63718. */
  63719. l10: Vector3;
  63720. /**
  63721. * The l1,1 coefficients of the spherical harmonics
  63722. */
  63723. l11: Vector3;
  63724. /**
  63725. * The l2,-2 coefficients of the spherical harmonics
  63726. */
  63727. l2_2: Vector3;
  63728. /**
  63729. * The l2,-1 coefficients of the spherical harmonics
  63730. */
  63731. l2_1: Vector3;
  63732. /**
  63733. * The l2,0 coefficients of the spherical harmonics
  63734. */
  63735. l20: Vector3;
  63736. /**
  63737. * The l2,1 coefficients of the spherical harmonics
  63738. */
  63739. l21: Vector3;
  63740. /**
  63741. * The l2,2 coefficients of the spherical harmonics
  63742. */
  63743. lL22: Vector3;
  63744. /**
  63745. * Adds a light to the spherical harmonics
  63746. * @param direction the direction of the light
  63747. * @param color the color of the light
  63748. * @param deltaSolidAngle the delta solid angle of the light
  63749. */
  63750. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63751. /**
  63752. * Scales the spherical harmonics by the given amount
  63753. * @param scale the amount to scale
  63754. */
  63755. scale(scale: number): void;
  63756. /**
  63757. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63758. *
  63759. * ```
  63760. * E_lm = A_l * L_lm
  63761. * ```
  63762. *
  63763. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63764. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63765. * the scaling factors are given in equation 9.
  63766. */
  63767. convertIncidentRadianceToIrradiance(): void;
  63768. /**
  63769. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63770. *
  63771. * ```
  63772. * L = (1/pi) * E * rho
  63773. * ```
  63774. *
  63775. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63776. */
  63777. convertIrradianceToLambertianRadiance(): void;
  63778. /**
  63779. * Gets the spherical harmonics from polynomial
  63780. * @param polynomial the spherical polynomial
  63781. * @returns the spherical harmonics
  63782. */
  63783. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63784. /**
  63785. * Constructs a spherical harmonics from an array.
  63786. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63787. * @returns the spherical harmonics
  63788. */
  63789. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63790. }
  63791. }
  63792. declare module BABYLON {
  63793. /**
  63794. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63795. */
  63796. export interface CubeMapInfo {
  63797. /**
  63798. * The pixel array for the front face.
  63799. * This is stored in format, left to right, up to down format.
  63800. */
  63801. front: Nullable<ArrayBufferView>;
  63802. /**
  63803. * The pixel array for the back face.
  63804. * This is stored in format, left to right, up to down format.
  63805. */
  63806. back: Nullable<ArrayBufferView>;
  63807. /**
  63808. * The pixel array for the left face.
  63809. * This is stored in format, left to right, up to down format.
  63810. */
  63811. left: Nullable<ArrayBufferView>;
  63812. /**
  63813. * The pixel array for the right face.
  63814. * This is stored in format, left to right, up to down format.
  63815. */
  63816. right: Nullable<ArrayBufferView>;
  63817. /**
  63818. * The pixel array for the up face.
  63819. * This is stored in format, left to right, up to down format.
  63820. */
  63821. up: Nullable<ArrayBufferView>;
  63822. /**
  63823. * The pixel array for the down face.
  63824. * This is stored in format, left to right, up to down format.
  63825. */
  63826. down: Nullable<ArrayBufferView>;
  63827. /**
  63828. * The size of the cubemap stored.
  63829. *
  63830. * Each faces will be size * size pixels.
  63831. */
  63832. size: number;
  63833. /**
  63834. * The format of the texture.
  63835. *
  63836. * RGBA, RGB.
  63837. */
  63838. format: number;
  63839. /**
  63840. * The type of the texture data.
  63841. *
  63842. * UNSIGNED_INT, FLOAT.
  63843. */
  63844. type: number;
  63845. /**
  63846. * Specifies whether the texture is in gamma space.
  63847. */
  63848. gammaSpace: boolean;
  63849. }
  63850. /**
  63851. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63852. */
  63853. export class PanoramaToCubeMapTools {
  63854. private static FACE_FRONT;
  63855. private static FACE_BACK;
  63856. private static FACE_RIGHT;
  63857. private static FACE_LEFT;
  63858. private static FACE_DOWN;
  63859. private static FACE_UP;
  63860. /**
  63861. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63862. *
  63863. * @param float32Array The source data.
  63864. * @param inputWidth The width of the input panorama.
  63865. * @param inputHeight The height of the input panorama.
  63866. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63867. * @return The cubemap data
  63868. */
  63869. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63870. private static CreateCubemapTexture;
  63871. private static CalcProjectionSpherical;
  63872. }
  63873. }
  63874. declare module BABYLON {
  63875. /**
  63876. * Helper class dealing with the extraction of spherical polynomial dataArray
  63877. * from a cube map.
  63878. */
  63879. export class CubeMapToSphericalPolynomialTools {
  63880. private static FileFaces;
  63881. /**
  63882. * Converts a texture to the according Spherical Polynomial data.
  63883. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63884. *
  63885. * @param texture The texture to extract the information from.
  63886. * @return The Spherical Polynomial data.
  63887. */
  63888. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63889. /**
  63890. * Converts a cubemap to the according Spherical Polynomial data.
  63891. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63892. *
  63893. * @param cubeInfo The Cube map to extract the information from.
  63894. * @return The Spherical Polynomial data.
  63895. */
  63896. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63897. }
  63898. }
  63899. declare module BABYLON {
  63900. /**
  63901. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63902. * during the life time of the application.
  63903. */
  63904. export class EngineStore {
  63905. /** Gets the list of created engines */
  63906. static Instances: Engine[];
  63907. /**
  63908. * Gets the latest created engine
  63909. */
  63910. static readonly LastCreatedEngine: Nullable<Engine>;
  63911. /**
  63912. * Gets the latest created scene
  63913. */
  63914. static readonly LastCreatedScene: Nullable<Scene>;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /**
  63919. * Define options used to create a render target texture
  63920. */
  63921. export class RenderTargetCreationOptions {
  63922. /**
  63923. * Specifies is mipmaps must be generated
  63924. */
  63925. generateMipMaps?: boolean;
  63926. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63927. generateDepthBuffer?: boolean;
  63928. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63929. generateStencilBuffer?: boolean;
  63930. /** Defines texture type (int by default) */
  63931. type?: number;
  63932. /** Defines sampling mode (trilinear by default) */
  63933. samplingMode?: number;
  63934. /** Defines format (RGBA by default) */
  63935. format?: number;
  63936. }
  63937. }
  63938. declare module BABYLON {
  63939. /**
  63940. * @hidden
  63941. **/
  63942. export class _AlphaState {
  63943. private _isAlphaBlendDirty;
  63944. private _isBlendFunctionParametersDirty;
  63945. private _isBlendEquationParametersDirty;
  63946. private _isBlendConstantsDirty;
  63947. private _alphaBlend;
  63948. private _blendFunctionParameters;
  63949. private _blendEquationParameters;
  63950. private _blendConstants;
  63951. /**
  63952. * Initializes the state.
  63953. */
  63954. constructor();
  63955. readonly isDirty: boolean;
  63956. alphaBlend: boolean;
  63957. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63958. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63959. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63960. reset(): void;
  63961. apply(gl: WebGLRenderingContext): void;
  63962. }
  63963. }
  63964. declare module BABYLON {
  63965. /**
  63966. * @hidden
  63967. **/
  63968. export class _DepthCullingState {
  63969. private _isDepthTestDirty;
  63970. private _isDepthMaskDirty;
  63971. private _isDepthFuncDirty;
  63972. private _isCullFaceDirty;
  63973. private _isCullDirty;
  63974. private _isZOffsetDirty;
  63975. private _isFrontFaceDirty;
  63976. private _depthTest;
  63977. private _depthMask;
  63978. private _depthFunc;
  63979. private _cull;
  63980. private _cullFace;
  63981. private _zOffset;
  63982. private _frontFace;
  63983. /**
  63984. * Initializes the state.
  63985. */
  63986. constructor();
  63987. readonly isDirty: boolean;
  63988. zOffset: number;
  63989. cullFace: Nullable<number>;
  63990. cull: Nullable<boolean>;
  63991. depthFunc: Nullable<number>;
  63992. depthMask: boolean;
  63993. depthTest: boolean;
  63994. frontFace: Nullable<number>;
  63995. reset(): void;
  63996. apply(gl: WebGLRenderingContext): void;
  63997. }
  63998. }
  63999. declare module BABYLON {
  64000. /**
  64001. * @hidden
  64002. **/
  64003. export class _StencilState {
  64004. /** 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 */
  64005. static readonly ALWAYS: number;
  64006. /** Passed to stencilOperation to specify that stencil value must be kept */
  64007. static readonly KEEP: number;
  64008. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64009. static readonly REPLACE: number;
  64010. private _isStencilTestDirty;
  64011. private _isStencilMaskDirty;
  64012. private _isStencilFuncDirty;
  64013. private _isStencilOpDirty;
  64014. private _stencilTest;
  64015. private _stencilMask;
  64016. private _stencilFunc;
  64017. private _stencilFuncRef;
  64018. private _stencilFuncMask;
  64019. private _stencilOpStencilFail;
  64020. private _stencilOpDepthFail;
  64021. private _stencilOpStencilDepthPass;
  64022. readonly isDirty: boolean;
  64023. stencilFunc: number;
  64024. stencilFuncRef: number;
  64025. stencilFuncMask: number;
  64026. stencilOpStencilFail: number;
  64027. stencilOpDepthFail: number;
  64028. stencilOpStencilDepthPass: number;
  64029. stencilMask: number;
  64030. stencilTest: boolean;
  64031. constructor();
  64032. reset(): void;
  64033. apply(gl: WebGLRenderingContext): void;
  64034. }
  64035. }
  64036. declare module BABYLON {
  64037. /**
  64038. * @hidden
  64039. **/
  64040. export class _TimeToken {
  64041. _startTimeQuery: Nullable<WebGLQuery>;
  64042. _endTimeQuery: Nullable<WebGLQuery>;
  64043. _timeElapsedQuery: Nullable<WebGLQuery>;
  64044. _timeElapsedQueryEnded: boolean;
  64045. }
  64046. }
  64047. declare module BABYLON {
  64048. /**
  64049. * Internal interface used to track InternalTexture already bound to the GL context
  64050. */
  64051. export interface IInternalTextureTracker {
  64052. /**
  64053. * Gets or set the previous tracker in the list
  64054. */
  64055. previous: Nullable<IInternalTextureTracker>;
  64056. /**
  64057. * Gets or set the next tracker in the list
  64058. */
  64059. next: Nullable<IInternalTextureTracker>;
  64060. }
  64061. /**
  64062. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64063. */
  64064. export class DummyInternalTextureTracker {
  64065. /**
  64066. * Gets or set the previous tracker in the list
  64067. */
  64068. previous: Nullable<IInternalTextureTracker>;
  64069. /**
  64070. * Gets or set the next tracker in the list
  64071. */
  64072. next: Nullable<IInternalTextureTracker>;
  64073. }
  64074. }
  64075. declare module BABYLON {
  64076. /**
  64077. * Class used to store data associated with WebGL texture data for the engine
  64078. * This class should not be used directly
  64079. */
  64080. export class InternalTexture implements IInternalTextureTracker {
  64081. /** hidden */
  64082. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64083. /**
  64084. * The source of the texture data is unknown
  64085. */
  64086. static DATASOURCE_UNKNOWN: number;
  64087. /**
  64088. * Texture data comes from an URL
  64089. */
  64090. static DATASOURCE_URL: number;
  64091. /**
  64092. * Texture data is only used for temporary storage
  64093. */
  64094. static DATASOURCE_TEMP: number;
  64095. /**
  64096. * Texture data comes from raw data (ArrayBuffer)
  64097. */
  64098. static DATASOURCE_RAW: number;
  64099. /**
  64100. * Texture content is dynamic (video or dynamic texture)
  64101. */
  64102. static DATASOURCE_DYNAMIC: number;
  64103. /**
  64104. * Texture content is generated by rendering to it
  64105. */
  64106. static DATASOURCE_RENDERTARGET: number;
  64107. /**
  64108. * Texture content is part of a multi render target process
  64109. */
  64110. static DATASOURCE_MULTIRENDERTARGET: number;
  64111. /**
  64112. * Texture data comes from a cube data file
  64113. */
  64114. static DATASOURCE_CUBE: number;
  64115. /**
  64116. * Texture data comes from a raw cube data
  64117. */
  64118. static DATASOURCE_CUBERAW: number;
  64119. /**
  64120. * Texture data come from a prefiltered cube data file
  64121. */
  64122. static DATASOURCE_CUBEPREFILTERED: number;
  64123. /**
  64124. * Texture content is raw 3D data
  64125. */
  64126. static DATASOURCE_RAW3D: number;
  64127. /**
  64128. * Texture content is a depth texture
  64129. */
  64130. static DATASOURCE_DEPTHTEXTURE: number;
  64131. /**
  64132. * Texture data comes from a raw cube data encoded with RGBD
  64133. */
  64134. static DATASOURCE_CUBERAW_RGBD: number;
  64135. /**
  64136. * Defines if the texture is ready
  64137. */
  64138. isReady: boolean;
  64139. /**
  64140. * Defines if the texture is a cube texture
  64141. */
  64142. isCube: boolean;
  64143. /**
  64144. * Defines if the texture contains 3D data
  64145. */
  64146. is3D: boolean;
  64147. /**
  64148. * Gets the URL used to load this texture
  64149. */
  64150. url: string;
  64151. /**
  64152. * Gets the sampling mode of the texture
  64153. */
  64154. samplingMode: number;
  64155. /**
  64156. * Gets a boolean indicating if the texture needs mipmaps generation
  64157. */
  64158. generateMipMaps: boolean;
  64159. /**
  64160. * Gets the number of samples used by the texture (WebGL2+ only)
  64161. */
  64162. samples: number;
  64163. /**
  64164. * Gets the type of the texture (int, float...)
  64165. */
  64166. type: number;
  64167. /**
  64168. * Gets the format of the texture (RGB, RGBA...)
  64169. */
  64170. format: number;
  64171. /**
  64172. * Observable called when the texture is loaded
  64173. */
  64174. onLoadedObservable: Observable<InternalTexture>;
  64175. /**
  64176. * Gets the width of the texture
  64177. */
  64178. width: number;
  64179. /**
  64180. * Gets the height of the texture
  64181. */
  64182. height: number;
  64183. /**
  64184. * Gets the depth of the texture
  64185. */
  64186. depth: number;
  64187. /**
  64188. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64189. */
  64190. baseWidth: number;
  64191. /**
  64192. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64193. */
  64194. baseHeight: number;
  64195. /**
  64196. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64197. */
  64198. baseDepth: number;
  64199. /**
  64200. * Gets a boolean indicating if the texture is inverted on Y axis
  64201. */
  64202. invertY: boolean;
  64203. /**
  64204. * Gets or set the previous tracker in the list
  64205. */
  64206. previous: Nullable<IInternalTextureTracker>;
  64207. /**
  64208. * Gets or set the next tracker in the list
  64209. */
  64210. next: Nullable<IInternalTextureTracker>;
  64211. /** @hidden */
  64212. _invertVScale: boolean;
  64213. /** @hidden */
  64214. _initialSlot: number;
  64215. /** @hidden */
  64216. _designatedSlot: number;
  64217. /** @hidden */
  64218. _dataSource: number;
  64219. /** @hidden */
  64220. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64221. /** @hidden */
  64222. _bufferView: Nullable<ArrayBufferView>;
  64223. /** @hidden */
  64224. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64225. /** @hidden */
  64226. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64227. /** @hidden */
  64228. _size: number;
  64229. /** @hidden */
  64230. _extension: string;
  64231. /** @hidden */
  64232. _files: Nullable<string[]>;
  64233. /** @hidden */
  64234. _workingCanvas: HTMLCanvasElement;
  64235. /** @hidden */
  64236. _workingContext: CanvasRenderingContext2D;
  64237. /** @hidden */
  64238. _framebuffer: Nullable<WebGLFramebuffer>;
  64239. /** @hidden */
  64240. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64241. /** @hidden */
  64242. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64243. /** @hidden */
  64244. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64245. /** @hidden */
  64246. _attachments: Nullable<number[]>;
  64247. /** @hidden */
  64248. _cachedCoordinatesMode: Nullable<number>;
  64249. /** @hidden */
  64250. _cachedWrapU: Nullable<number>;
  64251. /** @hidden */
  64252. _cachedWrapV: Nullable<number>;
  64253. /** @hidden */
  64254. _cachedWrapR: Nullable<number>;
  64255. /** @hidden */
  64256. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64257. /** @hidden */
  64258. _isDisabled: boolean;
  64259. /** @hidden */
  64260. _compression: Nullable<string>;
  64261. /** @hidden */
  64262. _generateStencilBuffer: boolean;
  64263. /** @hidden */
  64264. _generateDepthBuffer: boolean;
  64265. /** @hidden */
  64266. _comparisonFunction: number;
  64267. /** @hidden */
  64268. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64269. /** @hidden */
  64270. _lodGenerationScale: number;
  64271. /** @hidden */
  64272. _lodGenerationOffset: number;
  64273. /** @hidden */
  64274. _lodTextureHigh: BaseTexture;
  64275. /** @hidden */
  64276. _lodTextureMid: BaseTexture;
  64277. /** @hidden */
  64278. _lodTextureLow: BaseTexture;
  64279. /** @hidden */
  64280. _isRGBD: boolean;
  64281. /** @hidden */
  64282. _webGLTexture: Nullable<WebGLTexture>;
  64283. /** @hidden */
  64284. _references: number;
  64285. private _engine;
  64286. /**
  64287. * Gets the Engine the texture belongs to.
  64288. * @returns The babylon engine
  64289. */
  64290. getEngine(): Engine;
  64291. /**
  64292. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64293. */
  64294. readonly dataSource: number;
  64295. /**
  64296. * Creates a new InternalTexture
  64297. * @param engine defines the engine to use
  64298. * @param dataSource defines the type of data that will be used
  64299. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64300. */
  64301. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64302. /**
  64303. * Increments the number of references (ie. the number of Texture that point to it)
  64304. */
  64305. incrementReferences(): void;
  64306. /**
  64307. * Change the size of the texture (not the size of the content)
  64308. * @param width defines the new width
  64309. * @param height defines the new height
  64310. * @param depth defines the new depth (1 by default)
  64311. */
  64312. updateSize(width: int, height: int, depth?: int): void;
  64313. /** @hidden */
  64314. _rebuild(): void;
  64315. /** @hidden */
  64316. _swapAndDie(target: InternalTexture): void;
  64317. /**
  64318. * Dispose the current allocated resources
  64319. */
  64320. dispose(): void;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * This represents the main contract an easing function should follow.
  64326. * Easing functions are used throughout the animation system.
  64327. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64328. */
  64329. export interface IEasingFunction {
  64330. /**
  64331. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64332. * of the easing function.
  64333. * The link below provides some of the most common examples of easing functions.
  64334. * @see https://easings.net/
  64335. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64336. * @returns the corresponding value on the curve defined by the easing function
  64337. */
  64338. ease(gradient: number): number;
  64339. }
  64340. /**
  64341. * Base class used for every default easing function.
  64342. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64343. */
  64344. export class EasingFunction implements IEasingFunction {
  64345. /**
  64346. * Interpolation follows the mathematical formula associated with the easing function.
  64347. */
  64348. static readonly EASINGMODE_EASEIN: number;
  64349. /**
  64350. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64351. */
  64352. static readonly EASINGMODE_EASEOUT: number;
  64353. /**
  64354. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64355. */
  64356. static readonly EASINGMODE_EASEINOUT: number;
  64357. private _easingMode;
  64358. /**
  64359. * Sets the easing mode of the current function.
  64360. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64361. */
  64362. setEasingMode(easingMode: number): void;
  64363. /**
  64364. * Gets the current easing mode.
  64365. * @returns the easing mode
  64366. */
  64367. getEasingMode(): number;
  64368. /**
  64369. * @hidden
  64370. */
  64371. easeInCore(gradient: number): number;
  64372. /**
  64373. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64374. * of the easing function.
  64375. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64376. * @returns the corresponding value on the curve defined by the easing function
  64377. */
  64378. ease(gradient: number): number;
  64379. }
  64380. /**
  64381. * Easing function with a circle shape (see link below).
  64382. * @see https://easings.net/#easeInCirc
  64383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64384. */
  64385. export class CircleEase extends EasingFunction implements IEasingFunction {
  64386. /** @hidden */
  64387. easeInCore(gradient: number): number;
  64388. }
  64389. /**
  64390. * Easing function with a ease back shape (see link below).
  64391. * @see https://easings.net/#easeInBack
  64392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64393. */
  64394. export class BackEase extends EasingFunction implements IEasingFunction {
  64395. /** Defines the amplitude of the function */
  64396. amplitude: number;
  64397. /**
  64398. * Instantiates a back ease easing
  64399. * @see https://easings.net/#easeInBack
  64400. * @param amplitude Defines the amplitude of the function
  64401. */
  64402. constructor(
  64403. /** Defines the amplitude of the function */
  64404. amplitude?: number);
  64405. /** @hidden */
  64406. easeInCore(gradient: number): number;
  64407. }
  64408. /**
  64409. * Easing function with a bouncing shape (see link below).
  64410. * @see https://easings.net/#easeInBounce
  64411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64412. */
  64413. export class BounceEase extends EasingFunction implements IEasingFunction {
  64414. /** Defines the number of bounces */
  64415. bounces: number;
  64416. /** Defines the amplitude of the bounce */
  64417. bounciness: number;
  64418. /**
  64419. * Instantiates a bounce easing
  64420. * @see https://easings.net/#easeInBounce
  64421. * @param bounces Defines the number of bounces
  64422. * @param bounciness Defines the amplitude of the bounce
  64423. */
  64424. constructor(
  64425. /** Defines the number of bounces */
  64426. bounces?: number,
  64427. /** Defines the amplitude of the bounce */
  64428. bounciness?: number);
  64429. /** @hidden */
  64430. easeInCore(gradient: number): number;
  64431. }
  64432. /**
  64433. * Easing function with a power of 3 shape (see link below).
  64434. * @see https://easings.net/#easeInCubic
  64435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64436. */
  64437. export class CubicEase extends EasingFunction implements IEasingFunction {
  64438. /** @hidden */
  64439. easeInCore(gradient: number): number;
  64440. }
  64441. /**
  64442. * Easing function with an elastic shape (see link below).
  64443. * @see https://easings.net/#easeInElastic
  64444. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64445. */
  64446. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64447. /** Defines the number of oscillations*/
  64448. oscillations: number;
  64449. /** Defines the amplitude of the oscillations*/
  64450. springiness: number;
  64451. /**
  64452. * Instantiates an elastic easing function
  64453. * @see https://easings.net/#easeInElastic
  64454. * @param oscillations Defines the number of oscillations
  64455. * @param springiness Defines the amplitude of the oscillations
  64456. */
  64457. constructor(
  64458. /** Defines the number of oscillations*/
  64459. oscillations?: number,
  64460. /** Defines the amplitude of the oscillations*/
  64461. springiness?: number);
  64462. /** @hidden */
  64463. easeInCore(gradient: number): number;
  64464. }
  64465. /**
  64466. * Easing function with an exponential shape (see link below).
  64467. * @see https://easings.net/#easeInExpo
  64468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64469. */
  64470. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64471. /** Defines the exponent of the function */
  64472. exponent: number;
  64473. /**
  64474. * Instantiates an exponential easing function
  64475. * @see https://easings.net/#easeInExpo
  64476. * @param exponent Defines the exponent of the function
  64477. */
  64478. constructor(
  64479. /** Defines the exponent of the function */
  64480. exponent?: number);
  64481. /** @hidden */
  64482. easeInCore(gradient: number): number;
  64483. }
  64484. /**
  64485. * Easing function with a power shape (see link below).
  64486. * @see https://easings.net/#easeInQuad
  64487. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64488. */
  64489. export class PowerEase extends EasingFunction implements IEasingFunction {
  64490. /** Defines the power of the function */
  64491. power: number;
  64492. /**
  64493. * Instantiates an power base easing function
  64494. * @see https://easings.net/#easeInQuad
  64495. * @param power Defines the power of the function
  64496. */
  64497. constructor(
  64498. /** Defines the power of the function */
  64499. power?: number);
  64500. /** @hidden */
  64501. easeInCore(gradient: number): number;
  64502. }
  64503. /**
  64504. * Easing function with a power of 2 shape (see link below).
  64505. * @see https://easings.net/#easeInQuad
  64506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64507. */
  64508. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64509. /** @hidden */
  64510. easeInCore(gradient: number): number;
  64511. }
  64512. /**
  64513. * Easing function with a power of 4 shape (see link below).
  64514. * @see https://easings.net/#easeInQuart
  64515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64516. */
  64517. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64518. /** @hidden */
  64519. easeInCore(gradient: number): number;
  64520. }
  64521. /**
  64522. * Easing function with a power of 5 shape (see link below).
  64523. * @see https://easings.net/#easeInQuint
  64524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64525. */
  64526. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64527. /** @hidden */
  64528. easeInCore(gradient: number): number;
  64529. }
  64530. /**
  64531. * Easing function with a sin shape (see link below).
  64532. * @see https://easings.net/#easeInSine
  64533. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64534. */
  64535. export class SineEase extends EasingFunction implements IEasingFunction {
  64536. /** @hidden */
  64537. easeInCore(gradient: number): number;
  64538. }
  64539. /**
  64540. * Easing function with a bezier shape (see link below).
  64541. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64542. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64543. */
  64544. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64545. /** Defines the x component of the start tangent in the bezier curve */
  64546. x1: number;
  64547. /** Defines the y component of the start tangent in the bezier curve */
  64548. y1: number;
  64549. /** Defines the x component of the end tangent in the bezier curve */
  64550. x2: number;
  64551. /** Defines the y component of the end tangent in the bezier curve */
  64552. y2: number;
  64553. /**
  64554. * Instantiates a bezier function
  64555. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64556. * @param x1 Defines the x component of the start tangent in the bezier curve
  64557. * @param y1 Defines the y component of the start tangent in the bezier curve
  64558. * @param x2 Defines the x component of the end tangent in the bezier curve
  64559. * @param y2 Defines the y component of the end tangent in the bezier curve
  64560. */
  64561. constructor(
  64562. /** Defines the x component of the start tangent in the bezier curve */
  64563. x1?: number,
  64564. /** Defines the y component of the start tangent in the bezier curve */
  64565. y1?: number,
  64566. /** Defines the x component of the end tangent in the bezier curve */
  64567. x2?: number,
  64568. /** Defines the y component of the end tangent in the bezier curve */
  64569. y2?: number);
  64570. /** @hidden */
  64571. easeInCore(gradient: number): number;
  64572. }
  64573. }
  64574. declare module BABYLON {
  64575. /**
  64576. * Defines an interface which represents an animation key frame
  64577. */
  64578. export interface IAnimationKey {
  64579. /**
  64580. * Frame of the key frame
  64581. */
  64582. frame: number;
  64583. /**
  64584. * Value at the specifies key frame
  64585. */
  64586. value: any;
  64587. /**
  64588. * The input tangent for the cubic hermite spline
  64589. */
  64590. inTangent?: any;
  64591. /**
  64592. * The output tangent for the cubic hermite spline
  64593. */
  64594. outTangent?: any;
  64595. /**
  64596. * The animation interpolation type
  64597. */
  64598. interpolation?: AnimationKeyInterpolation;
  64599. }
  64600. /**
  64601. * Enum for the animation key frame interpolation type
  64602. */
  64603. export enum AnimationKeyInterpolation {
  64604. /**
  64605. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64606. */
  64607. STEP = 1
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /**
  64612. * Represents the range of an animation
  64613. */
  64614. export class AnimationRange {
  64615. /**The name of the animation range**/
  64616. name: string;
  64617. /**The starting frame of the animation */
  64618. from: number;
  64619. /**The ending frame of the animation*/
  64620. to: number;
  64621. /**
  64622. * Initializes the range of an animation
  64623. * @param name The name of the animation range
  64624. * @param from The starting frame of the animation
  64625. * @param to The ending frame of the animation
  64626. */
  64627. constructor(
  64628. /**The name of the animation range**/
  64629. name: string,
  64630. /**The starting frame of the animation */
  64631. from: number,
  64632. /**The ending frame of the animation*/
  64633. to: number);
  64634. /**
  64635. * Makes a copy of the animation range
  64636. * @returns A copy of the animation range
  64637. */
  64638. clone(): AnimationRange;
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * Composed of a frame, and an action function
  64644. */
  64645. export class AnimationEvent {
  64646. /** The frame for which the event is triggered **/
  64647. frame: number;
  64648. /** The event to perform when triggered **/
  64649. action: (currentFrame: number) => void;
  64650. /** Specifies if the event should be triggered only once**/
  64651. onlyOnce?: boolean | undefined;
  64652. /**
  64653. * Specifies if the animation event is done
  64654. */
  64655. isDone: boolean;
  64656. /**
  64657. * Initializes the animation event
  64658. * @param frame The frame for which the event is triggered
  64659. * @param action The event to perform when triggered
  64660. * @param onlyOnce Specifies if the event should be triggered only once
  64661. */
  64662. constructor(
  64663. /** The frame for which the event is triggered **/
  64664. frame: number,
  64665. /** The event to perform when triggered **/
  64666. action: (currentFrame: number) => void,
  64667. /** Specifies if the event should be triggered only once**/
  64668. onlyOnce?: boolean | undefined);
  64669. /** @hidden */
  64670. _clone(): AnimationEvent;
  64671. }
  64672. }
  64673. declare module BABYLON {
  64674. /**
  64675. * Interface used to define a behavior
  64676. */
  64677. export interface Behavior<T> {
  64678. /** gets or sets behavior's name */
  64679. name: string;
  64680. /**
  64681. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64682. */
  64683. init(): void;
  64684. /**
  64685. * Called when the behavior is attached to a target
  64686. * @param target defines the target where the behavior is attached to
  64687. */
  64688. attach(target: T): void;
  64689. /**
  64690. * Called when the behavior is detached from its target
  64691. */
  64692. detach(): void;
  64693. }
  64694. /**
  64695. * Interface implemented by classes supporting behaviors
  64696. */
  64697. export interface IBehaviorAware<T> {
  64698. /**
  64699. * Attach a behavior
  64700. * @param behavior defines the behavior to attach
  64701. * @returns the current host
  64702. */
  64703. addBehavior(behavior: Behavior<T>): T;
  64704. /**
  64705. * Remove a behavior from the current object
  64706. * @param behavior defines the behavior to detach
  64707. * @returns the current host
  64708. */
  64709. removeBehavior(behavior: Behavior<T>): T;
  64710. /**
  64711. * Gets a behavior using its name to search
  64712. * @param name defines the name to search
  64713. * @returns the behavior or null if not found
  64714. */
  64715. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64716. }
  64717. }
  64718. declare module BABYLON {
  64719. /**
  64720. * @hidden
  64721. */
  64722. export class IntersectionInfo {
  64723. bu: Nullable<number>;
  64724. bv: Nullable<number>;
  64725. distance: number;
  64726. faceId: number;
  64727. subMeshId: number;
  64728. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64729. }
  64730. }
  64731. declare module BABYLON {
  64732. /**
  64733. * Class used to store bounding sphere information
  64734. */
  64735. export class BoundingSphere {
  64736. /**
  64737. * Gets the center of the bounding sphere in local space
  64738. */
  64739. readonly center: Vector3;
  64740. /**
  64741. * Radius of the bounding sphere in local space
  64742. */
  64743. radius: number;
  64744. /**
  64745. * Gets the center of the bounding sphere in world space
  64746. */
  64747. readonly centerWorld: Vector3;
  64748. /**
  64749. * Radius of the bounding sphere in world space
  64750. */
  64751. radiusWorld: number;
  64752. /**
  64753. * Gets the minimum vector in local space
  64754. */
  64755. readonly minimum: Vector3;
  64756. /**
  64757. * Gets the maximum vector in local space
  64758. */
  64759. readonly maximum: Vector3;
  64760. private _worldMatrix;
  64761. private static readonly TmpVector3;
  64762. /**
  64763. * Creates a new bounding sphere
  64764. * @param min defines the minimum vector (in local space)
  64765. * @param max defines the maximum vector (in local space)
  64766. * @param worldMatrix defines the new world matrix
  64767. */
  64768. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64769. /**
  64770. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64771. * @param min defines the new minimum vector (in local space)
  64772. * @param max defines the new maximum vector (in local space)
  64773. * @param worldMatrix defines the new world matrix
  64774. */
  64775. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64776. /**
  64777. * Scale the current bounding sphere by applying a scale factor
  64778. * @param factor defines the scale factor to apply
  64779. * @returns the current bounding box
  64780. */
  64781. scale(factor: number): BoundingSphere;
  64782. /**
  64783. * Gets the world matrix of the bounding box
  64784. * @returns a matrix
  64785. */
  64786. getWorldMatrix(): DeepImmutable<Matrix>;
  64787. /** @hidden */
  64788. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64789. /**
  64790. * Tests if the bounding sphere is intersecting the frustum planes
  64791. * @param frustumPlanes defines the frustum planes to test
  64792. * @returns true if there is an intersection
  64793. */
  64794. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64795. /**
  64796. * Tests if the bounding sphere center is in between the frustum planes.
  64797. * Used for optimistic fast inclusion.
  64798. * @param frustumPlanes defines the frustum planes to test
  64799. * @returns true if the sphere center is in between the frustum planes
  64800. */
  64801. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64802. /**
  64803. * Tests if a point is inside the bounding sphere
  64804. * @param point defines the point to test
  64805. * @returns true if the point is inside the bounding sphere
  64806. */
  64807. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64808. /**
  64809. * Checks if two sphere intersct
  64810. * @param sphere0 sphere 0
  64811. * @param sphere1 sphere 1
  64812. * @returns true if the speres intersect
  64813. */
  64814. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64815. }
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * Class used to store bounding box information
  64820. */
  64821. export class BoundingBox implements ICullable {
  64822. /**
  64823. * Gets the 8 vectors representing the bounding box in local space
  64824. */
  64825. readonly vectors: Vector3[];
  64826. /**
  64827. * Gets the center of the bounding box in local space
  64828. */
  64829. readonly center: Vector3;
  64830. /**
  64831. * Gets the center of the bounding box in world space
  64832. */
  64833. readonly centerWorld: Vector3;
  64834. /**
  64835. * Gets the extend size in local space
  64836. */
  64837. readonly extendSize: Vector3;
  64838. /**
  64839. * Gets the extend size in world space
  64840. */
  64841. readonly extendSizeWorld: Vector3;
  64842. /**
  64843. * Gets the OBB (object bounding box) directions
  64844. */
  64845. readonly directions: Vector3[];
  64846. /**
  64847. * Gets the 8 vectors representing the bounding box in world space
  64848. */
  64849. readonly vectorsWorld: Vector3[];
  64850. /**
  64851. * Gets the minimum vector in world space
  64852. */
  64853. readonly minimumWorld: Vector3;
  64854. /**
  64855. * Gets the maximum vector in world space
  64856. */
  64857. readonly maximumWorld: Vector3;
  64858. /**
  64859. * Gets the minimum vector in local space
  64860. */
  64861. readonly minimum: Vector3;
  64862. /**
  64863. * Gets the maximum vector in local space
  64864. */
  64865. readonly maximum: Vector3;
  64866. private _worldMatrix;
  64867. private static readonly TmpVector3;
  64868. /**
  64869. * @hidden
  64870. */
  64871. _tag: number;
  64872. /**
  64873. * Creates a new bounding box
  64874. * @param min defines the minimum vector (in local space)
  64875. * @param max defines the maximum vector (in local space)
  64876. * @param worldMatrix defines the new world matrix
  64877. */
  64878. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64879. /**
  64880. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64881. * @param min defines the new minimum vector (in local space)
  64882. * @param max defines the new maximum vector (in local space)
  64883. * @param worldMatrix defines the new world matrix
  64884. */
  64885. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64886. /**
  64887. * Scale the current bounding box by applying a scale factor
  64888. * @param factor defines the scale factor to apply
  64889. * @returns the current bounding box
  64890. */
  64891. scale(factor: number): BoundingBox;
  64892. /**
  64893. * Gets the world matrix of the bounding box
  64894. * @returns a matrix
  64895. */
  64896. getWorldMatrix(): DeepImmutable<Matrix>;
  64897. /** @hidden */
  64898. _update(world: DeepImmutable<Matrix>): void;
  64899. /**
  64900. * Tests if the bounding box is intersecting the frustum planes
  64901. * @param frustumPlanes defines the frustum planes to test
  64902. * @returns true if there is an intersection
  64903. */
  64904. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64905. /**
  64906. * Tests if the bounding box is entirely inside the frustum planes
  64907. * @param frustumPlanes defines the frustum planes to test
  64908. * @returns true if there is an inclusion
  64909. */
  64910. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64911. /**
  64912. * Tests if a point is inside the bounding box
  64913. * @param point defines the point to test
  64914. * @returns true if the point is inside the bounding box
  64915. */
  64916. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64917. /**
  64918. * Tests if the bounding box intersects with a bounding sphere
  64919. * @param sphere defines the sphere to test
  64920. * @returns true if there is an intersection
  64921. */
  64922. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64923. /**
  64924. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64925. * @param min defines the min vector to use
  64926. * @param max defines the max vector to use
  64927. * @returns true if there is an intersection
  64928. */
  64929. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64930. /**
  64931. * Tests if two bounding boxes are intersections
  64932. * @param box0 defines the first box to test
  64933. * @param box1 defines the second box to test
  64934. * @returns true if there is an intersection
  64935. */
  64936. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64937. /**
  64938. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64939. * @param minPoint defines the minimum vector of the bounding box
  64940. * @param maxPoint defines the maximum vector of the bounding box
  64941. * @param sphereCenter defines the sphere center
  64942. * @param sphereRadius defines the sphere radius
  64943. * @returns true if there is an intersection
  64944. */
  64945. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64946. /**
  64947. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64948. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64949. * @param frustumPlanes defines the frustum planes to test
  64950. * @return true if there is an inclusion
  64951. */
  64952. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64953. /**
  64954. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64956. * @param frustumPlanes defines the frustum planes to test
  64957. * @return true if there is an intersection
  64958. */
  64959. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64960. }
  64961. }
  64962. declare module BABYLON {
  64963. /** @hidden */
  64964. export class Collider {
  64965. /** Define if a collision was found */
  64966. collisionFound: boolean;
  64967. /**
  64968. * Define last intersection point in local space
  64969. */
  64970. intersectionPoint: Vector3;
  64971. /**
  64972. * Define last collided mesh
  64973. */
  64974. collidedMesh: Nullable<AbstractMesh>;
  64975. private _collisionPoint;
  64976. private _planeIntersectionPoint;
  64977. private _tempVector;
  64978. private _tempVector2;
  64979. private _tempVector3;
  64980. private _tempVector4;
  64981. private _edge;
  64982. private _baseToVertex;
  64983. private _destinationPoint;
  64984. private _slidePlaneNormal;
  64985. private _displacementVector;
  64986. /** @hidden */
  64987. _radius: Vector3;
  64988. /** @hidden */
  64989. _retry: number;
  64990. private _velocity;
  64991. private _basePoint;
  64992. private _epsilon;
  64993. /** @hidden */
  64994. _velocityWorldLength: number;
  64995. /** @hidden */
  64996. _basePointWorld: Vector3;
  64997. private _velocityWorld;
  64998. private _normalizedVelocity;
  64999. /** @hidden */
  65000. _initialVelocity: Vector3;
  65001. /** @hidden */
  65002. _initialPosition: Vector3;
  65003. private _nearestDistance;
  65004. private _collisionMask;
  65005. collisionMask: number;
  65006. /**
  65007. * Gets the plane normal used to compute the sliding response (in local space)
  65008. */
  65009. readonly slidePlaneNormal: Vector3;
  65010. /** @hidden */
  65011. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65012. /** @hidden */
  65013. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65014. /** @hidden */
  65015. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65016. /** @hidden */
  65017. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65018. /** @hidden */
  65019. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65020. /** @hidden */
  65021. _getResponse(pos: Vector3, vel: Vector3): void;
  65022. }
  65023. }
  65024. declare module BABYLON {
  65025. /**
  65026. * Interface for cullable objects
  65027. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65028. */
  65029. export interface ICullable {
  65030. /**
  65031. * Checks if the object or part of the object is in the frustum
  65032. * @param frustumPlanes Camera near/planes
  65033. * @returns true if the object is in frustum otherwise false
  65034. */
  65035. isInFrustum(frustumPlanes: Plane[]): boolean;
  65036. /**
  65037. * Checks if a cullable object (mesh...) is in the camera frustum
  65038. * Unlike isInFrustum this cheks the full bounding box
  65039. * @param frustumPlanes Camera near/planes
  65040. * @returns true if the object is in frustum otherwise false
  65041. */
  65042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65043. }
  65044. /**
  65045. * Info for a bounding data of a mesh
  65046. */
  65047. export class BoundingInfo implements ICullable {
  65048. /**
  65049. * Bounding box for the mesh
  65050. */
  65051. readonly boundingBox: BoundingBox;
  65052. /**
  65053. * Bounding sphere for the mesh
  65054. */
  65055. readonly boundingSphere: BoundingSphere;
  65056. private _isLocked;
  65057. private static readonly TmpVector3;
  65058. /**
  65059. * Constructs bounding info
  65060. * @param minimum min vector of the bounding box/sphere
  65061. * @param maximum max vector of the bounding box/sphere
  65062. * @param worldMatrix defines the new world matrix
  65063. */
  65064. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65065. /**
  65066. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65067. * @param min defines the new minimum vector (in local space)
  65068. * @param max defines the new maximum vector (in local space)
  65069. * @param worldMatrix defines the new world matrix
  65070. */
  65071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65072. /**
  65073. * min vector of the bounding box/sphere
  65074. */
  65075. readonly minimum: Vector3;
  65076. /**
  65077. * max vector of the bounding box/sphere
  65078. */
  65079. readonly maximum: Vector3;
  65080. /**
  65081. * If the info is locked and won't be updated to avoid perf overhead
  65082. */
  65083. isLocked: boolean;
  65084. /**
  65085. * Updates the bounding sphere and box
  65086. * @param world world matrix to be used to update
  65087. */
  65088. update(world: DeepImmutable<Matrix>): void;
  65089. /**
  65090. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65091. * @param center New center of the bounding info
  65092. * @param extend New extend of the bounding info
  65093. * @returns the current bounding info
  65094. */
  65095. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65096. /**
  65097. * Scale the current bounding info by applying a scale factor
  65098. * @param factor defines the scale factor to apply
  65099. * @returns the current bounding info
  65100. */
  65101. scale(factor: number): BoundingInfo;
  65102. /**
  65103. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65104. * @param frustumPlanes defines the frustum to test
  65105. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65106. * @returns true if the bounding info is in the frustum planes
  65107. */
  65108. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65109. /**
  65110. * Gets the world distance between the min and max points of the bounding box
  65111. */
  65112. readonly diagonalLength: number;
  65113. /**
  65114. * Checks if a cullable object (mesh...) is in the camera frustum
  65115. * Unlike isInFrustum this cheks the full bounding box
  65116. * @param frustumPlanes Camera near/planes
  65117. * @returns true if the object is in frustum otherwise false
  65118. */
  65119. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65120. /** @hidden */
  65121. _checkCollision(collider: Collider): boolean;
  65122. /**
  65123. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65125. * @param point the point to check intersection with
  65126. * @returns if the point intersects
  65127. */
  65128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65129. /**
  65130. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65131. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65132. * @param boundingInfo the bounding info to check intersection with
  65133. * @param precise if the intersection should be done using OBB
  65134. * @returns if the bounding info intersects
  65135. */
  65136. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65137. }
  65138. }
  65139. declare module BABYLON {
  65140. /**
  65141. * Defines an array and its length.
  65142. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65143. */
  65144. export interface ISmartArrayLike<T> {
  65145. /**
  65146. * The data of the array.
  65147. */
  65148. data: Array<T>;
  65149. /**
  65150. * The active length of the array.
  65151. */
  65152. length: number;
  65153. }
  65154. /**
  65155. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65156. */
  65157. export class SmartArray<T> implements ISmartArrayLike<T> {
  65158. /**
  65159. * The full set of data from the array.
  65160. */
  65161. data: Array<T>;
  65162. /**
  65163. * The active length of the array.
  65164. */
  65165. length: number;
  65166. protected _id: number;
  65167. /**
  65168. * Instantiates a Smart Array.
  65169. * @param capacity defines the default capacity of the array.
  65170. */
  65171. constructor(capacity: number);
  65172. /**
  65173. * Pushes a value at the end of the active data.
  65174. * @param value defines the object to push in the array.
  65175. */
  65176. push(value: T): void;
  65177. /**
  65178. * Iterates over the active data and apply the lambda to them.
  65179. * @param func defines the action to apply on each value.
  65180. */
  65181. forEach(func: (content: T) => void): void;
  65182. /**
  65183. * Sorts the full sets of data.
  65184. * @param compareFn defines the comparison function to apply.
  65185. */
  65186. sort(compareFn: (a: T, b: T) => number): void;
  65187. /**
  65188. * Resets the active data to an empty array.
  65189. */
  65190. reset(): void;
  65191. /**
  65192. * Releases all the data from the array as well as the array.
  65193. */
  65194. dispose(): void;
  65195. /**
  65196. * Concats the active data with a given array.
  65197. * @param array defines the data to concatenate with.
  65198. */
  65199. concat(array: any): void;
  65200. /**
  65201. * Returns the position of a value in the active data.
  65202. * @param value defines the value to find the index for
  65203. * @returns the index if found in the active data otherwise -1
  65204. */
  65205. indexOf(value: T): number;
  65206. /**
  65207. * Returns whether an element is part of the active data.
  65208. * @param value defines the value to look for
  65209. * @returns true if found in the active data otherwise false
  65210. */
  65211. contains(value: T): boolean;
  65212. private static _GlobalId;
  65213. }
  65214. /**
  65215. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65216. * The data in this array can only be present once
  65217. */
  65218. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65219. private _duplicateId;
  65220. /**
  65221. * Pushes a value at the end of the active data.
  65222. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65223. * @param value defines the object to push in the array.
  65224. */
  65225. push(value: T): void;
  65226. /**
  65227. * Pushes a value at the end of the active data.
  65228. * If the data is already present, it won t be added again
  65229. * @param value defines the object to push in the array.
  65230. * @returns true if added false if it was already present
  65231. */
  65232. pushNoDuplicate(value: T): boolean;
  65233. /**
  65234. * Resets the active data to an empty array.
  65235. */
  65236. reset(): void;
  65237. /**
  65238. * Concats the active data with a given array.
  65239. * This ensures no dupplicate will be present in the result.
  65240. * @param array defines the data to concatenate with.
  65241. */
  65242. concatWithNoDuplicate(array: any): void;
  65243. }
  65244. }
  65245. declare module BABYLON {
  65246. /**
  65247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65248. * separate meshes. This can be use to improve performances.
  65249. * @see http://doc.babylonjs.com/how_to/multi_materials
  65250. */
  65251. export class MultiMaterial extends Material {
  65252. private _subMaterials;
  65253. /**
  65254. * Gets or Sets the list of Materials used within the multi material.
  65255. * They need to be ordered according to the submeshes order in the associated mesh
  65256. */
  65257. subMaterials: Nullable<Material>[];
  65258. /**
  65259. * Function used to align with Node.getChildren()
  65260. * @returns the list of Materials used within the multi material
  65261. */
  65262. getChildren(): Nullable<Material>[];
  65263. /**
  65264. * Instantiates a new Multi Material
  65265. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65266. * separate meshes. This can be use to improve performances.
  65267. * @see http://doc.babylonjs.com/how_to/multi_materials
  65268. * @param name Define the name in the scene
  65269. * @param scene Define the scene the material belongs to
  65270. */
  65271. constructor(name: string, scene: Scene);
  65272. private _hookArray;
  65273. /**
  65274. * Get one of the submaterial by its index in the submaterials array
  65275. * @param index The index to look the sub material at
  65276. * @returns The Material if the index has been defined
  65277. */
  65278. getSubMaterial(index: number): Nullable<Material>;
  65279. /**
  65280. * Get the list of active textures for the whole sub materials list.
  65281. * @returns All the textures that will be used during the rendering
  65282. */
  65283. getActiveTextures(): BaseTexture[];
  65284. /**
  65285. * Gets the current class name of the material e.g. "MultiMaterial"
  65286. * Mainly use in serialization.
  65287. * @returns the class name
  65288. */
  65289. getClassName(): string;
  65290. /**
  65291. * Checks if the material is ready to render the requested sub mesh
  65292. * @param mesh Define the mesh the submesh belongs to
  65293. * @param subMesh Define the sub mesh to look readyness for
  65294. * @param useInstances Define whether or not the material is used with instances
  65295. * @returns true if ready, otherwise false
  65296. */
  65297. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65298. /**
  65299. * Clones the current material and its related sub materials
  65300. * @param name Define the name of the newly cloned material
  65301. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65302. * @returns the cloned material
  65303. */
  65304. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65305. /**
  65306. * Serializes the materials into a JSON representation.
  65307. * @returns the JSON representation
  65308. */
  65309. serialize(): any;
  65310. /**
  65311. * Dispose the material and release its associated resources
  65312. * @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)
  65313. * @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)
  65314. * @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)
  65315. */
  65316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65317. /**
  65318. * Creates a MultiMaterial from parsed MultiMaterial data.
  65319. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65320. * @param scene defines the hosting scene
  65321. * @returns a new MultiMaterial
  65322. */
  65323. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65324. }
  65325. }
  65326. declare module BABYLON {
  65327. /**
  65328. * Class used to represent data loading progression
  65329. */
  65330. export class SceneLoaderFlags {
  65331. private static _ForceFullSceneLoadingForIncremental;
  65332. private static _ShowLoadingScreen;
  65333. private static _CleanBoneMatrixWeights;
  65334. private static _loggingLevel;
  65335. /**
  65336. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65337. */
  65338. static ForceFullSceneLoadingForIncremental: boolean;
  65339. /**
  65340. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65341. */
  65342. static ShowLoadingScreen: boolean;
  65343. /**
  65344. * Defines the current logging level (while loading the scene)
  65345. * @ignorenaming
  65346. */
  65347. static loggingLevel: number;
  65348. /**
  65349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65350. */
  65351. static CleanBoneMatrixWeights: boolean;
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * 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.
  65357. * @see https://doc.babylonjs.com/how_to/transformnode
  65358. */
  65359. export class TransformNode extends Node {
  65360. /**
  65361. * Object will not rotate to face the camera
  65362. */
  65363. static BILLBOARDMODE_NONE: number;
  65364. /**
  65365. * Object will rotate to face the camera but only on the x axis
  65366. */
  65367. static BILLBOARDMODE_X: number;
  65368. /**
  65369. * Object will rotate to face the camera but only on the y axis
  65370. */
  65371. static BILLBOARDMODE_Y: number;
  65372. /**
  65373. * Object will rotate to face the camera but only on the z axis
  65374. */
  65375. static BILLBOARDMODE_Z: number;
  65376. /**
  65377. * Object will rotate to face the camera
  65378. */
  65379. static BILLBOARDMODE_ALL: number;
  65380. private _forward;
  65381. private _forwardInverted;
  65382. private _up;
  65383. private _right;
  65384. private _rightInverted;
  65385. private _position;
  65386. private _rotation;
  65387. private _rotationQuaternion;
  65388. protected _scaling: Vector3;
  65389. protected _isDirty: boolean;
  65390. private _transformToBoneReferal;
  65391. /**
  65392. * Set the billboard mode. Default is 0.
  65393. *
  65394. * | Value | Type | Description |
  65395. * | --- | --- | --- |
  65396. * | 0 | BILLBOARDMODE_NONE | |
  65397. * | 1 | BILLBOARDMODE_X | |
  65398. * | 2 | BILLBOARDMODE_Y | |
  65399. * | 4 | BILLBOARDMODE_Z | |
  65400. * | 7 | BILLBOARDMODE_ALL | |
  65401. *
  65402. */
  65403. billboardMode: number;
  65404. /**
  65405. * 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
  65406. */
  65407. scalingDeterminant: number;
  65408. /**
  65409. * Sets the distance of the object to max, often used by skybox
  65410. */
  65411. infiniteDistance: boolean;
  65412. /**
  65413. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65414. * By default the system will update normals to compensate
  65415. */
  65416. ignoreNonUniformScaling: boolean;
  65417. /** @hidden */
  65418. _poseMatrix: Matrix;
  65419. /** @hidden */
  65420. _localMatrix: Matrix;
  65421. private _absolutePosition;
  65422. private _pivotMatrix;
  65423. private _pivotMatrixInverse;
  65424. protected _postMultiplyPivotMatrix: boolean;
  65425. private _tempMatrix;
  65426. private _tempMatrix2;
  65427. protected _isWorldMatrixFrozen: boolean;
  65428. /** @hidden */
  65429. _indexInSceneTransformNodesArray: number;
  65430. /**
  65431. * An event triggered after the world matrix is updated
  65432. */
  65433. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65434. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65435. /**
  65436. * Gets a string identifying the name of the class
  65437. * @returns "TransformNode" string
  65438. */
  65439. getClassName(): string;
  65440. /**
  65441. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65442. */
  65443. position: Vector3;
  65444. /**
  65445. * 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)).
  65446. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65447. */
  65448. rotation: Vector3;
  65449. /**
  65450. * 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)).
  65451. */
  65452. scaling: Vector3;
  65453. /**
  65454. * 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).
  65455. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65456. */
  65457. rotationQuaternion: Nullable<Quaternion>;
  65458. /**
  65459. * The forward direction of that transform in world space.
  65460. */
  65461. readonly forward: Vector3;
  65462. /**
  65463. * The up direction of that transform in world space.
  65464. */
  65465. readonly up: Vector3;
  65466. /**
  65467. * The right direction of that transform in world space.
  65468. */
  65469. readonly right: Vector3;
  65470. /**
  65471. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65472. * @param matrix the matrix to copy the pose from
  65473. * @returns this TransformNode.
  65474. */
  65475. updatePoseMatrix(matrix: Matrix): TransformNode;
  65476. /**
  65477. * Returns the mesh Pose matrix.
  65478. * @returns the pose matrix
  65479. */
  65480. getPoseMatrix(): Matrix;
  65481. /** @hidden */
  65482. _isSynchronized(): boolean;
  65483. /** @hidden */
  65484. _initCache(): void;
  65485. /**
  65486. * Flag the transform node as dirty (Forcing it to update everything)
  65487. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65488. * @returns this transform node
  65489. */
  65490. markAsDirty(property: string): TransformNode;
  65491. /**
  65492. * Returns the current mesh absolute position.
  65493. * Returns a Vector3.
  65494. */
  65495. readonly absolutePosition: Vector3;
  65496. /**
  65497. * Sets a new matrix to apply before all other transformation
  65498. * @param matrix defines the transform matrix
  65499. * @returns the current TransformNode
  65500. */
  65501. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65502. /**
  65503. * Sets a new pivot matrix to the current node
  65504. * @param matrix defines the new pivot matrix to use
  65505. * @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
  65506. * @returns the current TransformNode
  65507. */
  65508. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65509. /**
  65510. * Returns the mesh pivot matrix.
  65511. * Default : Identity.
  65512. * @returns the matrix
  65513. */
  65514. getPivotMatrix(): Matrix;
  65515. /**
  65516. * Prevents the World matrix to be computed any longer.
  65517. * @returns the TransformNode.
  65518. */
  65519. freezeWorldMatrix(): TransformNode;
  65520. /**
  65521. * Allows back the World matrix computation.
  65522. * @returns the TransformNode.
  65523. */
  65524. unfreezeWorldMatrix(): this;
  65525. /**
  65526. * True if the World matrix has been frozen.
  65527. */
  65528. readonly isWorldMatrixFrozen: boolean;
  65529. /**
  65530. * Retuns the mesh absolute position in the World.
  65531. * @returns a Vector3.
  65532. */
  65533. getAbsolutePosition(): Vector3;
  65534. /**
  65535. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65536. * @param absolutePosition the absolute position to set
  65537. * @returns the TransformNode.
  65538. */
  65539. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65540. /**
  65541. * Sets the mesh position in its local space.
  65542. * @param vector3 the position to set in localspace
  65543. * @returns the TransformNode.
  65544. */
  65545. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65546. /**
  65547. * Returns the mesh position in the local space from the current World matrix values.
  65548. * @returns a new Vector3.
  65549. */
  65550. getPositionExpressedInLocalSpace(): Vector3;
  65551. /**
  65552. * Translates the mesh along the passed Vector3 in its local space.
  65553. * @param vector3 the distance to translate in localspace
  65554. * @returns the TransformNode.
  65555. */
  65556. locallyTranslate(vector3: Vector3): TransformNode;
  65557. private static _lookAtVectorCache;
  65558. /**
  65559. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65560. * @param targetPoint the position (must be in same space as current mesh) to look at
  65561. * @param yawCor optional yaw (y-axis) correction in radians
  65562. * @param pitchCor optional pitch (x-axis) correction in radians
  65563. * @param rollCor optional roll (z-axis) correction in radians
  65564. * @param space the choosen space of the target
  65565. * @returns the TransformNode.
  65566. */
  65567. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65568. /**
  65569. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65570. * This Vector3 is expressed in the World space.
  65571. * @param localAxis axis to rotate
  65572. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65573. */
  65574. getDirection(localAxis: Vector3): Vector3;
  65575. /**
  65576. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65577. * localAxis is expressed in the mesh local space.
  65578. * result is computed in the Wordl space from the mesh World matrix.
  65579. * @param localAxis axis to rotate
  65580. * @param result the resulting transformnode
  65581. * @returns this TransformNode.
  65582. */
  65583. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65584. /**
  65585. * Sets this transform node rotation to the given local axis.
  65586. * @param localAxis the axis in local space
  65587. * @param yawCor optional yaw (y-axis) correction in radians
  65588. * @param pitchCor optional pitch (x-axis) correction in radians
  65589. * @param rollCor optional roll (z-axis) correction in radians
  65590. * @returns this TransformNode
  65591. */
  65592. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65593. /**
  65594. * Sets a new pivot point to the current node
  65595. * @param point defines the new pivot point to use
  65596. * @param space defines if the point is in world or local space (local by default)
  65597. * @returns the current TransformNode
  65598. */
  65599. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65600. /**
  65601. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65602. * @returns the pivot point
  65603. */
  65604. getPivotPoint(): Vector3;
  65605. /**
  65606. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65607. * @param result the vector3 to store the result
  65608. * @returns this TransformNode.
  65609. */
  65610. getPivotPointToRef(result: Vector3): TransformNode;
  65611. /**
  65612. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65613. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65614. */
  65615. getAbsolutePivotPoint(): Vector3;
  65616. /**
  65617. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65618. * @param result vector3 to store the result
  65619. * @returns this TransformNode.
  65620. */
  65621. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65622. /**
  65623. * Defines the passed node as the parent of the current node.
  65624. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65625. * @param node the node ot set as the parent
  65626. * @returns this TransformNode.
  65627. */
  65628. setParent(node: Nullable<Node>): TransformNode;
  65629. private _nonUniformScaling;
  65630. /**
  65631. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65632. */
  65633. readonly nonUniformScaling: boolean;
  65634. /** @hidden */
  65635. _updateNonUniformScalingState(value: boolean): boolean;
  65636. /**
  65637. * Attach the current TransformNode to another TransformNode associated with a bone
  65638. * @param bone Bone affecting the TransformNode
  65639. * @param affectedTransformNode TransformNode associated with the bone
  65640. * @returns this object
  65641. */
  65642. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65643. /**
  65644. * Detach the transform node if its associated with a bone
  65645. * @returns this object
  65646. */
  65647. detachFromBone(): TransformNode;
  65648. private static _rotationAxisCache;
  65649. /**
  65650. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65651. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65652. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65653. * The passed axis is also normalized.
  65654. * @param axis the axis to rotate around
  65655. * @param amount the amount to rotate in radians
  65656. * @param space Space to rotate in (Default: local)
  65657. * @returns the TransformNode.
  65658. */
  65659. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65660. /**
  65661. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65662. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65663. * The passed axis is also normalized. .
  65664. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65665. * @param point the point to rotate around
  65666. * @param axis the axis to rotate around
  65667. * @param amount the amount to rotate in radians
  65668. * @returns the TransformNode
  65669. */
  65670. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65671. /**
  65672. * Translates the mesh along the axis vector for the passed distance in the given space.
  65673. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65674. * @param axis the axis to translate in
  65675. * @param distance the distance to translate
  65676. * @param space Space to rotate in (Default: local)
  65677. * @returns the TransformNode.
  65678. */
  65679. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65680. /**
  65681. * Adds a rotation step to the mesh current rotation.
  65682. * x, y, z are Euler angles expressed in radians.
  65683. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65684. * This means this rotation is made in the mesh local space only.
  65685. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65686. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65687. * ```javascript
  65688. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65689. * ```
  65690. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65691. * 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.
  65692. * @param x Rotation to add
  65693. * @param y Rotation to add
  65694. * @param z Rotation to add
  65695. * @returns the TransformNode.
  65696. */
  65697. addRotation(x: number, y: number, z: number): TransformNode;
  65698. /**
  65699. * Computes the world matrix of the node
  65700. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65701. * @returns the world matrix
  65702. */
  65703. computeWorldMatrix(force?: boolean): Matrix;
  65704. protected _afterComputeWorldMatrix(): void;
  65705. /**
  65706. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65707. * @param func callback function to add
  65708. *
  65709. * @returns the TransformNode.
  65710. */
  65711. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65712. /**
  65713. * Removes a registered callback function.
  65714. * @param func callback function to remove
  65715. * @returns the TransformNode.
  65716. */
  65717. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65718. /**
  65719. * Gets the position of the current mesh in camera space
  65720. * @param camera defines the camera to use
  65721. * @returns a position
  65722. */
  65723. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65724. /**
  65725. * Returns the distance from the mesh to the active camera
  65726. * @param camera defines the camera to use
  65727. * @returns the distance
  65728. */
  65729. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65730. /**
  65731. * Clone the current transform node
  65732. * @param name Name of the new clone
  65733. * @param newParent New parent for the clone
  65734. * @param doNotCloneChildren Do not clone children hierarchy
  65735. * @returns the new transform node
  65736. */
  65737. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65738. /**
  65739. * Serializes the objects information.
  65740. * @param currentSerializationObject defines the object to serialize in
  65741. * @returns the serialized object
  65742. */
  65743. serialize(currentSerializationObject?: any): any;
  65744. /**
  65745. * Returns a new TransformNode object parsed from the source provided.
  65746. * @param parsedTransformNode is the source.
  65747. * @param scene the scne the object belongs to
  65748. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65749. * @returns a new TransformNode object parsed from the source provided.
  65750. */
  65751. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65752. /**
  65753. * Get all child-transformNodes of this node
  65754. * @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
  65755. * @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
  65756. * @returns an array of TransformNode
  65757. */
  65758. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65759. /**
  65760. * Releases resources associated with this transform node.
  65761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65763. */
  65764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65765. }
  65766. }
  65767. declare module BABYLON {
  65768. /**
  65769. * Class used to override all child animations of a given target
  65770. */
  65771. export class AnimationPropertiesOverride {
  65772. /**
  65773. * Gets or sets a value indicating if animation blending must be used
  65774. */
  65775. enableBlending: boolean;
  65776. /**
  65777. * Gets or sets the blending speed to use when enableBlending is true
  65778. */
  65779. blendingSpeed: number;
  65780. /**
  65781. * Gets or sets the default loop mode to use
  65782. */
  65783. loopMode: number;
  65784. }
  65785. }
  65786. declare module BABYLON {
  65787. /**
  65788. * Class used to store bone information
  65789. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65790. */
  65791. export class Bone extends Node {
  65792. /**
  65793. * defines the bone name
  65794. */
  65795. name: string;
  65796. private static _tmpVecs;
  65797. private static _tmpQuat;
  65798. private static _tmpMats;
  65799. /**
  65800. * Gets the list of child bones
  65801. */
  65802. children: Bone[];
  65803. /** Gets the animations associated with this bone */
  65804. animations: Animation[];
  65805. /**
  65806. * Gets or sets bone length
  65807. */
  65808. length: number;
  65809. /**
  65810. * @hidden Internal only
  65811. * Set this value to map this bone to a different index in the transform matrices
  65812. * Set this value to -1 to exclude the bone from the transform matrices
  65813. */
  65814. _index: Nullable<number>;
  65815. private _skeleton;
  65816. private _localMatrix;
  65817. private _restPose;
  65818. private _baseMatrix;
  65819. private _absoluteTransform;
  65820. private _invertedAbsoluteTransform;
  65821. private _parent;
  65822. private _scalingDeterminant;
  65823. private _worldTransform;
  65824. private _localScaling;
  65825. private _localRotation;
  65826. private _localPosition;
  65827. private _needToDecompose;
  65828. private _needToCompose;
  65829. /** @hidden */
  65830. _linkedTransformNode: Nullable<TransformNode>;
  65831. /** @hidden */
  65832. /** @hidden */
  65833. _matrix: Matrix;
  65834. /**
  65835. * Create a new bone
  65836. * @param name defines the bone name
  65837. * @param skeleton defines the parent skeleton
  65838. * @param parentBone defines the parent (can be null if the bone is the root)
  65839. * @param localMatrix defines the local matrix
  65840. * @param restPose defines the rest pose matrix
  65841. * @param baseMatrix defines the base matrix
  65842. * @param index defines index of the bone in the hiearchy
  65843. */
  65844. constructor(
  65845. /**
  65846. * defines the bone name
  65847. */
  65848. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65849. /**
  65850. * Gets the current object class name.
  65851. * @return the class name
  65852. */
  65853. getClassName(): string;
  65854. /**
  65855. * Gets the parent skeleton
  65856. * @returns a skeleton
  65857. */
  65858. getSkeleton(): Skeleton;
  65859. /**
  65860. * Gets parent bone
  65861. * @returns a bone or null if the bone is the root of the bone hierarchy
  65862. */
  65863. getParent(): Nullable<Bone>;
  65864. /**
  65865. * Returns an array containing the root bones
  65866. * @returns an array containing the root bones
  65867. */
  65868. getChildren(): Array<Bone>;
  65869. /**
  65870. * Sets the parent bone
  65871. * @param parent defines the parent (can be null if the bone is the root)
  65872. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65873. */
  65874. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65875. /**
  65876. * Gets the local matrix
  65877. * @returns a matrix
  65878. */
  65879. getLocalMatrix(): Matrix;
  65880. /**
  65881. * Gets the base matrix (initial matrix which remains unchanged)
  65882. * @returns a matrix
  65883. */
  65884. getBaseMatrix(): Matrix;
  65885. /**
  65886. * Gets the rest pose matrix
  65887. * @returns a matrix
  65888. */
  65889. getRestPose(): Matrix;
  65890. /**
  65891. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65892. */
  65893. getWorldMatrix(): Matrix;
  65894. /**
  65895. * Sets the local matrix to rest pose matrix
  65896. */
  65897. returnToRest(): void;
  65898. /**
  65899. * Gets the inverse of the absolute transform matrix.
  65900. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65901. * @returns a matrix
  65902. */
  65903. getInvertedAbsoluteTransform(): Matrix;
  65904. /**
  65905. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65906. * @returns a matrix
  65907. */
  65908. getAbsoluteTransform(): Matrix;
  65909. /**
  65910. * Links with the given transform node.
  65911. * The local matrix of this bone is copied from the transform node every frame.
  65912. * @param transformNode defines the transform node to link to
  65913. */
  65914. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65915. /** Gets or sets current position (in local space) */
  65916. position: Vector3;
  65917. /** Gets or sets current rotation (in local space) */
  65918. rotation: Vector3;
  65919. /** Gets or sets current rotation quaternion (in local space) */
  65920. rotationQuaternion: Quaternion;
  65921. /** Gets or sets current scaling (in local space) */
  65922. scaling: Vector3;
  65923. /**
  65924. * Gets the animation properties override
  65925. */
  65926. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65927. private _decompose;
  65928. private _compose;
  65929. /**
  65930. * Update the base and local matrices
  65931. * @param matrix defines the new base or local matrix
  65932. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65933. * @param updateLocalMatrix defines if the local matrix should be updated
  65934. */
  65935. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65936. /** @hidden */
  65937. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65938. /**
  65939. * Flag the bone as dirty (Forcing it to update everything)
  65940. */
  65941. markAsDirty(): void;
  65942. private _markAsDirtyAndCompose;
  65943. private _markAsDirtyAndDecompose;
  65944. /**
  65945. * Translate the bone in local or world space
  65946. * @param vec The amount to translate the bone
  65947. * @param space The space that the translation is in
  65948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65949. */
  65950. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65951. /**
  65952. * Set the postion of the bone in local or world space
  65953. * @param position The position to set the bone
  65954. * @param space The space that the position is in
  65955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65956. */
  65957. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65958. /**
  65959. * Set the absolute position of the bone (world space)
  65960. * @param position The position to set the bone
  65961. * @param mesh The mesh that this bone is attached to
  65962. */
  65963. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65964. /**
  65965. * Scale the bone on the x, y and z axes (in local space)
  65966. * @param x The amount to scale the bone on the x axis
  65967. * @param y The amount to scale the bone on the y axis
  65968. * @param z The amount to scale the bone on the z axis
  65969. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65970. */
  65971. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65972. /**
  65973. * Set the bone scaling in local space
  65974. * @param scale defines the scaling vector
  65975. */
  65976. setScale(scale: Vector3): void;
  65977. /**
  65978. * Gets the current scaling in local space
  65979. * @returns the current scaling vector
  65980. */
  65981. getScale(): Vector3;
  65982. /**
  65983. * Gets the current scaling in local space and stores it in a target vector
  65984. * @param result defines the target vector
  65985. */
  65986. getScaleToRef(result: Vector3): void;
  65987. /**
  65988. * Set the yaw, pitch, and roll of the bone in local or world space
  65989. * @param yaw The rotation of the bone on the y axis
  65990. * @param pitch The rotation of the bone on the x axis
  65991. * @param roll The rotation of the bone on the z axis
  65992. * @param space The space that the axes of rotation are in
  65993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65994. */
  65995. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65996. /**
  65997. * Add a rotation to the bone on an axis in local or world space
  65998. * @param axis The axis to rotate the bone on
  65999. * @param amount The amount to rotate the bone
  66000. * @param space The space that the axis is in
  66001. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66002. */
  66003. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66004. /**
  66005. * Set the rotation of the bone to a particular axis angle in local or world space
  66006. * @param axis The axis to rotate the bone on
  66007. * @param angle The angle that the bone should be rotated to
  66008. * @param space The space that the axis is in
  66009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66010. */
  66011. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66012. /**
  66013. * Set the euler rotation of the bone in local of world space
  66014. * @param rotation The euler rotation that the bone should be set to
  66015. * @param space The space that the rotation is in
  66016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66017. */
  66018. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66019. /**
  66020. * Set the quaternion rotation of the bone in local of world space
  66021. * @param quat The quaternion rotation that the bone should be set to
  66022. * @param space The space that the rotation is in
  66023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66024. */
  66025. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66026. /**
  66027. * Set the rotation matrix of the bone in local of world space
  66028. * @param rotMat The rotation matrix that the bone should be set to
  66029. * @param space The space that the rotation is in
  66030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66031. */
  66032. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66033. private _rotateWithMatrix;
  66034. private _getNegativeRotationToRef;
  66035. /**
  66036. * Get the position of the bone in local or world space
  66037. * @param space The space that the returned position is in
  66038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66039. * @returns The position of the bone
  66040. */
  66041. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66042. /**
  66043. * Copy the position of the bone to a vector3 in local or world space
  66044. * @param space The space that the returned position is in
  66045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66046. * @param result The vector3 to copy the position to
  66047. */
  66048. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66049. /**
  66050. * Get the absolute position of the bone (world space)
  66051. * @param mesh The mesh that this bone is attached to
  66052. * @returns The absolute position of the bone
  66053. */
  66054. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66055. /**
  66056. * Copy the absolute position of the bone (world space) to the result param
  66057. * @param mesh The mesh that this bone is attached to
  66058. * @param result The vector3 to copy the absolute position to
  66059. */
  66060. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66061. /**
  66062. * Compute the absolute transforms of this bone and its children
  66063. */
  66064. computeAbsoluteTransforms(): void;
  66065. /**
  66066. * Get the world direction from an axis that is in the local space of the bone
  66067. * @param localAxis The local direction that is used to compute the world direction
  66068. * @param mesh The mesh that this bone is attached to
  66069. * @returns The world direction
  66070. */
  66071. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66072. /**
  66073. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66074. * @param localAxis The local direction that is used to compute the world direction
  66075. * @param mesh The mesh that this bone is attached to
  66076. * @param result The vector3 that the world direction will be copied to
  66077. */
  66078. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66079. /**
  66080. * Get the euler rotation of the bone in local or world space
  66081. * @param space The space that the rotation should be in
  66082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66083. * @returns The euler rotation
  66084. */
  66085. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66086. /**
  66087. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66088. * @param space The space that the rotation should be in
  66089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66090. * @param result The vector3 that the rotation should be copied to
  66091. */
  66092. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66093. /**
  66094. * Get the quaternion rotation of the bone in either local or world space
  66095. * @param space The space that the rotation should be in
  66096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66097. * @returns The quaternion rotation
  66098. */
  66099. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66100. /**
  66101. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66102. * @param space The space that the rotation should be in
  66103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66104. * @param result The quaternion that the rotation should be copied to
  66105. */
  66106. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66107. /**
  66108. * Get the rotation matrix of the bone in local or world space
  66109. * @param space The space that the rotation should be in
  66110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66111. * @returns The rotation matrix
  66112. */
  66113. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66114. /**
  66115. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66116. * @param space The space that the rotation should be in
  66117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66118. * @param result The quaternion that the rotation should be copied to
  66119. */
  66120. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66121. /**
  66122. * Get the world position of a point that is in the local space of the bone
  66123. * @param position The local position
  66124. * @param mesh The mesh that this bone is attached to
  66125. * @returns The world position
  66126. */
  66127. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66128. /**
  66129. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66130. * @param position The local position
  66131. * @param mesh The mesh that this bone is attached to
  66132. * @param result The vector3 that the world position should be copied to
  66133. */
  66134. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66135. /**
  66136. * Get the local position of a point that is in world space
  66137. * @param position The world position
  66138. * @param mesh The mesh that this bone is attached to
  66139. * @returns The local position
  66140. */
  66141. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66142. /**
  66143. * Get the local position of a point that is in world space and copy it to the result param
  66144. * @param position The world position
  66145. * @param mesh The mesh that this bone is attached to
  66146. * @param result The vector3 that the local position should be copied to
  66147. */
  66148. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66149. }
  66150. }
  66151. declare module BABYLON {
  66152. /**
  66153. * Class for creating a cube texture
  66154. */
  66155. export class CubeTexture extends BaseTexture {
  66156. private _delayedOnLoad;
  66157. /**
  66158. * The url of the texture
  66159. */
  66160. url: string;
  66161. /**
  66162. * Gets or sets the center of the bounding box associated with the cube texture.
  66163. * It must define where the camera used to render the texture was set
  66164. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66165. */
  66166. boundingBoxPosition: Vector3;
  66167. private _boundingBoxSize;
  66168. /**
  66169. * Gets or sets the size of the bounding box associated with the cube texture
  66170. * When defined, the cubemap will switch to local mode
  66171. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66172. * @example https://www.babylonjs-playground.com/#RNASML
  66173. */
  66174. /**
  66175. * Returns the bounding box size
  66176. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66177. */
  66178. boundingBoxSize: Vector3;
  66179. protected _rotationY: number;
  66180. /**
  66181. * Sets texture matrix rotation angle around Y axis in radians.
  66182. */
  66183. /**
  66184. * Gets texture matrix rotation angle around Y axis radians.
  66185. */
  66186. rotationY: number;
  66187. /**
  66188. * Are mip maps generated for this texture or not.
  66189. */
  66190. readonly noMipmap: boolean;
  66191. private _noMipmap;
  66192. private _files;
  66193. private _extensions;
  66194. private _textureMatrix;
  66195. private _format;
  66196. private _createPolynomials;
  66197. /** @hidden */
  66198. _prefiltered: boolean;
  66199. /**
  66200. * Creates a cube texture from an array of image urls
  66201. * @param files defines an array of image urls
  66202. * @param scene defines the hosting scene
  66203. * @param noMipmap specifies if mip maps are not used
  66204. * @returns a cube texture
  66205. */
  66206. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66207. /**
  66208. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66209. * @param url defines the url of the prefiltered texture
  66210. * @param scene defines the scene the texture is attached to
  66211. * @param forcedExtension defines the extension of the file if different from the url
  66212. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66213. * @return the prefiltered texture
  66214. */
  66215. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66216. /**
  66217. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66218. * as prefiltered data.
  66219. * @param rootUrl defines the url of the texture or the root name of the six images
  66220. * @param scene defines the scene the texture is attached to
  66221. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66222. * @param noMipmap defines if mipmaps should be created or not
  66223. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66224. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66225. * @param onError defines a callback triggered in case of error during load
  66226. * @param format defines the internal format to use for the texture once loaded
  66227. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66228. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66229. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66230. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66231. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66232. * @return the cube texture
  66233. */
  66234. 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);
  66235. /**
  66236. * Get the current class name of the texture useful for serialization or dynamic coding.
  66237. * @returns "CubeTexture"
  66238. */
  66239. getClassName(): string;
  66240. /**
  66241. * Update the url (and optional buffer) of this texture if url was null during construction.
  66242. * @param url the url of the texture
  66243. * @param forcedExtension defines the extension to use
  66244. * @param onLoad callback called when the texture is loaded (defaults to null)
  66245. */
  66246. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66247. /**
  66248. * Delays loading of the cube texture
  66249. * @param forcedExtension defines the extension to use
  66250. */
  66251. delayLoad(forcedExtension?: string): void;
  66252. /**
  66253. * Returns the reflection texture matrix
  66254. * @returns the reflection texture matrix
  66255. */
  66256. getReflectionTextureMatrix(): Matrix;
  66257. /**
  66258. * Sets the reflection texture matrix
  66259. * @param value Reflection texture matrix
  66260. */
  66261. setReflectionTextureMatrix(value: Matrix): void;
  66262. /**
  66263. * Parses text to create a cube texture
  66264. * @param parsedTexture define the serialized text to read from
  66265. * @param scene defines the hosting scene
  66266. * @param rootUrl defines the root url of the cube texture
  66267. * @returns a cube texture
  66268. */
  66269. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66270. /**
  66271. * Makes a clone, or deep copy, of the cube texture
  66272. * @returns a new cube texture
  66273. */
  66274. clone(): CubeTexture;
  66275. }
  66276. }
  66277. declare module BABYLON {
  66278. /** @hidden */
  66279. export var postprocessVertexShader: {
  66280. name: string;
  66281. shader: string;
  66282. };
  66283. }
  66284. declare module BABYLON {
  66285. /**
  66286. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66287. * This is the base of the follow, arc rotate cameras and Free camera
  66288. * @see http://doc.babylonjs.com/features/cameras
  66289. */
  66290. export class TargetCamera extends Camera {
  66291. private static _RigCamTransformMatrix;
  66292. private static _TargetTransformMatrix;
  66293. private static _TargetFocalPoint;
  66294. /**
  66295. * Define the current direction the camera is moving to
  66296. */
  66297. cameraDirection: Vector3;
  66298. /**
  66299. * Define the current rotation the camera is rotating to
  66300. */
  66301. cameraRotation: Vector2;
  66302. /**
  66303. * When set, the up vector of the camera will be updated by the rotation of the camera
  66304. */
  66305. updateUpVectorFromRotation: boolean;
  66306. private _tmpQuaternion;
  66307. /**
  66308. * Define the current rotation of the camera
  66309. */
  66310. rotation: Vector3;
  66311. /**
  66312. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66313. */
  66314. rotationQuaternion: Quaternion;
  66315. /**
  66316. * Define the current speed of the camera
  66317. */
  66318. speed: number;
  66319. /**
  66320. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66321. * around all axis.
  66322. */
  66323. noRotationConstraint: boolean;
  66324. /**
  66325. * Define the current target of the camera as an object or a position.
  66326. */
  66327. lockedTarget: any;
  66328. /** @hidden */
  66329. _currentTarget: Vector3;
  66330. /** @hidden */
  66331. _initialFocalDistance: number;
  66332. /** @hidden */
  66333. _viewMatrix: Matrix;
  66334. /** @hidden */
  66335. _camMatrix: Matrix;
  66336. /** @hidden */
  66337. _cameraTransformMatrix: Matrix;
  66338. /** @hidden */
  66339. _cameraRotationMatrix: Matrix;
  66340. /** @hidden */
  66341. _referencePoint: Vector3;
  66342. /** @hidden */
  66343. _transformedReferencePoint: Vector3;
  66344. protected _globalCurrentTarget: Vector3;
  66345. protected _globalCurrentUpVector: Vector3;
  66346. /** @hidden */
  66347. _reset: () => void;
  66348. private _defaultUp;
  66349. /**
  66350. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66351. * This is the base of the follow, arc rotate cameras and Free camera
  66352. * @see http://doc.babylonjs.com/features/cameras
  66353. * @param name Defines the name of the camera in the scene
  66354. * @param position Defines the start position of the camera in the scene
  66355. * @param scene Defines the scene the camera belongs to
  66356. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66357. */
  66358. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66359. /**
  66360. * Gets the position in front of the camera at a given distance.
  66361. * @param distance The distance from the camera we want the position to be
  66362. * @returns the position
  66363. */
  66364. getFrontPosition(distance: number): Vector3;
  66365. /** @hidden */
  66366. _getLockedTargetPosition(): Nullable<Vector3>;
  66367. private _storedPosition;
  66368. private _storedRotation;
  66369. private _storedRotationQuaternion;
  66370. /**
  66371. * Store current camera state of the camera (fov, position, rotation, etc..)
  66372. * @returns the camera
  66373. */
  66374. storeState(): Camera;
  66375. /**
  66376. * Restored camera state. You must call storeState() first
  66377. * @returns whether it was successful or not
  66378. * @hidden
  66379. */
  66380. _restoreStateValues(): boolean;
  66381. /** @hidden */
  66382. _initCache(): void;
  66383. /** @hidden */
  66384. _updateCache(ignoreParentClass?: boolean): void;
  66385. /** @hidden */
  66386. _isSynchronizedViewMatrix(): boolean;
  66387. /** @hidden */
  66388. _computeLocalCameraSpeed(): number;
  66389. /**
  66390. * Defines the target the camera should look at.
  66391. * This will automatically adapt alpha beta and radius to fit within the new target.
  66392. * @param target Defines the new target as a Vector or a mesh
  66393. */
  66394. setTarget(target: Vector3): void;
  66395. /**
  66396. * Return the current target position of the camera. This value is expressed in local space.
  66397. * @returns the target position
  66398. */
  66399. getTarget(): Vector3;
  66400. /** @hidden */
  66401. _decideIfNeedsToMove(): boolean;
  66402. /** @hidden */
  66403. _updatePosition(): void;
  66404. /** @hidden */
  66405. _checkInputs(): void;
  66406. protected _updateCameraRotationMatrix(): void;
  66407. /**
  66408. * 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)
  66409. * @returns the current camera
  66410. */
  66411. private _rotateUpVectorWithCameraRotationMatrix;
  66412. private _cachedRotationZ;
  66413. private _cachedQuaternionRotationZ;
  66414. /** @hidden */
  66415. _getViewMatrix(): Matrix;
  66416. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66417. /**
  66418. * @hidden
  66419. */
  66420. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66421. /**
  66422. * @hidden
  66423. */
  66424. _updateRigCameras(): void;
  66425. private _getRigCamPositionAndTarget;
  66426. /**
  66427. * Gets the current object class name.
  66428. * @return the class name
  66429. */
  66430. getClassName(): string;
  66431. }
  66432. }
  66433. declare module BABYLON {
  66434. /**
  66435. * @ignore
  66436. * This is a list of all the different input types that are available in the application.
  66437. * Fo instance: ArcRotateCameraGamepadInput...
  66438. */
  66439. export var CameraInputTypes: {};
  66440. /**
  66441. * This is the contract to implement in order to create a new input class.
  66442. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66443. */
  66444. export interface ICameraInput<TCamera extends Camera> {
  66445. /**
  66446. * Defines the camera the input is attached to.
  66447. */
  66448. camera: Nullable<TCamera>;
  66449. /**
  66450. * Gets the class name of the current intput.
  66451. * @returns the class name
  66452. */
  66453. getClassName(): string;
  66454. /**
  66455. * Get the friendly name associated with the input class.
  66456. * @returns the input friendly name
  66457. */
  66458. getSimpleName(): string;
  66459. /**
  66460. * Attach the input controls to a specific dom element to get the input from.
  66461. * @param element Defines the element the controls should be listened from
  66462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66463. */
  66464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66465. /**
  66466. * Detach the current controls from the specified dom element.
  66467. * @param element Defines the element to stop listening the inputs from
  66468. */
  66469. detachControl(element: Nullable<HTMLElement>): void;
  66470. /**
  66471. * Update the current camera state depending on the inputs that have been used this frame.
  66472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66473. */
  66474. checkInputs?: () => void;
  66475. }
  66476. /**
  66477. * Represents a map of input types to input instance or input index to input instance.
  66478. */
  66479. export interface CameraInputsMap<TCamera extends Camera> {
  66480. /**
  66481. * Accessor to the input by input type.
  66482. */
  66483. [name: string]: ICameraInput<TCamera>;
  66484. /**
  66485. * Accessor to the input by input index.
  66486. */
  66487. [idx: number]: ICameraInput<TCamera>;
  66488. }
  66489. /**
  66490. * This represents the input manager used within a camera.
  66491. * It helps dealing with all the different kind of input attached to a camera.
  66492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66493. */
  66494. export class CameraInputsManager<TCamera extends Camera> {
  66495. /**
  66496. * Defines the list of inputs attahed to the camera.
  66497. */
  66498. attached: CameraInputsMap<TCamera>;
  66499. /**
  66500. * Defines the dom element the camera is collecting inputs from.
  66501. * This is null if the controls have not been attached.
  66502. */
  66503. attachedElement: Nullable<HTMLElement>;
  66504. /**
  66505. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66506. */
  66507. noPreventDefault: boolean;
  66508. /**
  66509. * Defined the camera the input manager belongs to.
  66510. */
  66511. camera: TCamera;
  66512. /**
  66513. * Update the current camera state depending on the inputs that have been used this frame.
  66514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66515. */
  66516. checkInputs: () => void;
  66517. /**
  66518. * Instantiate a new Camera Input Manager.
  66519. * @param camera Defines the camera the input manager blongs to
  66520. */
  66521. constructor(camera: TCamera);
  66522. /**
  66523. * Add an input method to a camera
  66524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66525. * @param input camera input method
  66526. */
  66527. add(input: ICameraInput<TCamera>): void;
  66528. /**
  66529. * Remove a specific input method from a camera
  66530. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66531. * @param inputToRemove camera input method
  66532. */
  66533. remove(inputToRemove: ICameraInput<TCamera>): void;
  66534. /**
  66535. * Remove a specific input type from a camera
  66536. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66537. * @param inputType the type of the input to remove
  66538. */
  66539. removeByType(inputType: string): void;
  66540. private _addCheckInputs;
  66541. /**
  66542. * Attach the input controls to the currently attached dom element to listen the events from.
  66543. * @param input Defines the input to attach
  66544. */
  66545. attachInput(input: ICameraInput<TCamera>): void;
  66546. /**
  66547. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66548. * @param element Defines the dom element to collect the events from
  66549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66550. */
  66551. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66552. /**
  66553. * Detach the current manager inputs controls from a specific dom element.
  66554. * @param element Defines the dom element to collect the events from
  66555. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66556. */
  66557. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66558. /**
  66559. * Rebuild the dynamic inputCheck function from the current list of
  66560. * defined inputs in the manager.
  66561. */
  66562. rebuildInputCheck(): void;
  66563. /**
  66564. * Remove all attached input methods from a camera
  66565. */
  66566. clear(): void;
  66567. /**
  66568. * Serialize the current input manager attached to a camera.
  66569. * This ensures than once parsed,
  66570. * the input associated to the camera will be identical to the current ones
  66571. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66572. */
  66573. serialize(serializedCamera: any): void;
  66574. /**
  66575. * Parses an input manager serialized JSON to restore the previous list of inputs
  66576. * and states associated to a camera.
  66577. * @param parsedCamera Defines the JSON to parse
  66578. */
  66579. parse(parsedCamera: any): void;
  66580. }
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * Gather the list of keyboard event types as constants.
  66585. */
  66586. export class KeyboardEventTypes {
  66587. /**
  66588. * The keydown event is fired when a key becomes active (pressed).
  66589. */
  66590. static readonly KEYDOWN: number;
  66591. /**
  66592. * The keyup event is fired when a key has been released.
  66593. */
  66594. static readonly KEYUP: number;
  66595. }
  66596. /**
  66597. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66598. */
  66599. export class KeyboardInfo {
  66600. /**
  66601. * Defines the type of event (KeyboardEventTypes)
  66602. */
  66603. type: number;
  66604. /**
  66605. * Defines the related dom event
  66606. */
  66607. event: KeyboardEvent;
  66608. /**
  66609. * Instantiates a new keyboard info.
  66610. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66611. * @param type Defines the type of event (KeyboardEventTypes)
  66612. * @param event Defines the related dom event
  66613. */
  66614. constructor(
  66615. /**
  66616. * Defines the type of event (KeyboardEventTypes)
  66617. */
  66618. type: number,
  66619. /**
  66620. * Defines the related dom event
  66621. */
  66622. event: KeyboardEvent);
  66623. }
  66624. /**
  66625. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66626. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66627. */
  66628. export class KeyboardInfoPre extends KeyboardInfo {
  66629. /**
  66630. * Defines the type of event (KeyboardEventTypes)
  66631. */
  66632. type: number;
  66633. /**
  66634. * Defines the related dom event
  66635. */
  66636. event: KeyboardEvent;
  66637. /**
  66638. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66639. */
  66640. skipOnPointerObservable: boolean;
  66641. /**
  66642. * Instantiates a new keyboard pre info.
  66643. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66644. * @param type Defines the type of event (KeyboardEventTypes)
  66645. * @param event Defines the related dom event
  66646. */
  66647. constructor(
  66648. /**
  66649. * Defines the type of event (KeyboardEventTypes)
  66650. */
  66651. type: number,
  66652. /**
  66653. * Defines the related dom event
  66654. */
  66655. event: KeyboardEvent);
  66656. }
  66657. }
  66658. declare module BABYLON {
  66659. /**
  66660. * Manage the keyboard inputs to control the movement of a free camera.
  66661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66662. */
  66663. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66664. /**
  66665. * Defines the camera the input is attached to.
  66666. */
  66667. camera: FreeCamera;
  66668. /**
  66669. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66670. */
  66671. keysUp: number[];
  66672. /**
  66673. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66674. */
  66675. keysDown: number[];
  66676. /**
  66677. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66678. */
  66679. keysLeft: number[];
  66680. /**
  66681. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66682. */
  66683. keysRight: number[];
  66684. private _keys;
  66685. private _onCanvasBlurObserver;
  66686. private _onKeyboardObserver;
  66687. private _engine;
  66688. private _scene;
  66689. /**
  66690. * Attach the input controls to a specific dom element to get the input from.
  66691. * @param element Defines the element the controls should be listened from
  66692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66693. */
  66694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66695. /**
  66696. * Detach the current controls from the specified dom element.
  66697. * @param element Defines the element to stop listening the inputs from
  66698. */
  66699. detachControl(element: Nullable<HTMLElement>): void;
  66700. /**
  66701. * Update the current camera state depending on the inputs that have been used this frame.
  66702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66703. */
  66704. checkInputs(): void;
  66705. /**
  66706. * Gets the class name of the current intput.
  66707. * @returns the class name
  66708. */
  66709. getClassName(): string;
  66710. /** @hidden */
  66711. _onLostFocus(): void;
  66712. /**
  66713. * Get the friendly name associated with the input class.
  66714. * @returns the input friendly name
  66715. */
  66716. getSimpleName(): string;
  66717. }
  66718. }
  66719. declare module BABYLON {
  66720. /**
  66721. * Interface describing all the common properties and methods a shadow light needs to implement.
  66722. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66723. * as well as binding the different shadow properties to the effects.
  66724. */
  66725. export interface IShadowLight extends Light {
  66726. /**
  66727. * The light id in the scene (used in scene.findLighById for instance)
  66728. */
  66729. id: string;
  66730. /**
  66731. * The position the shdow will be casted from.
  66732. */
  66733. position: Vector3;
  66734. /**
  66735. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66736. */
  66737. direction: Vector3;
  66738. /**
  66739. * The transformed position. Position of the light in world space taking parenting in account.
  66740. */
  66741. transformedPosition: Vector3;
  66742. /**
  66743. * The transformed direction. Direction of the light in world space taking parenting in account.
  66744. */
  66745. transformedDirection: Vector3;
  66746. /**
  66747. * The friendly name of the light in the scene.
  66748. */
  66749. name: string;
  66750. /**
  66751. * Defines the shadow projection clipping minimum z value.
  66752. */
  66753. shadowMinZ: number;
  66754. /**
  66755. * Defines the shadow projection clipping maximum z value.
  66756. */
  66757. shadowMaxZ: number;
  66758. /**
  66759. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66760. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66761. */
  66762. computeTransformedInformation(): boolean;
  66763. /**
  66764. * Gets the scene the light belongs to.
  66765. * @returns The scene
  66766. */
  66767. getScene(): Scene;
  66768. /**
  66769. * Callback defining a custom Projection Matrix Builder.
  66770. * This can be used to override the default projection matrix computation.
  66771. */
  66772. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66773. /**
  66774. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66775. * @param matrix The materix to updated with the projection information
  66776. * @param viewMatrix The transform matrix of the light
  66777. * @param renderList The list of mesh to render in the map
  66778. * @returns The current light
  66779. */
  66780. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66781. /**
  66782. * Gets the current depth scale used in ESM.
  66783. * @returns The scale
  66784. */
  66785. getDepthScale(): number;
  66786. /**
  66787. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66788. * @returns true if a cube texture needs to be use
  66789. */
  66790. needCube(): boolean;
  66791. /**
  66792. * Detects if the projection matrix requires to be recomputed this frame.
  66793. * @returns true if it requires to be recomputed otherwise, false.
  66794. */
  66795. needProjectionMatrixCompute(): boolean;
  66796. /**
  66797. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66798. */
  66799. forceProjectionMatrixCompute(): void;
  66800. /**
  66801. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66802. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66803. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66804. */
  66805. getShadowDirection(faceIndex?: number): Vector3;
  66806. /**
  66807. * Gets the minZ used for shadow according to both the scene and the light.
  66808. * @param activeCamera The camera we are returning the min for
  66809. * @returns the depth min z
  66810. */
  66811. getDepthMinZ(activeCamera: Camera): number;
  66812. /**
  66813. * Gets the maxZ used for shadow according to both the scene and the light.
  66814. * @param activeCamera The camera we are returning the max for
  66815. * @returns the depth max z
  66816. */
  66817. getDepthMaxZ(activeCamera: Camera): number;
  66818. }
  66819. /**
  66820. * Base implementation IShadowLight
  66821. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66822. */
  66823. export abstract class ShadowLight extends Light implements IShadowLight {
  66824. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66825. protected _position: Vector3;
  66826. protected _setPosition(value: Vector3): void;
  66827. /**
  66828. * Sets the position the shadow will be casted from. Also use as the light position for both
  66829. * point and spot lights.
  66830. */
  66831. /**
  66832. * Sets the position the shadow will be casted from. Also use as the light position for both
  66833. * point and spot lights.
  66834. */
  66835. position: Vector3;
  66836. protected _direction: Vector3;
  66837. protected _setDirection(value: Vector3): void;
  66838. /**
  66839. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66840. * Also use as the light direction on spot and directional lights.
  66841. */
  66842. /**
  66843. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66844. * Also use as the light direction on spot and directional lights.
  66845. */
  66846. direction: Vector3;
  66847. private _shadowMinZ;
  66848. /**
  66849. * Gets the shadow projection clipping minimum z value.
  66850. */
  66851. /**
  66852. * Sets the shadow projection clipping minimum z value.
  66853. */
  66854. shadowMinZ: number;
  66855. private _shadowMaxZ;
  66856. /**
  66857. * Sets the shadow projection clipping maximum z value.
  66858. */
  66859. /**
  66860. * Gets the shadow projection clipping maximum z value.
  66861. */
  66862. shadowMaxZ: number;
  66863. /**
  66864. * Callback defining a custom Projection Matrix Builder.
  66865. * This can be used to override the default projection matrix computation.
  66866. */
  66867. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66868. /**
  66869. * The transformed position. Position of the light in world space taking parenting in account.
  66870. */
  66871. transformedPosition: Vector3;
  66872. /**
  66873. * The transformed direction. Direction of the light in world space taking parenting in account.
  66874. */
  66875. transformedDirection: Vector3;
  66876. private _needProjectionMatrixCompute;
  66877. /**
  66878. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66879. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66880. */
  66881. computeTransformedInformation(): boolean;
  66882. /**
  66883. * Return the depth scale used for the shadow map.
  66884. * @returns the depth scale.
  66885. */
  66886. getDepthScale(): number;
  66887. /**
  66888. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66889. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66890. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66891. */
  66892. getShadowDirection(faceIndex?: number): Vector3;
  66893. /**
  66894. * Returns the ShadowLight absolute position in the World.
  66895. * @returns the position vector in world space
  66896. */
  66897. getAbsolutePosition(): Vector3;
  66898. /**
  66899. * Sets the ShadowLight direction toward the passed target.
  66900. * @param target The point to target in local space
  66901. * @returns the updated ShadowLight direction
  66902. */
  66903. setDirectionToTarget(target: Vector3): Vector3;
  66904. /**
  66905. * Returns the light rotation in euler definition.
  66906. * @returns the x y z rotation in local space.
  66907. */
  66908. getRotation(): Vector3;
  66909. /**
  66910. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66911. * @returns true if a cube texture needs to be use
  66912. */
  66913. needCube(): boolean;
  66914. /**
  66915. * Detects if the projection matrix requires to be recomputed this frame.
  66916. * @returns true if it requires to be recomputed otherwise, false.
  66917. */
  66918. needProjectionMatrixCompute(): boolean;
  66919. /**
  66920. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66921. */
  66922. forceProjectionMatrixCompute(): void;
  66923. /** @hidden */
  66924. _initCache(): void;
  66925. /** @hidden */
  66926. _isSynchronized(): boolean;
  66927. /**
  66928. * Computes the world matrix of the node
  66929. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66930. * @returns the world matrix
  66931. */
  66932. computeWorldMatrix(force?: boolean): Matrix;
  66933. /**
  66934. * Gets the minZ used for shadow according to both the scene and the light.
  66935. * @param activeCamera The camera we are returning the min for
  66936. * @returns the depth min z
  66937. */
  66938. getDepthMinZ(activeCamera: Camera): number;
  66939. /**
  66940. * Gets the maxZ used for shadow according to both the scene and the light.
  66941. * @param activeCamera The camera we are returning the max for
  66942. * @returns the depth max z
  66943. */
  66944. getDepthMaxZ(activeCamera: Camera): number;
  66945. /**
  66946. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66947. * @param matrix The materix to updated with the projection information
  66948. * @param viewMatrix The transform matrix of the light
  66949. * @param renderList The list of mesh to render in the map
  66950. * @returns The current light
  66951. */
  66952. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66953. }
  66954. }
  66955. declare module BABYLON {
  66956. /**
  66957. * "Static Class" containing the most commonly used helper while dealing with material for
  66958. * rendering purpose.
  66959. *
  66960. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66961. *
  66962. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66963. */
  66964. export class MaterialHelper {
  66965. /**
  66966. * Bind the current view position to an effect.
  66967. * @param effect The effect to be bound
  66968. * @param scene The scene the eyes position is used from
  66969. */
  66970. static BindEyePosition(effect: Effect, scene: Scene): void;
  66971. /**
  66972. * Helps preparing the defines values about the UVs in used in the effect.
  66973. * UVs are shared as much as we can accross channels in the shaders.
  66974. * @param texture The texture we are preparing the UVs for
  66975. * @param defines The defines to update
  66976. * @param key The channel key "diffuse", "specular"... used in the shader
  66977. */
  66978. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66979. /**
  66980. * Binds a texture matrix value to its corrsponding uniform
  66981. * @param texture The texture to bind the matrix for
  66982. * @param uniformBuffer The uniform buffer receivin the data
  66983. * @param key The channel key "diffuse", "specular"... used in the shader
  66984. */
  66985. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66986. /**
  66987. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66988. * @param mesh defines the current mesh
  66989. * @param scene defines the current scene
  66990. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66991. * @param pointsCloud defines if point cloud rendering has to be turned on
  66992. * @param fogEnabled defines if fog has to be turned on
  66993. * @param alphaTest defines if alpha testing has to be turned on
  66994. * @param defines defines the current list of defines
  66995. */
  66996. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66997. /**
  66998. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66999. * @param scene defines the current scene
  67000. * @param engine defines the current engine
  67001. * @param defines specifies the list of active defines
  67002. * @param useInstances defines if instances have to be turned on
  67003. * @param useClipPlane defines if clip plane have to be turned on
  67004. */
  67005. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67006. /**
  67007. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67008. * @param mesh The mesh containing the geometry data we will draw
  67009. * @param defines The defines to update
  67010. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67011. * @param useBones Precise whether bones should be used or not (override mesh info)
  67012. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67013. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67014. * @returns false if defines are considered not dirty and have not been checked
  67015. */
  67016. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67017. /**
  67018. * Prepares the defines related to the light information passed in parameter
  67019. * @param scene The scene we are intending to draw
  67020. * @param mesh The mesh the effect is compiling for
  67021. * @param defines The defines to update
  67022. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67023. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67024. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67025. * @returns true if normals will be required for the rest of the effect
  67026. */
  67027. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67028. /**
  67029. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67030. * that won t be acctive due to defines being turned off.
  67031. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67032. * @param samplersList The samplers list
  67033. * @param defines The defines helping in the list generation
  67034. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67035. */
  67036. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67037. /**
  67038. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67039. * @param defines The defines to update while falling back
  67040. * @param fallbacks The authorized effect fallbacks
  67041. * @param maxSimultaneousLights The maximum number of lights allowed
  67042. * @param rank the current rank of the Effect
  67043. * @returns The newly affected rank
  67044. */
  67045. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67046. /**
  67047. * Prepares the list of attributes required for morph targets according to the effect defines.
  67048. * @param attribs The current list of supported attribs
  67049. * @param mesh The mesh to prepare the morph targets attributes for
  67050. * @param defines The current Defines of the effect
  67051. */
  67052. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67053. /**
  67054. * Prepares the list of attributes required for bones according to the effect defines.
  67055. * @param attribs The current list of supported attribs
  67056. * @param mesh The mesh to prepare the bones attributes for
  67057. * @param defines The current Defines of the effect
  67058. * @param fallbacks The current efffect fallback strategy
  67059. */
  67060. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67061. /**
  67062. * Prepares the list of attributes required for instances according to the effect defines.
  67063. * @param attribs The current list of supported attribs
  67064. * @param defines The current Defines of the effect
  67065. */
  67066. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67067. /**
  67068. * Binds the light shadow information to the effect for the given mesh.
  67069. * @param light The light containing the generator
  67070. * @param scene The scene the lights belongs to
  67071. * @param mesh The mesh we are binding the information to render
  67072. * @param lightIndex The light index in the effect used to render the mesh
  67073. * @param effect The effect we are binding the data to
  67074. */
  67075. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67076. /**
  67077. * Binds the light information to the effect.
  67078. * @param light The light containing the generator
  67079. * @param effect The effect we are binding the data to
  67080. * @param lightIndex The light index in the effect used to render
  67081. */
  67082. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67083. /**
  67084. * Binds the lights information from the scene to the effect for the given mesh.
  67085. * @param scene The scene the lights belongs to
  67086. * @param mesh The mesh we are binding the information to render
  67087. * @param effect The effect we are binding the data to
  67088. * @param defines The generated defines for the effect
  67089. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67090. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67091. */
  67092. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67093. private static _tempFogColor;
  67094. /**
  67095. * Binds the fog information from the scene to the effect for the given mesh.
  67096. * @param scene The scene the lights belongs to
  67097. * @param mesh The mesh we are binding the information to render
  67098. * @param effect The effect we are binding the data to
  67099. * @param linearSpace Defines if the fog effect is applied in linear space
  67100. */
  67101. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67102. /**
  67103. * Binds the bones information from the mesh to the effect.
  67104. * @param mesh The mesh we are binding the information to render
  67105. * @param effect The effect we are binding the data to
  67106. */
  67107. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67108. /**
  67109. * Binds the morph targets information from the mesh to the effect.
  67110. * @param abstractMesh The mesh we are binding the information to render
  67111. * @param effect The effect we are binding the data to
  67112. */
  67113. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67114. /**
  67115. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67116. * @param defines The generated defines used in the effect
  67117. * @param effect The effect we are binding the data to
  67118. * @param scene The scene we are willing to render with logarithmic scale for
  67119. */
  67120. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67121. /**
  67122. * Binds the clip plane information from the scene to the effect.
  67123. * @param scene The scene the clip plane information are extracted from
  67124. * @param effect The effect we are binding the data to
  67125. */
  67126. static BindClipPlane(effect: Effect, scene: Scene): void;
  67127. }
  67128. }
  67129. declare module BABYLON {
  67130. /** @hidden */
  67131. export var kernelBlurVaryingDeclaration: {
  67132. name: string;
  67133. shader: string;
  67134. };
  67135. }
  67136. declare module BABYLON {
  67137. /** @hidden */
  67138. export var kernelBlurFragment: {
  67139. name: string;
  67140. shader: string;
  67141. };
  67142. }
  67143. declare module BABYLON {
  67144. /** @hidden */
  67145. export var kernelBlurFragment2: {
  67146. name: string;
  67147. shader: string;
  67148. };
  67149. }
  67150. declare module BABYLON {
  67151. /** @hidden */
  67152. export var kernelBlurPixelShader: {
  67153. name: string;
  67154. shader: string;
  67155. };
  67156. }
  67157. declare module BABYLON {
  67158. /** @hidden */
  67159. export var kernelBlurVertex: {
  67160. name: string;
  67161. shader: string;
  67162. };
  67163. }
  67164. declare module BABYLON {
  67165. /** @hidden */
  67166. export var kernelBlurVertexShader: {
  67167. name: string;
  67168. shader: string;
  67169. };
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * The Blur Post Process which blurs an image based on a kernel and direction.
  67174. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67175. */
  67176. export class BlurPostProcess extends PostProcess {
  67177. /** The direction in which to blur the image. */
  67178. direction: Vector2;
  67179. private blockCompilation;
  67180. protected _kernel: number;
  67181. protected _idealKernel: number;
  67182. protected _packedFloat: boolean;
  67183. private _staticDefines;
  67184. /**
  67185. * Sets the length in pixels of the blur sample region
  67186. */
  67187. /**
  67188. * Gets the length in pixels of the blur sample region
  67189. */
  67190. kernel: number;
  67191. /**
  67192. * Sets wether or not the blur needs to unpack/repack floats
  67193. */
  67194. /**
  67195. * Gets wether or not the blur is unpacking/repacking floats
  67196. */
  67197. packedFloat: boolean;
  67198. /**
  67199. * Creates a new instance BlurPostProcess
  67200. * @param name The name of the effect.
  67201. * @param direction The direction in which to blur the image.
  67202. * @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.
  67203. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67204. * @param camera The camera to apply the render pass to.
  67205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67206. * @param engine The engine which the post process will be applied. (default: current engine)
  67207. * @param reusable If the post process can be reused on the same frame. (default: false)
  67208. * @param textureType Type of textures used when performing the post process. (default: 0)
  67209. * @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)
  67210. */
  67211. constructor(name: string,
  67212. /** The direction in which to blur the image. */
  67213. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67214. /**
  67215. * Updates the effect with the current post process compile time values and recompiles the shader.
  67216. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67217. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67218. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67219. * @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
  67220. * @param onCompiled Called when the shader has been compiled.
  67221. * @param onError Called if there is an error when compiling a shader.
  67222. */
  67223. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67224. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67225. /**
  67226. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67227. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67228. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67229. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67230. * The gaps between physical kernels are compensated for in the weighting of the samples
  67231. * @param idealKernel Ideal blur kernel.
  67232. * @return Nearest best kernel.
  67233. */
  67234. protected _nearestBestKernel(idealKernel: number): number;
  67235. /**
  67236. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67237. * @param x The point on the Gaussian distribution to sample.
  67238. * @return the value of the Gaussian function at x.
  67239. */
  67240. protected _gaussianWeight(x: number): number;
  67241. /**
  67242. * Generates a string that can be used as a floating point number in GLSL.
  67243. * @param x Value to print.
  67244. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67245. * @return GLSL float string.
  67246. */
  67247. protected _glslFloat(x: number, decimalFigures?: number): string;
  67248. }
  67249. }
  67250. declare module BABYLON {
  67251. /** @hidden */
  67252. export var shadowMapPixelShader: {
  67253. name: string;
  67254. shader: string;
  67255. };
  67256. }
  67257. declare module BABYLON {
  67258. /** @hidden */
  67259. export var bonesDeclaration: {
  67260. name: string;
  67261. shader: string;
  67262. };
  67263. }
  67264. declare module BABYLON {
  67265. /** @hidden */
  67266. export var morphTargetsVertexGlobalDeclaration: {
  67267. name: string;
  67268. shader: string;
  67269. };
  67270. }
  67271. declare module BABYLON {
  67272. /** @hidden */
  67273. export var morphTargetsVertexDeclaration: {
  67274. name: string;
  67275. shader: string;
  67276. };
  67277. }
  67278. declare module BABYLON {
  67279. /** @hidden */
  67280. export var instancesDeclaration: {
  67281. name: string;
  67282. shader: string;
  67283. };
  67284. }
  67285. declare module BABYLON {
  67286. /** @hidden */
  67287. export var helperFunctions: {
  67288. name: string;
  67289. shader: string;
  67290. };
  67291. }
  67292. declare module BABYLON {
  67293. /** @hidden */
  67294. export var morphTargetsVertex: {
  67295. name: string;
  67296. shader: string;
  67297. };
  67298. }
  67299. declare module BABYLON {
  67300. /** @hidden */
  67301. export var instancesVertex: {
  67302. name: string;
  67303. shader: string;
  67304. };
  67305. }
  67306. declare module BABYLON {
  67307. /** @hidden */
  67308. export var bonesVertex: {
  67309. name: string;
  67310. shader: string;
  67311. };
  67312. }
  67313. declare module BABYLON {
  67314. /** @hidden */
  67315. export var shadowMapVertexShader: {
  67316. name: string;
  67317. shader: string;
  67318. };
  67319. }
  67320. declare module BABYLON {
  67321. /** @hidden */
  67322. export var depthBoxBlurPixelShader: {
  67323. name: string;
  67324. shader: string;
  67325. };
  67326. }
  67327. declare module BABYLON {
  67328. /**
  67329. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67330. */
  67331. export interface ICustomShaderOptions {
  67332. /**
  67333. * Gets or sets the custom shader name to use
  67334. */
  67335. shaderName: string;
  67336. /**
  67337. * The list of attribute names used in the shader
  67338. */
  67339. attributes?: string[];
  67340. /**
  67341. * The list of unifrom names used in the shader
  67342. */
  67343. uniforms?: string[];
  67344. /**
  67345. * The list of sampler names used in the shader
  67346. */
  67347. samplers?: string[];
  67348. /**
  67349. * The list of defines used in the shader
  67350. */
  67351. defines?: string[];
  67352. }
  67353. /**
  67354. * Interface to implement to create a shadow generator compatible with BJS.
  67355. */
  67356. export interface IShadowGenerator {
  67357. /**
  67358. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67359. * @returns The render target texture if present otherwise, null
  67360. */
  67361. getShadowMap(): Nullable<RenderTargetTexture>;
  67362. /**
  67363. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67364. * @returns The render target texture if the shadow map is present otherwise, null
  67365. */
  67366. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67367. /**
  67368. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67369. * @param subMesh The submesh we want to render in the shadow map
  67370. * @param useInstances Defines wether will draw in the map using instances
  67371. * @returns true if ready otherwise, false
  67372. */
  67373. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67374. /**
  67375. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67376. * @param defines Defines of the material we want to update
  67377. * @param lightIndex Index of the light in the enabled light list of the material
  67378. */
  67379. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67380. /**
  67381. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67382. * defined in the generator but impacting the effect).
  67383. * It implies the unifroms available on the materials are the standard BJS ones.
  67384. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67385. * @param effect The effect we are binfing the information for
  67386. */
  67387. bindShadowLight(lightIndex: string, effect: Effect): void;
  67388. /**
  67389. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67390. * (eq to shadow prjection matrix * light transform matrix)
  67391. * @returns The transform matrix used to create the shadow map
  67392. */
  67393. getTransformMatrix(): Matrix;
  67394. /**
  67395. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67396. * Cube and 2D textures for instance.
  67397. */
  67398. recreateShadowMap(): void;
  67399. /**
  67400. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67401. * @param onCompiled Callback triggered at the and of the effects compilation
  67402. * @param options Sets of optional options forcing the compilation with different modes
  67403. */
  67404. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67405. useInstances: boolean;
  67406. }>): void;
  67407. /**
  67408. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67409. * @param options Sets of optional options forcing the compilation with different modes
  67410. * @returns A promise that resolves when the compilation completes
  67411. */
  67412. forceCompilationAsync(options?: Partial<{
  67413. useInstances: boolean;
  67414. }>): Promise<void>;
  67415. /**
  67416. * Serializes the shadow generator setup to a json object.
  67417. * @returns The serialized JSON object
  67418. */
  67419. serialize(): any;
  67420. /**
  67421. * Disposes the Shadow map and related Textures and effects.
  67422. */
  67423. dispose(): void;
  67424. }
  67425. /**
  67426. * Default implementation IShadowGenerator.
  67427. * This is the main object responsible of generating shadows in the framework.
  67428. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67429. */
  67430. export class ShadowGenerator implements IShadowGenerator {
  67431. /**
  67432. * Shadow generator mode None: no filtering applied.
  67433. */
  67434. static readonly FILTER_NONE: number;
  67435. /**
  67436. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67437. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67438. */
  67439. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67440. /**
  67441. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67442. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67443. */
  67444. static readonly FILTER_POISSONSAMPLING: number;
  67445. /**
  67446. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67447. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67448. */
  67449. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67450. /**
  67451. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67452. * edge artifacts on steep falloff.
  67453. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67454. */
  67455. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67456. /**
  67457. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67458. * edge artifacts on steep falloff.
  67459. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67460. */
  67461. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67462. /**
  67463. * Shadow generator mode PCF: Percentage Closer Filtering
  67464. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67465. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67466. */
  67467. static readonly FILTER_PCF: number;
  67468. /**
  67469. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67470. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67471. * Contact Hardening
  67472. */
  67473. static readonly FILTER_PCSS: number;
  67474. /**
  67475. * Reserved for PCF and PCSS
  67476. * Highest Quality.
  67477. *
  67478. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67479. *
  67480. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67481. */
  67482. static readonly QUALITY_HIGH: number;
  67483. /**
  67484. * Reserved for PCF and PCSS
  67485. * Good tradeoff for quality/perf cross devices
  67486. *
  67487. * Execute PCF on a 3*3 kernel.
  67488. *
  67489. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67490. */
  67491. static readonly QUALITY_MEDIUM: number;
  67492. /**
  67493. * Reserved for PCF and PCSS
  67494. * The lowest quality but the fastest.
  67495. *
  67496. * Execute PCF on a 1*1 kernel.
  67497. *
  67498. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67499. */
  67500. static readonly QUALITY_LOW: number;
  67501. /** Gets or sets the custom shader name to use */
  67502. customShaderOptions: ICustomShaderOptions;
  67503. /**
  67504. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67505. */
  67506. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67507. /**
  67508. * Observable triggered before a mesh is rendered in the shadow map.
  67509. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67510. */
  67511. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67512. private _bias;
  67513. /**
  67514. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67515. */
  67516. /**
  67517. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67518. */
  67519. bias: number;
  67520. private _normalBias;
  67521. /**
  67522. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67523. */
  67524. /**
  67525. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67526. */
  67527. normalBias: number;
  67528. private _blurBoxOffset;
  67529. /**
  67530. * Gets the blur box offset: offset applied during the blur pass.
  67531. * Only useful if useKernelBlur = false
  67532. */
  67533. /**
  67534. * Sets the blur box offset: offset applied during the blur pass.
  67535. * Only useful if useKernelBlur = false
  67536. */
  67537. blurBoxOffset: number;
  67538. private _blurScale;
  67539. /**
  67540. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67541. * 2 means half of the size.
  67542. */
  67543. /**
  67544. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67545. * 2 means half of the size.
  67546. */
  67547. blurScale: number;
  67548. private _blurKernel;
  67549. /**
  67550. * Gets the blur kernel: kernel size of the blur pass.
  67551. * Only useful if useKernelBlur = true
  67552. */
  67553. /**
  67554. * Sets the blur kernel: kernel size of the blur pass.
  67555. * Only useful if useKernelBlur = true
  67556. */
  67557. blurKernel: number;
  67558. private _useKernelBlur;
  67559. /**
  67560. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67561. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67562. */
  67563. /**
  67564. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67565. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67566. */
  67567. useKernelBlur: boolean;
  67568. private _depthScale;
  67569. /**
  67570. * Gets the depth scale used in ESM mode.
  67571. */
  67572. /**
  67573. * Sets the depth scale used in ESM mode.
  67574. * This can override the scale stored on the light.
  67575. */
  67576. depthScale: number;
  67577. private _filter;
  67578. /**
  67579. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67580. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67581. */
  67582. /**
  67583. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67584. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67585. */
  67586. filter: number;
  67587. /**
  67588. * Gets if the current filter is set to Poisson Sampling.
  67589. */
  67590. /**
  67591. * Sets the current filter to Poisson Sampling.
  67592. */
  67593. usePoissonSampling: boolean;
  67594. /**
  67595. * Gets if the current filter is set to ESM.
  67596. */
  67597. /**
  67598. * Sets the current filter is to ESM.
  67599. */
  67600. useExponentialShadowMap: boolean;
  67601. /**
  67602. * Gets if the current filter is set to filtered ESM.
  67603. */
  67604. /**
  67605. * Gets if the current filter is set to filtered ESM.
  67606. */
  67607. useBlurExponentialShadowMap: boolean;
  67608. /**
  67609. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67610. * exponential to prevent steep falloff artifacts).
  67611. */
  67612. /**
  67613. * Sets the current filter to "close ESM" (using the inverse of the
  67614. * exponential to prevent steep falloff artifacts).
  67615. */
  67616. useCloseExponentialShadowMap: boolean;
  67617. /**
  67618. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67619. * exponential to prevent steep falloff artifacts).
  67620. */
  67621. /**
  67622. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67623. * exponential to prevent steep falloff artifacts).
  67624. */
  67625. useBlurCloseExponentialShadowMap: boolean;
  67626. /**
  67627. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67628. */
  67629. /**
  67630. * Sets the current filter to "PCF" (percentage closer filtering).
  67631. */
  67632. usePercentageCloserFiltering: boolean;
  67633. private _filteringQuality;
  67634. /**
  67635. * Gets the PCF or PCSS Quality.
  67636. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67637. */
  67638. /**
  67639. * Sets the PCF or PCSS Quality.
  67640. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67641. */
  67642. filteringQuality: number;
  67643. /**
  67644. * Gets if the current filter is set to "PCSS" (contact hardening).
  67645. */
  67646. /**
  67647. * Sets the current filter to "PCSS" (contact hardening).
  67648. */
  67649. useContactHardeningShadow: boolean;
  67650. private _contactHardeningLightSizeUVRatio;
  67651. /**
  67652. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67653. * Using a ratio helps keeping shape stability independently of the map size.
  67654. *
  67655. * It does not account for the light projection as it was having too much
  67656. * instability during the light setup or during light position changes.
  67657. *
  67658. * Only valid if useContactHardeningShadow is true.
  67659. */
  67660. /**
  67661. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67662. * Using a ratio helps keeping shape stability independently of the map size.
  67663. *
  67664. * It does not account for the light projection as it was having too much
  67665. * instability during the light setup or during light position changes.
  67666. *
  67667. * Only valid if useContactHardeningShadow is true.
  67668. */
  67669. contactHardeningLightSizeUVRatio: number;
  67670. private _darkness;
  67671. /**
  67672. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67673. * 0 means strongest and 1 would means no shadow.
  67674. * @returns the darkness.
  67675. */
  67676. getDarkness(): number;
  67677. /**
  67678. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67679. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67680. * @returns the shadow generator allowing fluent coding.
  67681. */
  67682. setDarkness(darkness: number): ShadowGenerator;
  67683. private _transparencyShadow;
  67684. /**
  67685. * Sets the ability to have transparent shadow (boolean).
  67686. * @param transparent True if transparent else False
  67687. * @returns the shadow generator allowing fluent coding
  67688. */
  67689. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67690. private _shadowMap;
  67691. private _shadowMap2;
  67692. /**
  67693. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67694. * @returns The render target texture if present otherwise, null
  67695. */
  67696. getShadowMap(): Nullable<RenderTargetTexture>;
  67697. /**
  67698. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67699. * @returns The render target texture if the shadow map is present otherwise, null
  67700. */
  67701. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67702. /**
  67703. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67704. * @param mesh Mesh to add
  67705. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67706. * @returns the Shadow Generator itself
  67707. */
  67708. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67709. /**
  67710. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67711. * @param mesh Mesh to remove
  67712. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67713. * @returns the Shadow Generator itself
  67714. */
  67715. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67716. /**
  67717. * Controls the extent to which the shadows fade out at the edge of the frustum
  67718. * Used only by directionals and spots
  67719. */
  67720. frustumEdgeFalloff: number;
  67721. private _light;
  67722. /**
  67723. * Returns the associated light object.
  67724. * @returns the light generating the shadow
  67725. */
  67726. getLight(): IShadowLight;
  67727. /**
  67728. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67729. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67730. * It might on the other hand introduce peter panning.
  67731. */
  67732. forceBackFacesOnly: boolean;
  67733. private _scene;
  67734. private _lightDirection;
  67735. private _effect;
  67736. private _viewMatrix;
  67737. private _projectionMatrix;
  67738. private _transformMatrix;
  67739. private _cachedPosition;
  67740. private _cachedDirection;
  67741. private _cachedDefines;
  67742. private _currentRenderID;
  67743. private _boxBlurPostprocess;
  67744. private _kernelBlurXPostprocess;
  67745. private _kernelBlurYPostprocess;
  67746. private _blurPostProcesses;
  67747. private _mapSize;
  67748. private _currentFaceIndex;
  67749. private _currentFaceIndexCache;
  67750. private _textureType;
  67751. private _defaultTextureMatrix;
  67752. /** @hidden */
  67753. static _SceneComponentInitialization: (scene: Scene) => void;
  67754. /**
  67755. * Creates a ShadowGenerator object.
  67756. * A ShadowGenerator is the required tool to use the shadows.
  67757. * Each light casting shadows needs to use its own ShadowGenerator.
  67758. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67759. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67760. * @param light The light object generating the shadows.
  67761. * @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.
  67762. */
  67763. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67764. private _initializeGenerator;
  67765. private _initializeShadowMap;
  67766. private _initializeBlurRTTAndPostProcesses;
  67767. private _renderForShadowMap;
  67768. private _renderSubMeshForShadowMap;
  67769. private _applyFilterValues;
  67770. /**
  67771. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67772. * @param onCompiled Callback triggered at the and of the effects compilation
  67773. * @param options Sets of optional options forcing the compilation with different modes
  67774. */
  67775. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67776. useInstances: boolean;
  67777. }>): void;
  67778. /**
  67779. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67780. * @param options Sets of optional options forcing the compilation with different modes
  67781. * @returns A promise that resolves when the compilation completes
  67782. */
  67783. forceCompilationAsync(options?: Partial<{
  67784. useInstances: boolean;
  67785. }>): Promise<void>;
  67786. /**
  67787. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67788. * @param subMesh The submesh we want to render in the shadow map
  67789. * @param useInstances Defines wether will draw in the map using instances
  67790. * @returns true if ready otherwise, false
  67791. */
  67792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67793. /**
  67794. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67795. * @param defines Defines of the material we want to update
  67796. * @param lightIndex Index of the light in the enabled light list of the material
  67797. */
  67798. prepareDefines(defines: any, lightIndex: number): void;
  67799. /**
  67800. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67801. * defined in the generator but impacting the effect).
  67802. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67803. * @param effect The effect we are binfing the information for
  67804. */
  67805. bindShadowLight(lightIndex: string, effect: Effect): void;
  67806. /**
  67807. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67808. * (eq to shadow prjection matrix * light transform matrix)
  67809. * @returns The transform matrix used to create the shadow map
  67810. */
  67811. getTransformMatrix(): Matrix;
  67812. /**
  67813. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67814. * Cube and 2D textures for instance.
  67815. */
  67816. recreateShadowMap(): void;
  67817. private _disposeBlurPostProcesses;
  67818. private _disposeRTTandPostProcesses;
  67819. /**
  67820. * Disposes the ShadowGenerator.
  67821. * Returns nothing.
  67822. */
  67823. dispose(): void;
  67824. /**
  67825. * Serializes the shadow generator setup to a json object.
  67826. * @returns The serialized JSON object
  67827. */
  67828. serialize(): any;
  67829. /**
  67830. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67831. * @param parsedShadowGenerator The JSON object to parse
  67832. * @param scene The scene to create the shadow map for
  67833. * @returns The parsed shadow generator
  67834. */
  67835. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /**
  67840. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67841. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67842. * 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.
  67843. */
  67844. export abstract class Light extends Node {
  67845. /**
  67846. * Falloff Default: light is falling off following the material specification:
  67847. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67848. */
  67849. static readonly FALLOFF_DEFAULT: number;
  67850. /**
  67851. * Falloff Physical: light is falling off following the inverse squared distance law.
  67852. */
  67853. static readonly FALLOFF_PHYSICAL: number;
  67854. /**
  67855. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67856. * to enhance interoperability with other engines.
  67857. */
  67858. static readonly FALLOFF_GLTF: number;
  67859. /**
  67860. * Falloff Standard: light is falling off like in the standard material
  67861. * to enhance interoperability with other materials.
  67862. */
  67863. static readonly FALLOFF_STANDARD: number;
  67864. /**
  67865. * If every light affecting the material is in this lightmapMode,
  67866. * material.lightmapTexture adds or multiplies
  67867. * (depends on material.useLightmapAsShadowmap)
  67868. * after every other light calculations.
  67869. */
  67870. static readonly LIGHTMAP_DEFAULT: number;
  67871. /**
  67872. * material.lightmapTexture as only diffuse lighting from this light
  67873. * adds only specular lighting from this light
  67874. * adds dynamic shadows
  67875. */
  67876. static readonly LIGHTMAP_SPECULAR: number;
  67877. /**
  67878. * material.lightmapTexture as only lighting
  67879. * no light calculation from this light
  67880. * only adds dynamic shadows from this light
  67881. */
  67882. static readonly LIGHTMAP_SHADOWSONLY: number;
  67883. /**
  67884. * Each light type uses the default quantity according to its type:
  67885. * point/spot lights use luminous intensity
  67886. * directional lights use illuminance
  67887. */
  67888. static readonly INTENSITYMODE_AUTOMATIC: number;
  67889. /**
  67890. * lumen (lm)
  67891. */
  67892. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67893. /**
  67894. * candela (lm/sr)
  67895. */
  67896. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67897. /**
  67898. * lux (lm/m^2)
  67899. */
  67900. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67901. /**
  67902. * nit (cd/m^2)
  67903. */
  67904. static readonly INTENSITYMODE_LUMINANCE: number;
  67905. /**
  67906. * Light type const id of the point light.
  67907. */
  67908. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67909. /**
  67910. * Light type const id of the directional light.
  67911. */
  67912. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67913. /**
  67914. * Light type const id of the spot light.
  67915. */
  67916. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67917. /**
  67918. * Light type const id of the hemispheric light.
  67919. */
  67920. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67921. /**
  67922. * Diffuse gives the basic color to an object.
  67923. */
  67924. diffuse: Color3;
  67925. /**
  67926. * Specular produces a highlight color on an object.
  67927. * Note: This is note affecting PBR materials.
  67928. */
  67929. specular: Color3;
  67930. /**
  67931. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67932. * falling off base on range or angle.
  67933. * This can be set to any values in Light.FALLOFF_x.
  67934. *
  67935. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67936. * other types of materials.
  67937. */
  67938. falloffType: number;
  67939. /**
  67940. * Strength of the light.
  67941. * Note: By default it is define in the framework own unit.
  67942. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67943. */
  67944. intensity: number;
  67945. private _range;
  67946. protected _inverseSquaredRange: number;
  67947. /**
  67948. * Defines how far from the source the light is impacting in scene units.
  67949. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67950. */
  67951. /**
  67952. * Defines how far from the source the light is impacting in scene units.
  67953. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67954. */
  67955. range: number;
  67956. /**
  67957. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67958. * of light.
  67959. */
  67960. private _photometricScale;
  67961. private _intensityMode;
  67962. /**
  67963. * Gets the photometric scale used to interpret the intensity.
  67964. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67965. */
  67966. /**
  67967. * Sets the photometric scale used to interpret the intensity.
  67968. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67969. */
  67970. intensityMode: number;
  67971. private _radius;
  67972. /**
  67973. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67974. */
  67975. /**
  67976. * sets the light radius used by PBR Materials to simulate soft area lights.
  67977. */
  67978. radius: number;
  67979. private _renderPriority;
  67980. /**
  67981. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67982. * exceeding the number allowed of the materials.
  67983. */
  67984. renderPriority: number;
  67985. private _shadowEnabled;
  67986. /**
  67987. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67988. * the current shadow generator.
  67989. */
  67990. /**
  67991. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67992. * the current shadow generator.
  67993. */
  67994. shadowEnabled: boolean;
  67995. private _includedOnlyMeshes;
  67996. /**
  67997. * Gets the only meshes impacted by this light.
  67998. */
  67999. /**
  68000. * Sets the only meshes impacted by this light.
  68001. */
  68002. includedOnlyMeshes: AbstractMesh[];
  68003. private _excludedMeshes;
  68004. /**
  68005. * Gets the meshes not impacted by this light.
  68006. */
  68007. /**
  68008. * Sets the meshes not impacted by this light.
  68009. */
  68010. excludedMeshes: AbstractMesh[];
  68011. private _excludeWithLayerMask;
  68012. /**
  68013. * Gets the layer id use to find what meshes are not impacted by the light.
  68014. * Inactive if 0
  68015. */
  68016. /**
  68017. * Sets the layer id use to find what meshes are not impacted by the light.
  68018. * Inactive if 0
  68019. */
  68020. excludeWithLayerMask: number;
  68021. private _includeOnlyWithLayerMask;
  68022. /**
  68023. * Gets the layer id use to find what meshes are impacted by the light.
  68024. * Inactive if 0
  68025. */
  68026. /**
  68027. * Sets the layer id use to find what meshes are impacted by the light.
  68028. * Inactive if 0
  68029. */
  68030. includeOnlyWithLayerMask: number;
  68031. private _lightmapMode;
  68032. /**
  68033. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68034. */
  68035. /**
  68036. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68037. */
  68038. lightmapMode: number;
  68039. /**
  68040. * Shadow generator associted to the light.
  68041. * @hidden Internal use only.
  68042. */
  68043. _shadowGenerator: Nullable<IShadowGenerator>;
  68044. /**
  68045. * @hidden Internal use only.
  68046. */
  68047. _excludedMeshesIds: string[];
  68048. /**
  68049. * @hidden Internal use only.
  68050. */
  68051. _includedOnlyMeshesIds: string[];
  68052. /**
  68053. * The current light unifom buffer.
  68054. * @hidden Internal use only.
  68055. */
  68056. _uniformBuffer: UniformBuffer;
  68057. /**
  68058. * Creates a Light object in the scene.
  68059. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68060. * @param name The firendly name of the light
  68061. * @param scene The scene the light belongs too
  68062. */
  68063. constructor(name: string, scene: Scene);
  68064. protected abstract _buildUniformLayout(): void;
  68065. /**
  68066. * Sets the passed Effect "effect" with the Light information.
  68067. * @param effect The effect to update
  68068. * @param lightIndex The index of the light in the effect to update
  68069. * @returns The light
  68070. */
  68071. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68072. /**
  68073. * Returns the string "Light".
  68074. * @returns the class name
  68075. */
  68076. getClassName(): string;
  68077. /** @hidden */
  68078. readonly _isLight: boolean;
  68079. /**
  68080. * Converts the light information to a readable string for debug purpose.
  68081. * @param fullDetails Supports for multiple levels of logging within scene loading
  68082. * @returns the human readable light info
  68083. */
  68084. toString(fullDetails?: boolean): string;
  68085. /** @hidden */
  68086. protected _syncParentEnabledState(): void;
  68087. /**
  68088. * Set the enabled state of this node.
  68089. * @param value - the new enabled state
  68090. */
  68091. setEnabled(value: boolean): void;
  68092. /**
  68093. * Returns the Light associated shadow generator if any.
  68094. * @return the associated shadow generator.
  68095. */
  68096. getShadowGenerator(): Nullable<IShadowGenerator>;
  68097. /**
  68098. * Returns a Vector3, the absolute light position in the World.
  68099. * @returns the world space position of the light
  68100. */
  68101. getAbsolutePosition(): Vector3;
  68102. /**
  68103. * Specifies if the light will affect the passed mesh.
  68104. * @param mesh The mesh to test against the light
  68105. * @return true the mesh is affected otherwise, false.
  68106. */
  68107. canAffectMesh(mesh: AbstractMesh): boolean;
  68108. /**
  68109. * Sort function to order lights for rendering.
  68110. * @param a First Light object to compare to second.
  68111. * @param b Second Light object to compare first.
  68112. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68113. */
  68114. static CompareLightsPriority(a: Light, b: Light): number;
  68115. /**
  68116. * Releases resources associated with this node.
  68117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68119. */
  68120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68121. /**
  68122. * Returns the light type ID (integer).
  68123. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68124. */
  68125. getTypeID(): number;
  68126. /**
  68127. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68128. * @returns the scaled intensity in intensity mode unit
  68129. */
  68130. getScaledIntensity(): number;
  68131. /**
  68132. * Returns a new Light object, named "name", from the current one.
  68133. * @param name The name of the cloned light
  68134. * @returns the new created light
  68135. */
  68136. clone(name: string): Nullable<Light>;
  68137. /**
  68138. * Serializes the current light into a Serialization object.
  68139. * @returns the serialized object.
  68140. */
  68141. serialize(): any;
  68142. /**
  68143. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68144. * This new light is named "name" and added to the passed scene.
  68145. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68146. * @param name The friendly name of the light
  68147. * @param scene The scene the new light will belong to
  68148. * @returns the constructor function
  68149. */
  68150. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68151. /**
  68152. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68153. * @param parsedLight The JSON representation of the light
  68154. * @param scene The scene to create the parsed light in
  68155. * @returns the created light after parsing
  68156. */
  68157. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68158. private _hookArrayForExcluded;
  68159. private _hookArrayForIncludedOnly;
  68160. private _resyncMeshes;
  68161. /**
  68162. * Forces the meshes to update their light related information in their rendering used effects
  68163. * @hidden Internal Use Only
  68164. */
  68165. _markMeshesAsLightDirty(): void;
  68166. /**
  68167. * Recomputes the cached photometric scale if needed.
  68168. */
  68169. private _computePhotometricScale;
  68170. /**
  68171. * Returns the Photometric Scale according to the light type and intensity mode.
  68172. */
  68173. private _getPhotometricScale;
  68174. /**
  68175. * Reorder the light in the scene according to their defined priority.
  68176. * @hidden Internal Use Only
  68177. */
  68178. _reorderLightsInScene(): void;
  68179. /**
  68180. * Prepares the list of defines specific to the light type.
  68181. * @param defines the list of defines
  68182. * @param lightIndex defines the index of the light for the effect
  68183. */
  68184. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68185. }
  68186. }
  68187. declare module BABYLON {
  68188. /**
  68189. * Interface used to define Action
  68190. */
  68191. export interface IAction {
  68192. /**
  68193. * Trigger for the action
  68194. */
  68195. trigger: number;
  68196. /** Options of the trigger */
  68197. triggerOptions: any;
  68198. /**
  68199. * Gets the trigger parameters
  68200. * @returns the trigger parameters
  68201. */
  68202. getTriggerParameter(): any;
  68203. /**
  68204. * Internal only - executes current action event
  68205. * @hidden
  68206. */
  68207. _executeCurrent(evt?: ActionEvent): void;
  68208. /**
  68209. * Serialize placeholder for child classes
  68210. * @param parent of child
  68211. * @returns the serialized object
  68212. */
  68213. serialize(parent: any): any;
  68214. /**
  68215. * Internal only
  68216. * @hidden
  68217. */
  68218. _prepare(): void;
  68219. /**
  68220. * Internal only - manager for action
  68221. * @hidden
  68222. */
  68223. _actionManager: AbstractActionManager;
  68224. }
  68225. /**
  68226. * The action to be carried out following a trigger
  68227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68228. */
  68229. export class Action implements IAction {
  68230. /** the trigger, with or without parameters, for the action */
  68231. triggerOptions: any;
  68232. /**
  68233. * Trigger for the action
  68234. */
  68235. trigger: number;
  68236. /**
  68237. * Internal only - manager for action
  68238. * @hidden
  68239. */
  68240. _actionManager: ActionManager;
  68241. private _nextActiveAction;
  68242. private _child;
  68243. private _condition?;
  68244. private _triggerParameter;
  68245. /**
  68246. * An event triggered prior to action being executed.
  68247. */
  68248. onBeforeExecuteObservable: Observable<Action>;
  68249. /**
  68250. * Creates a new Action
  68251. * @param triggerOptions the trigger, with or without parameters, for the action
  68252. * @param condition an optional determinant of action
  68253. */
  68254. constructor(
  68255. /** the trigger, with or without parameters, for the action */
  68256. triggerOptions: any, condition?: Condition);
  68257. /**
  68258. * Internal only
  68259. * @hidden
  68260. */
  68261. _prepare(): void;
  68262. /**
  68263. * Gets the trigger parameters
  68264. * @returns the trigger parameters
  68265. */
  68266. getTriggerParameter(): any;
  68267. /**
  68268. * Internal only - executes current action event
  68269. * @hidden
  68270. */
  68271. _executeCurrent(evt?: ActionEvent): void;
  68272. /**
  68273. * Execute placeholder for child classes
  68274. * @param evt optional action event
  68275. */
  68276. execute(evt?: ActionEvent): void;
  68277. /**
  68278. * Skips to next active action
  68279. */
  68280. skipToNextActiveAction(): void;
  68281. /**
  68282. * Adds action to chain of actions, may be a DoNothingAction
  68283. * @param action defines the next action to execute
  68284. * @returns The action passed in
  68285. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68286. */
  68287. then(action: Action): Action;
  68288. /**
  68289. * Internal only
  68290. * @hidden
  68291. */
  68292. _getProperty(propertyPath: string): string;
  68293. /**
  68294. * Internal only
  68295. * @hidden
  68296. */
  68297. _getEffectiveTarget(target: any, propertyPath: string): any;
  68298. /**
  68299. * Serialize placeholder for child classes
  68300. * @param parent of child
  68301. * @returns the serialized object
  68302. */
  68303. serialize(parent: any): any;
  68304. /**
  68305. * Internal only called by serialize
  68306. * @hidden
  68307. */
  68308. protected _serialize(serializedAction: any, parent?: any): any;
  68309. /**
  68310. * Internal only
  68311. * @hidden
  68312. */
  68313. static _SerializeValueAsString: (value: any) => string;
  68314. /**
  68315. * Internal only
  68316. * @hidden
  68317. */
  68318. static _GetTargetProperty: (target: Scene | Node) => {
  68319. name: string;
  68320. targetType: string;
  68321. value: string;
  68322. };
  68323. }
  68324. }
  68325. declare module BABYLON {
  68326. /**
  68327. * A Condition applied to an Action
  68328. */
  68329. export class Condition {
  68330. /**
  68331. * Internal only - manager for action
  68332. * @hidden
  68333. */
  68334. _actionManager: ActionManager;
  68335. /**
  68336. * Internal only
  68337. * @hidden
  68338. */
  68339. _evaluationId: number;
  68340. /**
  68341. * Internal only
  68342. * @hidden
  68343. */
  68344. _currentResult: boolean;
  68345. /**
  68346. * Creates a new Condition
  68347. * @param actionManager the manager of the action the condition is applied to
  68348. */
  68349. constructor(actionManager: ActionManager);
  68350. /**
  68351. * Check if the current condition is valid
  68352. * @returns a boolean
  68353. */
  68354. isValid(): boolean;
  68355. /**
  68356. * Internal only
  68357. * @hidden
  68358. */
  68359. _getProperty(propertyPath: string): string;
  68360. /**
  68361. * Internal only
  68362. * @hidden
  68363. */
  68364. _getEffectiveTarget(target: any, propertyPath: string): any;
  68365. /**
  68366. * Serialize placeholder for child classes
  68367. * @returns the serialized object
  68368. */
  68369. serialize(): any;
  68370. /**
  68371. * Internal only
  68372. * @hidden
  68373. */
  68374. protected _serialize(serializedCondition: any): any;
  68375. }
  68376. /**
  68377. * Defines specific conditional operators as extensions of Condition
  68378. */
  68379. export class ValueCondition extends Condition {
  68380. /** path to specify the property of the target the conditional operator uses */
  68381. propertyPath: string;
  68382. /** the value compared by the conditional operator against the current value of the property */
  68383. value: any;
  68384. /** the conditional operator, default ValueCondition.IsEqual */
  68385. operator: number;
  68386. /**
  68387. * Internal only
  68388. * @hidden
  68389. */
  68390. private static _IsEqual;
  68391. /**
  68392. * Internal only
  68393. * @hidden
  68394. */
  68395. private static _IsDifferent;
  68396. /**
  68397. * Internal only
  68398. * @hidden
  68399. */
  68400. private static _IsGreater;
  68401. /**
  68402. * Internal only
  68403. * @hidden
  68404. */
  68405. private static _IsLesser;
  68406. /**
  68407. * returns the number for IsEqual
  68408. */
  68409. static readonly IsEqual: number;
  68410. /**
  68411. * Returns the number for IsDifferent
  68412. */
  68413. static readonly IsDifferent: number;
  68414. /**
  68415. * Returns the number for IsGreater
  68416. */
  68417. static readonly IsGreater: number;
  68418. /**
  68419. * Returns the number for IsLesser
  68420. */
  68421. static readonly IsLesser: number;
  68422. /**
  68423. * Internal only The action manager for the condition
  68424. * @hidden
  68425. */
  68426. _actionManager: ActionManager;
  68427. /**
  68428. * Internal only
  68429. * @hidden
  68430. */
  68431. private _target;
  68432. /**
  68433. * Internal only
  68434. * @hidden
  68435. */
  68436. private _effectiveTarget;
  68437. /**
  68438. * Internal only
  68439. * @hidden
  68440. */
  68441. private _property;
  68442. /**
  68443. * Creates a new ValueCondition
  68444. * @param actionManager manager for the action the condition applies to
  68445. * @param target for the action
  68446. * @param propertyPath path to specify the property of the target the conditional operator uses
  68447. * @param value the value compared by the conditional operator against the current value of the property
  68448. * @param operator the conditional operator, default ValueCondition.IsEqual
  68449. */
  68450. constructor(actionManager: ActionManager, target: any,
  68451. /** path to specify the property of the target the conditional operator uses */
  68452. propertyPath: string,
  68453. /** the value compared by the conditional operator against the current value of the property */
  68454. value: any,
  68455. /** the conditional operator, default ValueCondition.IsEqual */
  68456. operator?: number);
  68457. /**
  68458. * Compares the given value with the property value for the specified conditional operator
  68459. * @returns the result of the comparison
  68460. */
  68461. isValid(): boolean;
  68462. /**
  68463. * Serialize the ValueCondition into a JSON compatible object
  68464. * @returns serialization object
  68465. */
  68466. serialize(): any;
  68467. /**
  68468. * Gets the name of the conditional operator for the ValueCondition
  68469. * @param operator the conditional operator
  68470. * @returns the name
  68471. */
  68472. static GetOperatorName(operator: number): string;
  68473. }
  68474. /**
  68475. * Defines a predicate condition as an extension of Condition
  68476. */
  68477. export class PredicateCondition extends Condition {
  68478. /** defines the predicate function used to validate the condition */
  68479. predicate: () => boolean;
  68480. /**
  68481. * Internal only - manager for action
  68482. * @hidden
  68483. */
  68484. _actionManager: ActionManager;
  68485. /**
  68486. * Creates a new PredicateCondition
  68487. * @param actionManager manager for the action the condition applies to
  68488. * @param predicate defines the predicate function used to validate the condition
  68489. */
  68490. constructor(actionManager: ActionManager,
  68491. /** defines the predicate function used to validate the condition */
  68492. predicate: () => boolean);
  68493. /**
  68494. * @returns the validity of the predicate condition
  68495. */
  68496. isValid(): boolean;
  68497. }
  68498. /**
  68499. * Defines a state condition as an extension of Condition
  68500. */
  68501. export class StateCondition extends Condition {
  68502. /** Value to compare with target state */
  68503. value: string;
  68504. /**
  68505. * Internal only - manager for action
  68506. * @hidden
  68507. */
  68508. _actionManager: ActionManager;
  68509. /**
  68510. * Internal only
  68511. * @hidden
  68512. */
  68513. private _target;
  68514. /**
  68515. * Creates a new StateCondition
  68516. * @param actionManager manager for the action the condition applies to
  68517. * @param target of the condition
  68518. * @param value to compare with target state
  68519. */
  68520. constructor(actionManager: ActionManager, target: any,
  68521. /** Value to compare with target state */
  68522. value: string);
  68523. /**
  68524. * Gets a boolean indicating if the current condition is met
  68525. * @returns the validity of the state
  68526. */
  68527. isValid(): boolean;
  68528. /**
  68529. * Serialize the StateCondition into a JSON compatible object
  68530. * @returns serialization object
  68531. */
  68532. serialize(): any;
  68533. }
  68534. }
  68535. declare module BABYLON {
  68536. /**
  68537. * This defines an action responsible to toggle a boolean once triggered.
  68538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68539. */
  68540. export class SwitchBooleanAction extends Action {
  68541. /**
  68542. * The path to the boolean property in the target object
  68543. */
  68544. propertyPath: string;
  68545. private _target;
  68546. private _effectiveTarget;
  68547. private _property;
  68548. /**
  68549. * Instantiate the action
  68550. * @param triggerOptions defines the trigger options
  68551. * @param target defines the object containing the boolean
  68552. * @param propertyPath defines the path to the boolean property in the target object
  68553. * @param condition defines the trigger related conditions
  68554. */
  68555. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68556. /** @hidden */
  68557. _prepare(): void;
  68558. /**
  68559. * Execute the action toggle the boolean value.
  68560. */
  68561. execute(): void;
  68562. /**
  68563. * Serializes the actions and its related information.
  68564. * @param parent defines the object to serialize in
  68565. * @returns the serialized object
  68566. */
  68567. serialize(parent: any): any;
  68568. }
  68569. /**
  68570. * This defines an action responsible to set a the state field of the target
  68571. * to a desired value once triggered.
  68572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68573. */
  68574. export class SetStateAction extends Action {
  68575. /**
  68576. * The value to store in the state field.
  68577. */
  68578. value: string;
  68579. private _target;
  68580. /**
  68581. * Instantiate the action
  68582. * @param triggerOptions defines the trigger options
  68583. * @param target defines the object containing the state property
  68584. * @param value defines the value to store in the state field
  68585. * @param condition defines the trigger related conditions
  68586. */
  68587. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68588. /**
  68589. * Execute the action and store the value on the target state property.
  68590. */
  68591. execute(): void;
  68592. /**
  68593. * Serializes the actions and its related information.
  68594. * @param parent defines the object to serialize in
  68595. * @returns the serialized object
  68596. */
  68597. serialize(parent: any): any;
  68598. }
  68599. /**
  68600. * This defines an action responsible to set a property of the target
  68601. * to a desired value once triggered.
  68602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68603. */
  68604. export class SetValueAction extends Action {
  68605. /**
  68606. * The path of the property to set in the target.
  68607. */
  68608. propertyPath: string;
  68609. /**
  68610. * The value to set in the property
  68611. */
  68612. value: any;
  68613. private _target;
  68614. private _effectiveTarget;
  68615. private _property;
  68616. /**
  68617. * Instantiate the action
  68618. * @param triggerOptions defines the trigger options
  68619. * @param target defines the object containing the property
  68620. * @param propertyPath defines the path of the property to set in the target
  68621. * @param value defines the value to set in the property
  68622. * @param condition defines the trigger related conditions
  68623. */
  68624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68625. /** @hidden */
  68626. _prepare(): void;
  68627. /**
  68628. * Execute the action and set the targetted property to the desired value.
  68629. */
  68630. execute(): void;
  68631. /**
  68632. * Serializes the actions and its related information.
  68633. * @param parent defines the object to serialize in
  68634. * @returns the serialized object
  68635. */
  68636. serialize(parent: any): any;
  68637. }
  68638. /**
  68639. * This defines an action responsible to increment the target value
  68640. * to a desired value once triggered.
  68641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68642. */
  68643. export class IncrementValueAction extends Action {
  68644. /**
  68645. * The path of the property to increment in the target.
  68646. */
  68647. propertyPath: string;
  68648. /**
  68649. * The value we should increment the property by.
  68650. */
  68651. value: any;
  68652. private _target;
  68653. private _effectiveTarget;
  68654. private _property;
  68655. /**
  68656. * Instantiate the action
  68657. * @param triggerOptions defines the trigger options
  68658. * @param target defines the object containing the property
  68659. * @param propertyPath defines the path of the property to increment in the target
  68660. * @param value defines the value value we should increment the property by
  68661. * @param condition defines the trigger related conditions
  68662. */
  68663. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68664. /** @hidden */
  68665. _prepare(): void;
  68666. /**
  68667. * Execute the action and increment the target of the value amount.
  68668. */
  68669. execute(): void;
  68670. /**
  68671. * Serializes the actions and its related information.
  68672. * @param parent defines the object to serialize in
  68673. * @returns the serialized object
  68674. */
  68675. serialize(parent: any): any;
  68676. }
  68677. /**
  68678. * This defines an action responsible to start an animation once triggered.
  68679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68680. */
  68681. export class PlayAnimationAction extends Action {
  68682. /**
  68683. * Where the animation should start (animation frame)
  68684. */
  68685. from: number;
  68686. /**
  68687. * Where the animation should stop (animation frame)
  68688. */
  68689. to: number;
  68690. /**
  68691. * Define if the animation should loop or stop after the first play.
  68692. */
  68693. loop?: boolean;
  68694. private _target;
  68695. /**
  68696. * Instantiate the action
  68697. * @param triggerOptions defines the trigger options
  68698. * @param target defines the target animation or animation name
  68699. * @param from defines from where the animation should start (animation frame)
  68700. * @param end defines where the animation should stop (animation frame)
  68701. * @param loop defines if the animation should loop or stop after the first play
  68702. * @param condition defines the trigger related conditions
  68703. */
  68704. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68705. /** @hidden */
  68706. _prepare(): void;
  68707. /**
  68708. * Execute the action and play the animation.
  68709. */
  68710. execute(): void;
  68711. /**
  68712. * Serializes the actions and its related information.
  68713. * @param parent defines the object to serialize in
  68714. * @returns the serialized object
  68715. */
  68716. serialize(parent: any): any;
  68717. }
  68718. /**
  68719. * This defines an action responsible to stop an animation once triggered.
  68720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68721. */
  68722. export class StopAnimationAction extends Action {
  68723. private _target;
  68724. /**
  68725. * Instantiate the action
  68726. * @param triggerOptions defines the trigger options
  68727. * @param target defines the target animation or animation name
  68728. * @param condition defines the trigger related conditions
  68729. */
  68730. constructor(triggerOptions: any, target: any, condition?: Condition);
  68731. /** @hidden */
  68732. _prepare(): void;
  68733. /**
  68734. * Execute the action and stop the animation.
  68735. */
  68736. execute(): void;
  68737. /**
  68738. * Serializes the actions and its related information.
  68739. * @param parent defines the object to serialize in
  68740. * @returns the serialized object
  68741. */
  68742. serialize(parent: any): any;
  68743. }
  68744. /**
  68745. * This defines an action responsible that does nothing once triggered.
  68746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68747. */
  68748. export class DoNothingAction extends Action {
  68749. /**
  68750. * Instantiate the action
  68751. * @param triggerOptions defines the trigger options
  68752. * @param condition defines the trigger related conditions
  68753. */
  68754. constructor(triggerOptions?: any, condition?: Condition);
  68755. /**
  68756. * Execute the action and do nothing.
  68757. */
  68758. execute(): void;
  68759. /**
  68760. * Serializes the actions and its related information.
  68761. * @param parent defines the object to serialize in
  68762. * @returns the serialized object
  68763. */
  68764. serialize(parent: any): any;
  68765. }
  68766. /**
  68767. * This defines an action responsible to trigger several actions once triggered.
  68768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68769. */
  68770. export class CombineAction extends Action {
  68771. /**
  68772. * The list of aggregated animations to run.
  68773. */
  68774. children: Action[];
  68775. /**
  68776. * Instantiate the action
  68777. * @param triggerOptions defines the trigger options
  68778. * @param children defines the list of aggregated animations to run
  68779. * @param condition defines the trigger related conditions
  68780. */
  68781. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68782. /** @hidden */
  68783. _prepare(): void;
  68784. /**
  68785. * Execute the action and executes all the aggregated actions.
  68786. */
  68787. execute(evt: ActionEvent): void;
  68788. /**
  68789. * Serializes the actions and its related information.
  68790. * @param parent defines the object to serialize in
  68791. * @returns the serialized object
  68792. */
  68793. serialize(parent: any): any;
  68794. }
  68795. /**
  68796. * This defines an action responsible to run code (external event) once triggered.
  68797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68798. */
  68799. export class ExecuteCodeAction extends Action {
  68800. /**
  68801. * The callback function to run.
  68802. */
  68803. func: (evt: ActionEvent) => void;
  68804. /**
  68805. * Instantiate the action
  68806. * @param triggerOptions defines the trigger options
  68807. * @param func defines the callback function to run
  68808. * @param condition defines the trigger related conditions
  68809. */
  68810. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68811. /**
  68812. * Execute the action and run the attached code.
  68813. */
  68814. execute(evt: ActionEvent): void;
  68815. }
  68816. /**
  68817. * This defines an action responsible to set the parent property of the target once triggered.
  68818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68819. */
  68820. export class SetParentAction extends Action {
  68821. private _parent;
  68822. private _target;
  68823. /**
  68824. * Instantiate the action
  68825. * @param triggerOptions defines the trigger options
  68826. * @param target defines the target containing the parent property
  68827. * @param parent defines from where the animation should start (animation frame)
  68828. * @param condition defines the trigger related conditions
  68829. */
  68830. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68831. /** @hidden */
  68832. _prepare(): void;
  68833. /**
  68834. * Execute the action and set the parent property.
  68835. */
  68836. execute(): void;
  68837. /**
  68838. * Serializes the actions and its related information.
  68839. * @param parent defines the object to serialize in
  68840. * @returns the serialized object
  68841. */
  68842. serialize(parent: any): any;
  68843. }
  68844. }
  68845. declare module BABYLON {
  68846. /**
  68847. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68848. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68850. */
  68851. export class ActionManager extends AbstractActionManager {
  68852. /**
  68853. * Nothing
  68854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68855. */
  68856. static readonly NothingTrigger: number;
  68857. /**
  68858. * On pick
  68859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68860. */
  68861. static readonly OnPickTrigger: number;
  68862. /**
  68863. * On left pick
  68864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68865. */
  68866. static readonly OnLeftPickTrigger: number;
  68867. /**
  68868. * On right pick
  68869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68870. */
  68871. static readonly OnRightPickTrigger: number;
  68872. /**
  68873. * On center pick
  68874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68875. */
  68876. static readonly OnCenterPickTrigger: number;
  68877. /**
  68878. * On pick down
  68879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68880. */
  68881. static readonly OnPickDownTrigger: number;
  68882. /**
  68883. * On double pick
  68884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68885. */
  68886. static readonly OnDoublePickTrigger: number;
  68887. /**
  68888. * On pick up
  68889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68890. */
  68891. static readonly OnPickUpTrigger: number;
  68892. /**
  68893. * On pick out.
  68894. * This trigger will only be raised if you also declared a OnPickDown
  68895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68896. */
  68897. static readonly OnPickOutTrigger: number;
  68898. /**
  68899. * On long press
  68900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68901. */
  68902. static readonly OnLongPressTrigger: number;
  68903. /**
  68904. * On pointer over
  68905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68906. */
  68907. static readonly OnPointerOverTrigger: number;
  68908. /**
  68909. * On pointer out
  68910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68911. */
  68912. static readonly OnPointerOutTrigger: number;
  68913. /**
  68914. * On every frame
  68915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68916. */
  68917. static readonly OnEveryFrameTrigger: number;
  68918. /**
  68919. * On intersection enter
  68920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68921. */
  68922. static readonly OnIntersectionEnterTrigger: number;
  68923. /**
  68924. * On intersection exit
  68925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68926. */
  68927. static readonly OnIntersectionExitTrigger: number;
  68928. /**
  68929. * On key down
  68930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68931. */
  68932. static readonly OnKeyDownTrigger: number;
  68933. /**
  68934. * On key up
  68935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68936. */
  68937. static readonly OnKeyUpTrigger: number;
  68938. private _scene;
  68939. /**
  68940. * Creates a new action manager
  68941. * @param scene defines the hosting scene
  68942. */
  68943. constructor(scene: Scene);
  68944. /**
  68945. * Releases all associated resources
  68946. */
  68947. dispose(): void;
  68948. /**
  68949. * Gets hosting scene
  68950. * @returns the hosting scene
  68951. */
  68952. getScene(): Scene;
  68953. /**
  68954. * Does this action manager handles actions of any of the given triggers
  68955. * @param triggers defines the triggers to be tested
  68956. * @return a boolean indicating whether one (or more) of the triggers is handled
  68957. */
  68958. hasSpecificTriggers(triggers: number[]): boolean;
  68959. /**
  68960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68961. * speed.
  68962. * @param triggerA defines the trigger to be tested
  68963. * @param triggerB defines the trigger to be tested
  68964. * @return a boolean indicating whether one (or more) of the triggers is handled
  68965. */
  68966. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68967. /**
  68968. * Does this action manager handles actions of a given trigger
  68969. * @param trigger defines the trigger to be tested
  68970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68971. * @return whether the trigger is handled
  68972. */
  68973. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68974. /**
  68975. * Does this action manager has pointer triggers
  68976. */
  68977. readonly hasPointerTriggers: boolean;
  68978. /**
  68979. * Does this action manager has pick triggers
  68980. */
  68981. readonly hasPickTriggers: boolean;
  68982. /**
  68983. * Registers an action to this action manager
  68984. * @param action defines the action to be registered
  68985. * @return the action amended (prepared) after registration
  68986. */
  68987. registerAction(action: IAction): Nullable<IAction>;
  68988. /**
  68989. * Unregisters an action to this action manager
  68990. * @param action defines the action to be unregistered
  68991. * @return a boolean indicating whether the action has been unregistered
  68992. */
  68993. unregisterAction(action: IAction): Boolean;
  68994. /**
  68995. * Process a specific trigger
  68996. * @param trigger defines the trigger to process
  68997. * @param evt defines the event details to be processed
  68998. */
  68999. processTrigger(trigger: number, evt?: IActionEvent): void;
  69000. /** @hidden */
  69001. _getEffectiveTarget(target: any, propertyPath: string): any;
  69002. /** @hidden */
  69003. _getProperty(propertyPath: string): string;
  69004. /**
  69005. * Serialize this manager to a JSON object
  69006. * @param name defines the property name to store this manager
  69007. * @returns a JSON representation of this manager
  69008. */
  69009. serialize(name: string): any;
  69010. /**
  69011. * Creates a new ActionManager from a JSON data
  69012. * @param parsedActions defines the JSON data to read from
  69013. * @param object defines the hosting mesh
  69014. * @param scene defines the hosting scene
  69015. */
  69016. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69017. /**
  69018. * Get a trigger name by index
  69019. * @param trigger defines the trigger index
  69020. * @returns a trigger name
  69021. */
  69022. static GetTriggerName(trigger: number): string;
  69023. }
  69024. }
  69025. declare module BABYLON {
  69026. /**
  69027. * Class representing a ray with position and direction
  69028. */
  69029. export class Ray {
  69030. /** origin point */
  69031. origin: Vector3;
  69032. /** direction */
  69033. direction: Vector3;
  69034. /** length of the ray */
  69035. length: number;
  69036. private static readonly TmpVector3;
  69037. private _tmpRay;
  69038. /**
  69039. * Creates a new ray
  69040. * @param origin origin point
  69041. * @param direction direction
  69042. * @param length length of the ray
  69043. */
  69044. constructor(
  69045. /** origin point */
  69046. origin: Vector3,
  69047. /** direction */
  69048. direction: Vector3,
  69049. /** length of the ray */
  69050. length?: number);
  69051. /**
  69052. * Checks if the ray intersects a box
  69053. * @param minimum bound of the box
  69054. * @param maximum bound of the box
  69055. * @param intersectionTreshold extra extend to be added to the box in all direction
  69056. * @returns if the box was hit
  69057. */
  69058. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69059. /**
  69060. * Checks if the ray intersects a box
  69061. * @param box the bounding box to check
  69062. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69063. * @returns if the box was hit
  69064. */
  69065. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69066. /**
  69067. * If the ray hits a sphere
  69068. * @param sphere the bounding sphere to check
  69069. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69070. * @returns true if it hits the sphere
  69071. */
  69072. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69073. /**
  69074. * If the ray hits a triange
  69075. * @param vertex0 triangle vertex
  69076. * @param vertex1 triangle vertex
  69077. * @param vertex2 triangle vertex
  69078. * @returns intersection information if hit
  69079. */
  69080. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69081. /**
  69082. * Checks if ray intersects a plane
  69083. * @param plane the plane to check
  69084. * @returns the distance away it was hit
  69085. */
  69086. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69087. /**
  69088. * Checks if ray intersects a mesh
  69089. * @param mesh the mesh to check
  69090. * @param fastCheck if only the bounding box should checked
  69091. * @returns picking info of the intersecton
  69092. */
  69093. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69094. /**
  69095. * Checks if ray intersects a mesh
  69096. * @param meshes the meshes to check
  69097. * @param fastCheck if only the bounding box should checked
  69098. * @param results array to store result in
  69099. * @returns Array of picking infos
  69100. */
  69101. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69102. private _comparePickingInfo;
  69103. private static smallnum;
  69104. private static rayl;
  69105. /**
  69106. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69107. * @param sega the first point of the segment to test the intersection against
  69108. * @param segb the second point of the segment to test the intersection against
  69109. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69110. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69111. */
  69112. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69113. /**
  69114. * Update the ray from viewport position
  69115. * @param x position
  69116. * @param y y position
  69117. * @param viewportWidth viewport width
  69118. * @param viewportHeight viewport height
  69119. * @param world world matrix
  69120. * @param view view matrix
  69121. * @param projection projection matrix
  69122. * @returns this ray updated
  69123. */
  69124. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69125. /**
  69126. * Creates a ray with origin and direction of 0,0,0
  69127. * @returns the new ray
  69128. */
  69129. static Zero(): Ray;
  69130. /**
  69131. * Creates a new ray from screen space and viewport
  69132. * @param x position
  69133. * @param y y position
  69134. * @param viewportWidth viewport width
  69135. * @param viewportHeight viewport height
  69136. * @param world world matrix
  69137. * @param view view matrix
  69138. * @param projection projection matrix
  69139. * @returns new ray
  69140. */
  69141. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69142. /**
  69143. * 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
  69144. * transformed to the given world matrix.
  69145. * @param origin The origin point
  69146. * @param end The end point
  69147. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69148. * @returns the new ray
  69149. */
  69150. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69151. /**
  69152. * Transforms a ray by a matrix
  69153. * @param ray ray to transform
  69154. * @param matrix matrix to apply
  69155. * @returns the resulting new ray
  69156. */
  69157. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69158. /**
  69159. * Transforms a ray by a matrix
  69160. * @param ray ray to transform
  69161. * @param matrix matrix to apply
  69162. * @param result ray to store result in
  69163. */
  69164. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69165. /**
  69166. * Unproject a ray from screen space to object space
  69167. * @param sourceX defines the screen space x coordinate to use
  69168. * @param sourceY defines the screen space y coordinate to use
  69169. * @param viewportWidth defines the current width of the viewport
  69170. * @param viewportHeight defines the current height of the viewport
  69171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69172. * @param view defines the view matrix to use
  69173. * @param projection defines the projection matrix to use
  69174. */
  69175. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69176. }
  69177. /**
  69178. * Type used to define predicate used to select faces when a mesh intersection is detected
  69179. */
  69180. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69181. interface Scene {
  69182. /** @hidden */
  69183. _tempPickingRay: Nullable<Ray>;
  69184. /** @hidden */
  69185. _cachedRayForTransform: Ray;
  69186. /** @hidden */
  69187. _pickWithRayInverseMatrix: Matrix;
  69188. /** @hidden */
  69189. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69190. /** @hidden */
  69191. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69192. }
  69193. }
  69194. declare module BABYLON {
  69195. /**
  69196. * Groups all the scene component constants in one place to ease maintenance.
  69197. * @hidden
  69198. */
  69199. export class SceneComponentConstants {
  69200. static readonly NAME_EFFECTLAYER: string;
  69201. static readonly NAME_LAYER: string;
  69202. static readonly NAME_LENSFLARESYSTEM: string;
  69203. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69204. static readonly NAME_PARTICLESYSTEM: string;
  69205. static readonly NAME_GAMEPAD: string;
  69206. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69207. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69208. static readonly NAME_DEPTHRENDERER: string;
  69209. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69210. static readonly NAME_SPRITE: string;
  69211. static readonly NAME_OUTLINERENDERER: string;
  69212. static readonly NAME_PROCEDURALTEXTURE: string;
  69213. static readonly NAME_SHADOWGENERATOR: string;
  69214. static readonly NAME_OCTREE: string;
  69215. static readonly NAME_PHYSICSENGINE: string;
  69216. static readonly NAME_AUDIO: string;
  69217. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69218. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69219. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69220. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69221. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69222. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69223. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69224. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69225. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69226. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69227. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69228. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69229. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69230. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69231. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69232. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69233. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69234. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69235. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69236. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69237. static readonly STEP_AFTERRENDER_AUDIO: number;
  69238. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69239. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69240. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69241. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69242. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69243. static readonly STEP_POINTERMOVE_SPRITE: number;
  69244. static readonly STEP_POINTERDOWN_SPRITE: number;
  69245. static readonly STEP_POINTERUP_SPRITE: number;
  69246. }
  69247. /**
  69248. * This represents a scene component.
  69249. *
  69250. * This is used to decouple the dependency the scene is having on the different workloads like
  69251. * layers, post processes...
  69252. */
  69253. export interface ISceneComponent {
  69254. /**
  69255. * The name of the component. Each component must have a unique name.
  69256. */
  69257. name: string;
  69258. /**
  69259. * The scene the component belongs to.
  69260. */
  69261. scene: Scene;
  69262. /**
  69263. * Register the component to one instance of a scene.
  69264. */
  69265. register(): void;
  69266. /**
  69267. * Rebuilds the elements related to this component in case of
  69268. * context lost for instance.
  69269. */
  69270. rebuild(): void;
  69271. /**
  69272. * Disposes the component and the associated ressources.
  69273. */
  69274. dispose(): void;
  69275. }
  69276. /**
  69277. * This represents a SERIALIZABLE scene component.
  69278. *
  69279. * This extends Scene Component to add Serialization methods on top.
  69280. */
  69281. export interface ISceneSerializableComponent extends ISceneComponent {
  69282. /**
  69283. * Adds all the element from the container to the scene
  69284. * @param container the container holding the elements
  69285. */
  69286. addFromContainer(container: AbstractScene): void;
  69287. /**
  69288. * Removes all the elements in the container from the scene
  69289. * @param container contains the elements to remove
  69290. */
  69291. removeFromContainer(container: AbstractScene): void;
  69292. /**
  69293. * Serializes the component data to the specified json object
  69294. * @param serializationObject The object to serialize to
  69295. */
  69296. serialize(serializationObject: any): void;
  69297. }
  69298. /**
  69299. * Strong typing of a Mesh related stage step action
  69300. */
  69301. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69302. /**
  69303. * Strong typing of a Evaluate Sub Mesh related stage step action
  69304. */
  69305. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69306. /**
  69307. * Strong typing of a Active Mesh related stage step action
  69308. */
  69309. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69310. /**
  69311. * Strong typing of a Camera related stage step action
  69312. */
  69313. export type CameraStageAction = (camera: Camera) => void;
  69314. /**
  69315. * Strong typing of a Render Target related stage step action
  69316. */
  69317. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69318. /**
  69319. * Strong typing of a RenderingGroup related stage step action
  69320. */
  69321. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69322. /**
  69323. * Strong typing of a Mesh Render related stage step action
  69324. */
  69325. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69326. /**
  69327. * Strong typing of a simple stage step action
  69328. */
  69329. export type SimpleStageAction = () => void;
  69330. /**
  69331. * Strong typing of a render target action.
  69332. */
  69333. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69334. /**
  69335. * Strong typing of a pointer move action.
  69336. */
  69337. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69338. /**
  69339. * Strong typing of a pointer up/down action.
  69340. */
  69341. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69342. /**
  69343. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69344. * @hidden
  69345. */
  69346. export class Stage<T extends Function> extends Array<{
  69347. index: number;
  69348. component: ISceneComponent;
  69349. action: T;
  69350. }> {
  69351. /**
  69352. * Hide ctor from the rest of the world.
  69353. * @param items The items to add.
  69354. */
  69355. private constructor();
  69356. /**
  69357. * Creates a new Stage.
  69358. * @returns A new instance of a Stage
  69359. */
  69360. static Create<T extends Function>(): Stage<T>;
  69361. /**
  69362. * Registers a step in an ordered way in the targeted stage.
  69363. * @param index Defines the position to register the step in
  69364. * @param component Defines the component attached to the step
  69365. * @param action Defines the action to launch during the step
  69366. */
  69367. registerStep(index: number, component: ISceneComponent, action: T): void;
  69368. /**
  69369. * Clears all the steps from the stage.
  69370. */
  69371. clear(): void;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. interface Scene {
  69376. /** @hidden */
  69377. _pointerOverSprite: Nullable<Sprite>;
  69378. /** @hidden */
  69379. _pickedDownSprite: Nullable<Sprite>;
  69380. /** @hidden */
  69381. _tempSpritePickingRay: Nullable<Ray>;
  69382. /**
  69383. * All of the sprite managers added to this scene
  69384. * @see http://doc.babylonjs.com/babylon101/sprites
  69385. */
  69386. spriteManagers: Array<ISpriteManager>;
  69387. /**
  69388. * An event triggered when sprites rendering is about to start
  69389. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69390. */
  69391. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69392. /**
  69393. * An event triggered when sprites rendering is done
  69394. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69395. */
  69396. onAfterSpritesRenderingObservable: Observable<Scene>;
  69397. /** @hidden */
  69398. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69399. /** Launch a ray to try to pick a sprite in the scene
  69400. * @param x position on screen
  69401. * @param y position on screen
  69402. * @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
  69403. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69404. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69405. * @returns a PickingInfo
  69406. */
  69407. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69408. /** Use the given ray to pick a sprite in the scene
  69409. * @param ray The ray (in world space) to use to pick meshes
  69410. * @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
  69411. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69412. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69413. * @returns a PickingInfo
  69414. */
  69415. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69416. /**
  69417. * Force the sprite under the pointer
  69418. * @param sprite defines the sprite to use
  69419. */
  69420. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69421. /**
  69422. * Gets the sprite under the pointer
  69423. * @returns a Sprite or null if no sprite is under the pointer
  69424. */
  69425. getPointerOverSprite(): Nullable<Sprite>;
  69426. }
  69427. /**
  69428. * Defines the sprite scene component responsible to manage sprites
  69429. * in a given scene.
  69430. */
  69431. export class SpriteSceneComponent implements ISceneComponent {
  69432. /**
  69433. * The component name helpfull to identify the component in the list of scene components.
  69434. */
  69435. readonly name: string;
  69436. /**
  69437. * The scene the component belongs to.
  69438. */
  69439. scene: Scene;
  69440. /** @hidden */
  69441. private _spritePredicate;
  69442. /**
  69443. * Creates a new instance of the component for the given scene
  69444. * @param scene Defines the scene to register the component in
  69445. */
  69446. constructor(scene: Scene);
  69447. /**
  69448. * Registers the component in a given scene
  69449. */
  69450. register(): void;
  69451. /**
  69452. * Rebuilds the elements related to this component in case of
  69453. * context lost for instance.
  69454. */
  69455. rebuild(): void;
  69456. /**
  69457. * Disposes the component and the associated ressources.
  69458. */
  69459. dispose(): void;
  69460. private _pickSpriteButKeepRay;
  69461. private _pointerMove;
  69462. private _pointerDown;
  69463. private _pointerUp;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /** @hidden */
  69468. export var fogFragmentDeclaration: {
  69469. name: string;
  69470. shader: string;
  69471. };
  69472. }
  69473. declare module BABYLON {
  69474. /** @hidden */
  69475. export var fogFragment: {
  69476. name: string;
  69477. shader: string;
  69478. };
  69479. }
  69480. declare module BABYLON {
  69481. /** @hidden */
  69482. export var spritesPixelShader: {
  69483. name: string;
  69484. shader: string;
  69485. };
  69486. }
  69487. declare module BABYLON {
  69488. /** @hidden */
  69489. export var fogVertexDeclaration: {
  69490. name: string;
  69491. shader: string;
  69492. };
  69493. }
  69494. declare module BABYLON {
  69495. /** @hidden */
  69496. export var spritesVertexShader: {
  69497. name: string;
  69498. shader: string;
  69499. };
  69500. }
  69501. declare module BABYLON {
  69502. /**
  69503. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69504. */
  69505. export interface ISpriteManager extends IDisposable {
  69506. /**
  69507. * Restricts the camera to viewing objects with the same layerMask.
  69508. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69509. */
  69510. layerMask: number;
  69511. /**
  69512. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69513. */
  69514. isPickable: boolean;
  69515. /**
  69516. * Specifies the rendering group id for this mesh (0 by default)
  69517. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69518. */
  69519. renderingGroupId: number;
  69520. /**
  69521. * Defines the list of sprites managed by the manager.
  69522. */
  69523. sprites: Array<Sprite>;
  69524. /**
  69525. * Tests the intersection of a sprite with a specific ray.
  69526. * @param ray The ray we are sending to test the collision
  69527. * @param camera The camera space we are sending rays in
  69528. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69529. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69530. * @returns picking info or null.
  69531. */
  69532. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69533. /**
  69534. * Renders the list of sprites on screen.
  69535. */
  69536. render(): void;
  69537. }
  69538. /**
  69539. * Class used to manage multiple sprites on the same spritesheet
  69540. * @see http://doc.babylonjs.com/babylon101/sprites
  69541. */
  69542. export class SpriteManager implements ISpriteManager {
  69543. /** defines the manager's name */
  69544. name: string;
  69545. /** Gets the list of sprites */
  69546. sprites: Sprite[];
  69547. /** Gets or sets the rendering group id (0 by default) */
  69548. renderingGroupId: number;
  69549. /** Gets or sets camera layer mask */
  69550. layerMask: number;
  69551. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69552. fogEnabled: boolean;
  69553. /** Gets or sets a boolean indicating if the sprites are pickable */
  69554. isPickable: boolean;
  69555. /** Defines the default width of a cell in the spritesheet */
  69556. cellWidth: number;
  69557. /** Defines the default height of a cell in the spritesheet */
  69558. cellHeight: number;
  69559. /**
  69560. * An event triggered when the manager is disposed.
  69561. */
  69562. onDisposeObservable: Observable<SpriteManager>;
  69563. private _onDisposeObserver;
  69564. /**
  69565. * Callback called when the manager is disposed
  69566. */
  69567. onDispose: () => void;
  69568. private _capacity;
  69569. private _spriteTexture;
  69570. private _epsilon;
  69571. private _scene;
  69572. private _vertexData;
  69573. private _buffer;
  69574. private _vertexBuffers;
  69575. private _indexBuffer;
  69576. private _effectBase;
  69577. private _effectFog;
  69578. /**
  69579. * Gets or sets the spritesheet texture
  69580. */
  69581. texture: Texture;
  69582. /**
  69583. * Creates a new sprite manager
  69584. * @param name defines the manager's name
  69585. * @param imgUrl defines the sprite sheet url
  69586. * @param capacity defines the maximum allowed number of sprites
  69587. * @param cellSize defines the size of a sprite cell
  69588. * @param scene defines the hosting scene
  69589. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69590. * @param samplingMode defines the smapling mode to use with spritesheet
  69591. */
  69592. constructor(
  69593. /** defines the manager's name */
  69594. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69595. private _appendSpriteVertex;
  69596. /**
  69597. * Intersects the sprites with a ray
  69598. * @param ray defines the ray to intersect with
  69599. * @param camera defines the current active camera
  69600. * @param predicate defines a predicate used to select candidate sprites
  69601. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69602. * @returns null if no hit or a PickingInfo
  69603. */
  69604. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69605. /**
  69606. * Render all child sprites
  69607. */
  69608. render(): void;
  69609. /**
  69610. * Release associated resources
  69611. */
  69612. dispose(): void;
  69613. }
  69614. }
  69615. declare module BABYLON {
  69616. /**
  69617. * Class used to represent a sprite
  69618. * @see http://doc.babylonjs.com/babylon101/sprites
  69619. */
  69620. export class Sprite {
  69621. /** defines the name */
  69622. name: string;
  69623. /** Gets or sets the current world position */
  69624. position: Vector3;
  69625. /** Gets or sets the main color */
  69626. color: Color4;
  69627. /** Gets or sets the width */
  69628. width: number;
  69629. /** Gets or sets the height */
  69630. height: number;
  69631. /** Gets or sets rotation angle */
  69632. angle: number;
  69633. /** Gets or sets the cell index in the sprite sheet */
  69634. cellIndex: number;
  69635. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69636. invertU: number;
  69637. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69638. invertV: number;
  69639. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69640. disposeWhenFinishedAnimating: boolean;
  69641. /** Gets the list of attached animations */
  69642. animations: Animation[];
  69643. /** Gets or sets a boolean indicating if the sprite can be picked */
  69644. isPickable: boolean;
  69645. /**
  69646. * Gets or sets the associated action manager
  69647. */
  69648. actionManager: Nullable<ActionManager>;
  69649. private _animationStarted;
  69650. private _loopAnimation;
  69651. private _fromIndex;
  69652. private _toIndex;
  69653. private _delay;
  69654. private _direction;
  69655. private _manager;
  69656. private _time;
  69657. private _onAnimationEnd;
  69658. /**
  69659. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69660. */
  69661. isVisible: boolean;
  69662. /**
  69663. * Gets or sets the sprite size
  69664. */
  69665. size: number;
  69666. /**
  69667. * Creates a new Sprite
  69668. * @param name defines the name
  69669. * @param manager defines the manager
  69670. */
  69671. constructor(
  69672. /** defines the name */
  69673. name: string, manager: ISpriteManager);
  69674. /**
  69675. * Starts an animation
  69676. * @param from defines the initial key
  69677. * @param to defines the end key
  69678. * @param loop defines if the animation must loop
  69679. * @param delay defines the start delay (in ms)
  69680. * @param onAnimationEnd defines a callback to call when animation ends
  69681. */
  69682. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69683. /** Stops current animation (if any) */
  69684. stopAnimation(): void;
  69685. /** @hidden */
  69686. _animate(deltaTime: number): void;
  69687. /** Release associated resources */
  69688. dispose(): void;
  69689. }
  69690. }
  69691. declare module BABYLON {
  69692. /**
  69693. * Information about the result of picking within a scene
  69694. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69695. */
  69696. export class PickingInfo {
  69697. /** @hidden */
  69698. _pickingUnavailable: boolean;
  69699. /**
  69700. * If the pick collided with an object
  69701. */
  69702. hit: boolean;
  69703. /**
  69704. * Distance away where the pick collided
  69705. */
  69706. distance: number;
  69707. /**
  69708. * The location of pick collision
  69709. */
  69710. pickedPoint: Nullable<Vector3>;
  69711. /**
  69712. * The mesh corresponding the the pick collision
  69713. */
  69714. pickedMesh: Nullable<AbstractMesh>;
  69715. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69716. bu: number;
  69717. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69718. bv: number;
  69719. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69720. faceId: number;
  69721. /** Id of the the submesh that was picked */
  69722. subMeshId: number;
  69723. /** If a sprite was picked, this will be the sprite the pick collided with */
  69724. pickedSprite: Nullable<Sprite>;
  69725. /**
  69726. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69727. */
  69728. originMesh: Nullable<AbstractMesh>;
  69729. /**
  69730. * The ray that was used to perform the picking.
  69731. */
  69732. ray: Nullable<Ray>;
  69733. /**
  69734. * Gets the normal correspodning to the face the pick collided with
  69735. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69736. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69737. * @returns The normal correspodning to the face the pick collided with
  69738. */
  69739. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69740. /**
  69741. * Gets the texture coordinates of where the pick occured
  69742. * @returns the vector containing the coordnates of the texture
  69743. */
  69744. getTextureCoordinates(): Nullable<Vector2>;
  69745. }
  69746. }
  69747. declare module BABYLON {
  69748. /**
  69749. * Gather the list of pointer event types as constants.
  69750. */
  69751. export class PointerEventTypes {
  69752. /**
  69753. * 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.
  69754. */
  69755. static readonly POINTERDOWN: number;
  69756. /**
  69757. * The pointerup event is fired when a pointer is no longer active.
  69758. */
  69759. static readonly POINTERUP: number;
  69760. /**
  69761. * The pointermove event is fired when a pointer changes coordinates.
  69762. */
  69763. static readonly POINTERMOVE: number;
  69764. /**
  69765. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69766. */
  69767. static readonly POINTERWHEEL: number;
  69768. /**
  69769. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69770. */
  69771. static readonly POINTERPICK: number;
  69772. /**
  69773. * The pointertap event is fired when a the object has been touched and released without drag.
  69774. */
  69775. static readonly POINTERTAP: number;
  69776. /**
  69777. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69778. */
  69779. static readonly POINTERDOUBLETAP: number;
  69780. }
  69781. /**
  69782. * Base class of pointer info types.
  69783. */
  69784. export class PointerInfoBase {
  69785. /**
  69786. * Defines the type of event (PointerEventTypes)
  69787. */
  69788. type: number;
  69789. /**
  69790. * Defines the related dom event
  69791. */
  69792. event: PointerEvent | MouseWheelEvent;
  69793. /**
  69794. * Instantiates the base class of pointers info.
  69795. * @param type Defines the type of event (PointerEventTypes)
  69796. * @param event Defines the related dom event
  69797. */
  69798. constructor(
  69799. /**
  69800. * Defines the type of event (PointerEventTypes)
  69801. */
  69802. type: number,
  69803. /**
  69804. * Defines the related dom event
  69805. */
  69806. event: PointerEvent | MouseWheelEvent);
  69807. }
  69808. /**
  69809. * This class is used to store pointer related info for the onPrePointerObservable event.
  69810. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69811. */
  69812. export class PointerInfoPre extends PointerInfoBase {
  69813. /**
  69814. * Ray from a pointer if availible (eg. 6dof controller)
  69815. */
  69816. ray: Nullable<Ray>;
  69817. /**
  69818. * Defines the local position of the pointer on the canvas.
  69819. */
  69820. localPosition: Vector2;
  69821. /**
  69822. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69823. */
  69824. skipOnPointerObservable: boolean;
  69825. /**
  69826. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69827. * @param type Defines the type of event (PointerEventTypes)
  69828. * @param event Defines the related dom event
  69829. * @param localX Defines the local x coordinates of the pointer when the event occured
  69830. * @param localY Defines the local y coordinates of the pointer when the event occured
  69831. */
  69832. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69833. }
  69834. /**
  69835. * This type contains all the data related to a pointer event in Babylon.js.
  69836. * 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.
  69837. */
  69838. export class PointerInfo extends PointerInfoBase {
  69839. /**
  69840. * Defines the picking info associated to the info (if any)\
  69841. */
  69842. pickInfo: Nullable<PickingInfo>;
  69843. /**
  69844. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69845. * @param type Defines the type of event (PointerEventTypes)
  69846. * @param event Defines the related dom event
  69847. * @param pickInfo Defines the picking info associated to the info (if any)\
  69848. */
  69849. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69850. /**
  69851. * Defines the picking info associated to the info (if any)\
  69852. */
  69853. pickInfo: Nullable<PickingInfo>);
  69854. }
  69855. /**
  69856. * Data relating to a touch event on the screen.
  69857. */
  69858. export interface PointerTouch {
  69859. /**
  69860. * X coordinate of touch.
  69861. */
  69862. x: number;
  69863. /**
  69864. * Y coordinate of touch.
  69865. */
  69866. y: number;
  69867. /**
  69868. * Id of touch. Unique for each finger.
  69869. */
  69870. pointerId: number;
  69871. /**
  69872. * Event type passed from DOM.
  69873. */
  69874. type: any;
  69875. }
  69876. }
  69877. declare module BABYLON {
  69878. /**
  69879. * Manage the mouse inputs to control the movement of a free camera.
  69880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69881. */
  69882. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69883. /**
  69884. * Define if touch is enabled in the mouse input
  69885. */
  69886. touchEnabled: boolean;
  69887. /**
  69888. * Defines the camera the input is attached to.
  69889. */
  69890. camera: FreeCamera;
  69891. /**
  69892. * Defines the buttons associated with the input to handle camera move.
  69893. */
  69894. buttons: number[];
  69895. /**
  69896. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69897. */
  69898. angularSensibility: number;
  69899. private _pointerInput;
  69900. private _onMouseMove;
  69901. private _observer;
  69902. private previousPosition;
  69903. /**
  69904. * Manage the mouse inputs to control the movement of a free camera.
  69905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69906. * @param touchEnabled Defines if touch is enabled or not
  69907. */
  69908. constructor(
  69909. /**
  69910. * Define if touch is enabled in the mouse input
  69911. */
  69912. touchEnabled?: boolean);
  69913. /**
  69914. * Attach the input controls to a specific dom element to get the input from.
  69915. * @param element Defines the element the controls should be listened from
  69916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69917. */
  69918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69919. /**
  69920. * Called on JS contextmenu event.
  69921. * Override this method to provide functionality.
  69922. */
  69923. protected onContextMenu(evt: PointerEvent): void;
  69924. /**
  69925. * Detach the current controls from the specified dom element.
  69926. * @param element Defines the element to stop listening the inputs from
  69927. */
  69928. detachControl(element: Nullable<HTMLElement>): void;
  69929. /**
  69930. * Gets the class name of the current intput.
  69931. * @returns the class name
  69932. */
  69933. getClassName(): string;
  69934. /**
  69935. * Get the friendly name associated with the input class.
  69936. * @returns the input friendly name
  69937. */
  69938. getSimpleName(): string;
  69939. }
  69940. }
  69941. declare module BABYLON {
  69942. /**
  69943. * Manage the touch inputs to control the movement of a free camera.
  69944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69945. */
  69946. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69947. /**
  69948. * Defines the camera the input is attached to.
  69949. */
  69950. camera: FreeCamera;
  69951. /**
  69952. * Defines the touch sensibility for rotation.
  69953. * The higher the faster.
  69954. */
  69955. touchAngularSensibility: number;
  69956. /**
  69957. * Defines the touch sensibility for move.
  69958. * The higher the faster.
  69959. */
  69960. touchMoveSensibility: number;
  69961. private _offsetX;
  69962. private _offsetY;
  69963. private _pointerPressed;
  69964. private _pointerInput;
  69965. private _observer;
  69966. private _onLostFocus;
  69967. /**
  69968. * Attach the input controls to a specific dom element to get the input from.
  69969. * @param element Defines the element the controls should be listened from
  69970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69971. */
  69972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69973. /**
  69974. * Detach the current controls from the specified dom element.
  69975. * @param element Defines the element to stop listening the inputs from
  69976. */
  69977. detachControl(element: Nullable<HTMLElement>): void;
  69978. /**
  69979. * Update the current camera state depending on the inputs that have been used this frame.
  69980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69981. */
  69982. checkInputs(): void;
  69983. /**
  69984. * Gets the class name of the current intput.
  69985. * @returns the class name
  69986. */
  69987. getClassName(): string;
  69988. /**
  69989. * Get the friendly name associated with the input class.
  69990. * @returns the input friendly name
  69991. */
  69992. getSimpleName(): string;
  69993. }
  69994. }
  69995. declare module BABYLON {
  69996. /**
  69997. * Default Inputs manager for the FreeCamera.
  69998. * It groups all the default supported inputs for ease of use.
  69999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70000. */
  70001. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70002. /**
  70003. * Instantiates a new FreeCameraInputsManager.
  70004. * @param camera Defines the camera the inputs belong to
  70005. */
  70006. constructor(camera: FreeCamera);
  70007. /**
  70008. * Add keyboard input support to the input manager.
  70009. * @returns the current input manager
  70010. */
  70011. addKeyboard(): FreeCameraInputsManager;
  70012. /**
  70013. * Add mouse input support to the input manager.
  70014. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70015. * @returns the current input manager
  70016. */
  70017. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70018. /**
  70019. * Add touch input support to the input manager.
  70020. * @returns the current input manager
  70021. */
  70022. addTouch(): FreeCameraInputsManager;
  70023. }
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70028. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70030. */
  70031. export class FreeCamera extends TargetCamera {
  70032. /**
  70033. * Define the collision ellipsoid of the camera.
  70034. * This is helpful to simulate a camera body like the player body around the camera
  70035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70036. */
  70037. ellipsoid: Vector3;
  70038. /**
  70039. * Define an offset for the position of the ellipsoid around the camera.
  70040. * This can be helpful to determine the center of the body near the gravity center of the body
  70041. * instead of its head.
  70042. */
  70043. ellipsoidOffset: Vector3;
  70044. /**
  70045. * Enable or disable collisions of the camera with the rest of the scene objects.
  70046. */
  70047. checkCollisions: boolean;
  70048. /**
  70049. * Enable or disable gravity on the camera.
  70050. */
  70051. applyGravity: boolean;
  70052. /**
  70053. * Define the input manager associated to the camera.
  70054. */
  70055. inputs: FreeCameraInputsManager;
  70056. /**
  70057. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70058. * Higher values reduce sensitivity.
  70059. */
  70060. /**
  70061. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70062. * Higher values reduce sensitivity.
  70063. */
  70064. angularSensibility: number;
  70065. /**
  70066. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70067. */
  70068. keysUp: number[];
  70069. /**
  70070. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70071. */
  70072. keysDown: number[];
  70073. /**
  70074. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70075. */
  70076. keysLeft: number[];
  70077. /**
  70078. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70079. */
  70080. keysRight: number[];
  70081. /**
  70082. * Event raised when the camera collide with a mesh in the scene.
  70083. */
  70084. onCollide: (collidedMesh: AbstractMesh) => void;
  70085. private _collider;
  70086. private _needMoveForGravity;
  70087. private _oldPosition;
  70088. private _diffPosition;
  70089. private _newPosition;
  70090. /** @hidden */
  70091. _localDirection: Vector3;
  70092. /** @hidden */
  70093. _transformedDirection: Vector3;
  70094. /**
  70095. * Instantiates a Free Camera.
  70096. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70097. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70098. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70099. * @param name Define the name of the camera in the scene
  70100. * @param position Define the start position of the camera in the scene
  70101. * @param scene Define the scene the camera belongs to
  70102. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70103. */
  70104. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70105. /**
  70106. * Attached controls to the current camera.
  70107. * @param element Defines the element the controls should be listened from
  70108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70109. */
  70110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70111. /**
  70112. * Detach the current controls from the camera.
  70113. * The camera will stop reacting to inputs.
  70114. * @param element Defines the element to stop listening the inputs from
  70115. */
  70116. detachControl(element: HTMLElement): void;
  70117. private _collisionMask;
  70118. /**
  70119. * Define a collision mask to limit the list of object the camera can collide with
  70120. */
  70121. collisionMask: number;
  70122. /** @hidden */
  70123. _collideWithWorld(displacement: Vector3): void;
  70124. private _onCollisionPositionChange;
  70125. /** @hidden */
  70126. _checkInputs(): void;
  70127. /** @hidden */
  70128. _decideIfNeedsToMove(): boolean;
  70129. /** @hidden */
  70130. _updatePosition(): void;
  70131. /**
  70132. * Destroy the camera and release the current resources hold by it.
  70133. */
  70134. dispose(): void;
  70135. /**
  70136. * Gets the current object class name.
  70137. * @return the class name
  70138. */
  70139. getClassName(): string;
  70140. }
  70141. }
  70142. declare module BABYLON {
  70143. /**
  70144. * Represents a gamepad control stick position
  70145. */
  70146. export class StickValues {
  70147. /**
  70148. * The x component of the control stick
  70149. */
  70150. x: number;
  70151. /**
  70152. * The y component of the control stick
  70153. */
  70154. y: number;
  70155. /**
  70156. * Initializes the gamepad x and y control stick values
  70157. * @param x The x component of the gamepad control stick value
  70158. * @param y The y component of the gamepad control stick value
  70159. */
  70160. constructor(
  70161. /**
  70162. * The x component of the control stick
  70163. */
  70164. x: number,
  70165. /**
  70166. * The y component of the control stick
  70167. */
  70168. y: number);
  70169. }
  70170. /**
  70171. * An interface which manages callbacks for gamepad button changes
  70172. */
  70173. export interface GamepadButtonChanges {
  70174. /**
  70175. * Called when a gamepad has been changed
  70176. */
  70177. changed: boolean;
  70178. /**
  70179. * Called when a gamepad press event has been triggered
  70180. */
  70181. pressChanged: boolean;
  70182. /**
  70183. * Called when a touch event has been triggered
  70184. */
  70185. touchChanged: boolean;
  70186. /**
  70187. * Called when a value has changed
  70188. */
  70189. valueChanged: boolean;
  70190. }
  70191. /**
  70192. * Represents a gamepad
  70193. */
  70194. export class Gamepad {
  70195. /**
  70196. * The id of the gamepad
  70197. */
  70198. id: string;
  70199. /**
  70200. * The index of the gamepad
  70201. */
  70202. index: number;
  70203. /**
  70204. * The browser gamepad
  70205. */
  70206. browserGamepad: any;
  70207. /**
  70208. * Specifies what type of gamepad this represents
  70209. */
  70210. type: number;
  70211. private _leftStick;
  70212. private _rightStick;
  70213. /** @hidden */
  70214. _isConnected: boolean;
  70215. private _leftStickAxisX;
  70216. private _leftStickAxisY;
  70217. private _rightStickAxisX;
  70218. private _rightStickAxisY;
  70219. /**
  70220. * Triggered when the left control stick has been changed
  70221. */
  70222. private _onleftstickchanged;
  70223. /**
  70224. * Triggered when the right control stick has been changed
  70225. */
  70226. private _onrightstickchanged;
  70227. /**
  70228. * Represents a gamepad controller
  70229. */
  70230. static GAMEPAD: number;
  70231. /**
  70232. * Represents a generic controller
  70233. */
  70234. static GENERIC: number;
  70235. /**
  70236. * Represents an XBox controller
  70237. */
  70238. static XBOX: number;
  70239. /**
  70240. * Represents a pose-enabled controller
  70241. */
  70242. static POSE_ENABLED: number;
  70243. /**
  70244. * Specifies whether the left control stick should be Y-inverted
  70245. */
  70246. protected _invertLeftStickY: boolean;
  70247. /**
  70248. * Specifies if the gamepad has been connected
  70249. */
  70250. readonly isConnected: boolean;
  70251. /**
  70252. * Initializes the gamepad
  70253. * @param id The id of the gamepad
  70254. * @param index The index of the gamepad
  70255. * @param browserGamepad The browser gamepad
  70256. * @param leftStickX The x component of the left joystick
  70257. * @param leftStickY The y component of the left joystick
  70258. * @param rightStickX The x component of the right joystick
  70259. * @param rightStickY The y component of the right joystick
  70260. */
  70261. constructor(
  70262. /**
  70263. * The id of the gamepad
  70264. */
  70265. id: string,
  70266. /**
  70267. * The index of the gamepad
  70268. */
  70269. index: number,
  70270. /**
  70271. * The browser gamepad
  70272. */
  70273. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70274. /**
  70275. * Callback triggered when the left joystick has changed
  70276. * @param callback
  70277. */
  70278. onleftstickchanged(callback: (values: StickValues) => void): void;
  70279. /**
  70280. * Callback triggered when the right joystick has changed
  70281. * @param callback
  70282. */
  70283. onrightstickchanged(callback: (values: StickValues) => void): void;
  70284. /**
  70285. * Gets the left joystick
  70286. */
  70287. /**
  70288. * Sets the left joystick values
  70289. */
  70290. leftStick: StickValues;
  70291. /**
  70292. * Gets the right joystick
  70293. */
  70294. /**
  70295. * Sets the right joystick value
  70296. */
  70297. rightStick: StickValues;
  70298. /**
  70299. * Updates the gamepad joystick positions
  70300. */
  70301. update(): void;
  70302. /**
  70303. * Disposes the gamepad
  70304. */
  70305. dispose(): void;
  70306. }
  70307. /**
  70308. * Represents a generic gamepad
  70309. */
  70310. export class GenericPad extends Gamepad {
  70311. private _buttons;
  70312. private _onbuttondown;
  70313. private _onbuttonup;
  70314. /**
  70315. * Observable triggered when a button has been pressed
  70316. */
  70317. onButtonDownObservable: Observable<number>;
  70318. /**
  70319. * Observable triggered when a button has been released
  70320. */
  70321. onButtonUpObservable: Observable<number>;
  70322. /**
  70323. * Callback triggered when a button has been pressed
  70324. * @param callback Called when a button has been pressed
  70325. */
  70326. onbuttondown(callback: (buttonPressed: number) => void): void;
  70327. /**
  70328. * Callback triggered when a button has been released
  70329. * @param callback Called when a button has been released
  70330. */
  70331. onbuttonup(callback: (buttonReleased: number) => void): void;
  70332. /**
  70333. * Initializes the generic gamepad
  70334. * @param id The id of the generic gamepad
  70335. * @param index The index of the generic gamepad
  70336. * @param browserGamepad The browser gamepad
  70337. */
  70338. constructor(id: string, index: number, browserGamepad: any);
  70339. private _setButtonValue;
  70340. /**
  70341. * Updates the generic gamepad
  70342. */
  70343. update(): void;
  70344. /**
  70345. * Disposes the generic gamepad
  70346. */
  70347. dispose(): void;
  70348. }
  70349. }
  70350. declare module BABYLON {
  70351. /**
  70352. * Defines the types of pose enabled controllers that are supported
  70353. */
  70354. export enum PoseEnabledControllerType {
  70355. /**
  70356. * HTC Vive
  70357. */
  70358. VIVE = 0,
  70359. /**
  70360. * Oculus Rift
  70361. */
  70362. OCULUS = 1,
  70363. /**
  70364. * Windows mixed reality
  70365. */
  70366. WINDOWS = 2,
  70367. /**
  70368. * Samsung gear VR
  70369. */
  70370. GEAR_VR = 3,
  70371. /**
  70372. * Google Daydream
  70373. */
  70374. DAYDREAM = 4,
  70375. /**
  70376. * Generic
  70377. */
  70378. GENERIC = 5
  70379. }
  70380. /**
  70381. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70382. */
  70383. export interface MutableGamepadButton {
  70384. /**
  70385. * Value of the button/trigger
  70386. */
  70387. value: number;
  70388. /**
  70389. * If the button/trigger is currently touched
  70390. */
  70391. touched: boolean;
  70392. /**
  70393. * If the button/trigger is currently pressed
  70394. */
  70395. pressed: boolean;
  70396. }
  70397. /**
  70398. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70399. * @hidden
  70400. */
  70401. export interface ExtendedGamepadButton extends GamepadButton {
  70402. /**
  70403. * If the button/trigger is currently pressed
  70404. */
  70405. readonly pressed: boolean;
  70406. /**
  70407. * If the button/trigger is currently touched
  70408. */
  70409. readonly touched: boolean;
  70410. /**
  70411. * Value of the button/trigger
  70412. */
  70413. readonly value: number;
  70414. }
  70415. /** @hidden */
  70416. export interface _GamePadFactory {
  70417. /**
  70418. * Returns wether or not the current gamepad can be created for this type of controller.
  70419. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70420. * @returns true if it can be created, otherwise false
  70421. */
  70422. canCreate(gamepadInfo: any): boolean;
  70423. /**
  70424. * Creates a new instance of the Gamepad.
  70425. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70426. * @returns the new gamepad instance
  70427. */
  70428. create(gamepadInfo: any): Gamepad;
  70429. }
  70430. /**
  70431. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70432. */
  70433. export class PoseEnabledControllerHelper {
  70434. /** @hidden */
  70435. static _ControllerFactories: _GamePadFactory[];
  70436. /** @hidden */
  70437. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70438. /**
  70439. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70440. * @param vrGamepad the gamepad to initialized
  70441. * @returns a vr controller of the type the gamepad identified as
  70442. */
  70443. static InitiateController(vrGamepad: any): Gamepad;
  70444. }
  70445. /**
  70446. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70447. */
  70448. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70449. private _deviceRoomPosition;
  70450. private _deviceRoomRotationQuaternion;
  70451. /**
  70452. * The device position in babylon space
  70453. */
  70454. devicePosition: Vector3;
  70455. /**
  70456. * The device rotation in babylon space
  70457. */
  70458. deviceRotationQuaternion: Quaternion;
  70459. /**
  70460. * The scale factor of the device in babylon space
  70461. */
  70462. deviceScaleFactor: number;
  70463. /**
  70464. * (Likely devicePosition should be used instead) The device position in its room space
  70465. */
  70466. position: Vector3;
  70467. /**
  70468. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70469. */
  70470. rotationQuaternion: Quaternion;
  70471. /**
  70472. * The type of controller (Eg. Windows mixed reality)
  70473. */
  70474. controllerType: PoseEnabledControllerType;
  70475. protected _calculatedPosition: Vector3;
  70476. private _calculatedRotation;
  70477. /**
  70478. * The raw pose from the device
  70479. */
  70480. rawPose: DevicePose;
  70481. private _trackPosition;
  70482. private _maxRotationDistFromHeadset;
  70483. private _draggedRoomRotation;
  70484. /**
  70485. * @hidden
  70486. */
  70487. _disableTrackPosition(fixedPosition: Vector3): void;
  70488. /**
  70489. * Internal, the mesh attached to the controller
  70490. * @hidden
  70491. */
  70492. _mesh: Nullable<AbstractMesh>;
  70493. private _poseControlledCamera;
  70494. private _leftHandSystemQuaternion;
  70495. /**
  70496. * Internal, matrix used to convert room space to babylon space
  70497. * @hidden
  70498. */
  70499. _deviceToWorld: Matrix;
  70500. /**
  70501. * Node to be used when casting a ray from the controller
  70502. * @hidden
  70503. */
  70504. _pointingPoseNode: Nullable<TransformNode>;
  70505. /**
  70506. * Name of the child mesh that can be used to cast a ray from the controller
  70507. */
  70508. static readonly POINTING_POSE: string;
  70509. /**
  70510. * Creates a new PoseEnabledController from a gamepad
  70511. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70512. */
  70513. constructor(browserGamepad: any);
  70514. private _workingMatrix;
  70515. /**
  70516. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70517. */
  70518. update(): void;
  70519. /**
  70520. * Updates only the pose device and mesh without doing any button event checking
  70521. */
  70522. protected _updatePoseAndMesh(): void;
  70523. /**
  70524. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70525. * @param poseData raw pose fromthe device
  70526. */
  70527. updateFromDevice(poseData: DevicePose): void;
  70528. /**
  70529. * @hidden
  70530. */
  70531. _meshAttachedObservable: Observable<AbstractMesh>;
  70532. /**
  70533. * Attaches a mesh to the controller
  70534. * @param mesh the mesh to be attached
  70535. */
  70536. attachToMesh(mesh: AbstractMesh): void;
  70537. /**
  70538. * Attaches the controllers mesh to a camera
  70539. * @param camera the camera the mesh should be attached to
  70540. */
  70541. attachToPoseControlledCamera(camera: TargetCamera): void;
  70542. /**
  70543. * Disposes of the controller
  70544. */
  70545. dispose(): void;
  70546. /**
  70547. * The mesh that is attached to the controller
  70548. */
  70549. readonly mesh: Nullable<AbstractMesh>;
  70550. /**
  70551. * Gets the ray of the controller in the direction the controller is pointing
  70552. * @param length the length the resulting ray should be
  70553. * @returns a ray in the direction the controller is pointing
  70554. */
  70555. getForwardRay(length?: number): Ray;
  70556. }
  70557. }
  70558. declare module BABYLON {
  70559. /**
  70560. * Defines the WebVRController object that represents controllers tracked in 3D space
  70561. */
  70562. export abstract class WebVRController extends PoseEnabledController {
  70563. /**
  70564. * Internal, the default controller model for the controller
  70565. */
  70566. protected _defaultModel: AbstractMesh;
  70567. /**
  70568. * Fired when the trigger state has changed
  70569. */
  70570. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70571. /**
  70572. * Fired when the main button state has changed
  70573. */
  70574. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70575. /**
  70576. * Fired when the secondary button state has changed
  70577. */
  70578. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70579. /**
  70580. * Fired when the pad state has changed
  70581. */
  70582. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70583. /**
  70584. * Fired when controllers stick values have changed
  70585. */
  70586. onPadValuesChangedObservable: Observable<StickValues>;
  70587. /**
  70588. * Array of button availible on the controller
  70589. */
  70590. protected _buttons: Array<MutableGamepadButton>;
  70591. private _onButtonStateChange;
  70592. /**
  70593. * Fired when a controller button's state has changed
  70594. * @param callback the callback containing the button that was modified
  70595. */
  70596. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70597. /**
  70598. * X and Y axis corrisponding to the controllers joystick
  70599. */
  70600. pad: StickValues;
  70601. /**
  70602. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70603. */
  70604. hand: string;
  70605. /**
  70606. * The default controller model for the controller
  70607. */
  70608. readonly defaultModel: AbstractMesh;
  70609. /**
  70610. * Creates a new WebVRController from a gamepad
  70611. * @param vrGamepad the gamepad that the WebVRController should be created from
  70612. */
  70613. constructor(vrGamepad: any);
  70614. /**
  70615. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70616. */
  70617. update(): void;
  70618. /**
  70619. * Function to be called when a button is modified
  70620. */
  70621. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70622. /**
  70623. * Loads a mesh and attaches it to the controller
  70624. * @param scene the scene the mesh should be added to
  70625. * @param meshLoaded callback for when the mesh has been loaded
  70626. */
  70627. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70628. private _setButtonValue;
  70629. private _changes;
  70630. private _checkChanges;
  70631. /**
  70632. * Disposes of th webVRCOntroller
  70633. */
  70634. dispose(): void;
  70635. }
  70636. }
  70637. declare module BABYLON {
  70638. /**
  70639. * The HemisphericLight simulates the ambient environment light,
  70640. * so the passed direction is the light reflection direction, not the incoming direction.
  70641. */
  70642. export class HemisphericLight extends Light {
  70643. /**
  70644. * The groundColor is the light in the opposite direction to the one specified during creation.
  70645. * 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.
  70646. */
  70647. groundColor: Color3;
  70648. /**
  70649. * The light reflection direction, not the incoming direction.
  70650. */
  70651. direction: Vector3;
  70652. /**
  70653. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70654. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70655. * The HemisphericLight can't cast shadows.
  70656. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70657. * @param name The friendly name of the light
  70658. * @param direction The direction of the light reflection
  70659. * @param scene The scene the light belongs to
  70660. */
  70661. constructor(name: string, direction: Vector3, scene: Scene);
  70662. protected _buildUniformLayout(): void;
  70663. /**
  70664. * Returns the string "HemisphericLight".
  70665. * @return The class name
  70666. */
  70667. getClassName(): string;
  70668. /**
  70669. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70670. * Returns the updated direction.
  70671. * @param target The target the direction should point to
  70672. * @return The computed direction
  70673. */
  70674. setDirectionToTarget(target: Vector3): Vector3;
  70675. /**
  70676. * Returns the shadow generator associated to the light.
  70677. * @returns Always null for hemispheric lights because it does not support shadows.
  70678. */
  70679. getShadowGenerator(): Nullable<IShadowGenerator>;
  70680. /**
  70681. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70682. * @param effect The effect to update
  70683. * @param lightIndex The index of the light in the effect to update
  70684. * @returns The hemispheric light
  70685. */
  70686. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70687. /**
  70688. * Computes the world matrix of the node
  70689. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70690. * @param useWasUpdatedFlag defines a reserved property
  70691. * @returns the world matrix
  70692. */
  70693. computeWorldMatrix(): Matrix;
  70694. /**
  70695. * Returns the integer 3.
  70696. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70697. */
  70698. getTypeID(): number;
  70699. /**
  70700. * Prepares the list of defines specific to the light type.
  70701. * @param defines the list of defines
  70702. * @param lightIndex defines the index of the light for the effect
  70703. */
  70704. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70705. }
  70706. }
  70707. declare module BABYLON {
  70708. /**
  70709. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70710. * IMPORTANT!! The data is right-hand data.
  70711. * @export
  70712. * @interface DevicePose
  70713. */
  70714. export interface DevicePose {
  70715. /**
  70716. * The position of the device, values in array are [x,y,z].
  70717. */
  70718. readonly position: Nullable<Float32Array>;
  70719. /**
  70720. * The linearVelocity of the device, values in array are [x,y,z].
  70721. */
  70722. readonly linearVelocity: Nullable<Float32Array>;
  70723. /**
  70724. * The linearAcceleration of the device, values in array are [x,y,z].
  70725. */
  70726. readonly linearAcceleration: Nullable<Float32Array>;
  70727. /**
  70728. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70729. */
  70730. readonly orientation: Nullable<Float32Array>;
  70731. /**
  70732. * The angularVelocity of the device, values in array are [x,y,z].
  70733. */
  70734. readonly angularVelocity: Nullable<Float32Array>;
  70735. /**
  70736. * The angularAcceleration of the device, values in array are [x,y,z].
  70737. */
  70738. readonly angularAcceleration: Nullable<Float32Array>;
  70739. }
  70740. /**
  70741. * Interface representing a pose controlled object in Babylon.
  70742. * A pose controlled object has both regular pose values as well as pose values
  70743. * from an external device such as a VR head mounted display
  70744. */
  70745. export interface PoseControlled {
  70746. /**
  70747. * The position of the object in babylon space.
  70748. */
  70749. position: Vector3;
  70750. /**
  70751. * The rotation quaternion of the object in babylon space.
  70752. */
  70753. rotationQuaternion: Quaternion;
  70754. /**
  70755. * The position of the device in babylon space.
  70756. */
  70757. devicePosition?: Vector3;
  70758. /**
  70759. * The rotation quaternion of the device in babylon space.
  70760. */
  70761. deviceRotationQuaternion: Quaternion;
  70762. /**
  70763. * The raw pose coming from the device.
  70764. */
  70765. rawPose: Nullable<DevicePose>;
  70766. /**
  70767. * The scale of the device to be used when translating from device space to babylon space.
  70768. */
  70769. deviceScaleFactor: number;
  70770. /**
  70771. * Updates the poseControlled values based on the input device pose.
  70772. * @param poseData the pose data to update the object with
  70773. */
  70774. updateFromDevice(poseData: DevicePose): void;
  70775. }
  70776. /**
  70777. * Set of options to customize the webVRCamera
  70778. */
  70779. export interface WebVROptions {
  70780. /**
  70781. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70782. */
  70783. trackPosition?: boolean;
  70784. /**
  70785. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70786. */
  70787. positionScale?: number;
  70788. /**
  70789. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70790. */
  70791. displayName?: string;
  70792. /**
  70793. * Should the native controller meshes be initialized. (default: true)
  70794. */
  70795. controllerMeshes?: boolean;
  70796. /**
  70797. * Creating a default HemiLight only on controllers. (default: true)
  70798. */
  70799. defaultLightingOnControllers?: boolean;
  70800. /**
  70801. * If you don't want to use the default VR button of the helper. (default: false)
  70802. */
  70803. useCustomVRButton?: boolean;
  70804. /**
  70805. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70806. */
  70807. customVRButton?: HTMLButtonElement;
  70808. /**
  70809. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70810. */
  70811. rayLength?: number;
  70812. /**
  70813. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70814. */
  70815. defaultHeight?: number;
  70816. }
  70817. /**
  70818. * This represents a WebVR camera.
  70819. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70820. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70821. */
  70822. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70823. private webVROptions;
  70824. /**
  70825. * @hidden
  70826. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70827. */
  70828. _vrDevice: any;
  70829. /**
  70830. * The rawPose of the vrDevice.
  70831. */
  70832. rawPose: Nullable<DevicePose>;
  70833. private _onVREnabled;
  70834. private _specsVersion;
  70835. private _attached;
  70836. private _frameData;
  70837. protected _descendants: Array<Node>;
  70838. private _deviceRoomPosition;
  70839. /** @hidden */
  70840. _deviceRoomRotationQuaternion: Quaternion;
  70841. private _standingMatrix;
  70842. /**
  70843. * Represents device position in babylon space.
  70844. */
  70845. devicePosition: Vector3;
  70846. /**
  70847. * Represents device rotation in babylon space.
  70848. */
  70849. deviceRotationQuaternion: Quaternion;
  70850. /**
  70851. * The scale of the device to be used when translating from device space to babylon space.
  70852. */
  70853. deviceScaleFactor: number;
  70854. private _deviceToWorld;
  70855. private _worldToDevice;
  70856. /**
  70857. * References to the webVR controllers for the vrDevice.
  70858. */
  70859. controllers: Array<WebVRController>;
  70860. /**
  70861. * Emits an event when a controller is attached.
  70862. */
  70863. onControllersAttachedObservable: Observable<WebVRController[]>;
  70864. /**
  70865. * Emits an event when a controller's mesh has been loaded;
  70866. */
  70867. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70868. /**
  70869. * Emits an event when the HMD's pose has been updated.
  70870. */
  70871. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70872. private _poseSet;
  70873. /**
  70874. * If the rig cameras be used as parent instead of this camera.
  70875. */
  70876. rigParenting: boolean;
  70877. private _lightOnControllers;
  70878. private _defaultHeight?;
  70879. /**
  70880. * Instantiates a WebVRFreeCamera.
  70881. * @param name The name of the WebVRFreeCamera
  70882. * @param position The starting anchor position for the camera
  70883. * @param scene The scene the camera belongs to
  70884. * @param webVROptions a set of customizable options for the webVRCamera
  70885. */
  70886. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70887. /**
  70888. * Gets the device distance from the ground in meters.
  70889. * @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.
  70890. */
  70891. deviceDistanceToRoomGround(): number;
  70892. /**
  70893. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70894. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70895. */
  70896. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70897. /**
  70898. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70899. * @returns A promise with a boolean set to if the standing matrix is supported.
  70900. */
  70901. useStandingMatrixAsync(): Promise<boolean>;
  70902. /**
  70903. * Disposes the camera
  70904. */
  70905. dispose(): void;
  70906. /**
  70907. * Gets a vrController by name.
  70908. * @param name The name of the controller to retreive
  70909. * @returns the controller matching the name specified or null if not found
  70910. */
  70911. getControllerByName(name: string): Nullable<WebVRController>;
  70912. private _leftController;
  70913. /**
  70914. * The controller corrisponding to the users left hand.
  70915. */
  70916. readonly leftController: Nullable<WebVRController>;
  70917. private _rightController;
  70918. /**
  70919. * The controller corrisponding to the users right hand.
  70920. */
  70921. readonly rightController: Nullable<WebVRController>;
  70922. /**
  70923. * Casts a ray forward from the vrCamera's gaze.
  70924. * @param length Length of the ray (default: 100)
  70925. * @returns the ray corrisponding to the gaze
  70926. */
  70927. getForwardRay(length?: number): Ray;
  70928. /**
  70929. * @hidden
  70930. * Updates the camera based on device's frame data
  70931. */
  70932. _checkInputs(): void;
  70933. /**
  70934. * Updates the poseControlled values based on the input device pose.
  70935. * @param poseData Pose coming from the device
  70936. */
  70937. updateFromDevice(poseData: DevicePose): void;
  70938. private _htmlElementAttached;
  70939. private _detachIfAttached;
  70940. /**
  70941. * WebVR's attach control will start broadcasting frames to the device.
  70942. * Note that in certain browsers (chrome for example) this function must be called
  70943. * within a user-interaction callback. Example:
  70944. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70945. *
  70946. * @param element html element to attach the vrDevice to
  70947. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70948. */
  70949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70950. /**
  70951. * Detaches the camera from the html element and disables VR
  70952. *
  70953. * @param element html element to detach from
  70954. */
  70955. detachControl(element: HTMLElement): void;
  70956. /**
  70957. * @returns the name of this class
  70958. */
  70959. getClassName(): string;
  70960. /**
  70961. * Calls resetPose on the vrDisplay
  70962. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70963. */
  70964. resetToCurrentRotation(): void;
  70965. /**
  70966. * @hidden
  70967. * Updates the rig cameras (left and right eye)
  70968. */
  70969. _updateRigCameras(): void;
  70970. private _workingVector;
  70971. private _oneVector;
  70972. private _workingMatrix;
  70973. private updateCacheCalled;
  70974. private _correctPositionIfNotTrackPosition;
  70975. /**
  70976. * @hidden
  70977. * Updates the cached values of the camera
  70978. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70979. */
  70980. _updateCache(ignoreParentClass?: boolean): void;
  70981. /**
  70982. * @hidden
  70983. * Get current device position in babylon world
  70984. */
  70985. _computeDevicePosition(): void;
  70986. /**
  70987. * Updates the current device position and rotation in the babylon world
  70988. */
  70989. update(): void;
  70990. /**
  70991. * @hidden
  70992. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70993. * @returns an identity matrix
  70994. */
  70995. _getViewMatrix(): Matrix;
  70996. private _tmpMatrix;
  70997. /**
  70998. * This function is called by the two RIG cameras.
  70999. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71000. * @hidden
  71001. */
  71002. _getWebVRViewMatrix(): Matrix;
  71003. /** @hidden */
  71004. _getWebVRProjectionMatrix(): Matrix;
  71005. private _onGamepadConnectedObserver;
  71006. private _onGamepadDisconnectedObserver;
  71007. private _updateCacheWhenTrackingDisabledObserver;
  71008. /**
  71009. * Initializes the controllers and their meshes
  71010. */
  71011. initControllers(): void;
  71012. }
  71013. }
  71014. declare module BABYLON {
  71015. /**
  71016. * Size options for a post process
  71017. */
  71018. export type PostProcessOptions = {
  71019. width: number;
  71020. height: number;
  71021. };
  71022. /**
  71023. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71024. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71025. */
  71026. export class PostProcess {
  71027. /** Name of the PostProcess. */
  71028. name: string;
  71029. /**
  71030. * Gets or sets the unique id of the post process
  71031. */
  71032. uniqueId: number;
  71033. /**
  71034. * Width of the texture to apply the post process on
  71035. */
  71036. width: number;
  71037. /**
  71038. * Height of the texture to apply the post process on
  71039. */
  71040. height: number;
  71041. /**
  71042. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71043. * @hidden
  71044. */
  71045. _outputTexture: Nullable<InternalTexture>;
  71046. /**
  71047. * Sampling mode used by the shader
  71048. * See https://doc.babylonjs.com/classes/3.1/texture
  71049. */
  71050. renderTargetSamplingMode: number;
  71051. /**
  71052. * Clear color to use when screen clearing
  71053. */
  71054. clearColor: Color4;
  71055. /**
  71056. * If the buffer needs to be cleared before applying the post process. (default: true)
  71057. * Should be set to false if shader will overwrite all previous pixels.
  71058. */
  71059. autoClear: boolean;
  71060. /**
  71061. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71062. */
  71063. alphaMode: number;
  71064. /**
  71065. * Sets the setAlphaBlendConstants of the babylon engine
  71066. */
  71067. alphaConstants: Color4;
  71068. /**
  71069. * Animations to be used for the post processing
  71070. */
  71071. animations: Animation[];
  71072. /**
  71073. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71074. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71075. */
  71076. enablePixelPerfectMode: boolean;
  71077. /**
  71078. * Force the postprocess to be applied without taking in account viewport
  71079. */
  71080. forceFullscreenViewport: boolean;
  71081. /**
  71082. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71083. *
  71084. * | Value | Type | Description |
  71085. * | ----- | ----------------------------------- | ----------- |
  71086. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71087. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71088. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71089. *
  71090. */
  71091. scaleMode: number;
  71092. /**
  71093. * Force textures to be a power of two (default: false)
  71094. */
  71095. alwaysForcePOT: boolean;
  71096. private _samples;
  71097. /**
  71098. * Number of sample textures (default: 1)
  71099. */
  71100. samples: number;
  71101. /**
  71102. * Modify the scale of the post process to be the same as the viewport (default: false)
  71103. */
  71104. adaptScaleToCurrentViewport: boolean;
  71105. private _camera;
  71106. private _scene;
  71107. private _engine;
  71108. private _options;
  71109. private _reusable;
  71110. private _textureType;
  71111. /**
  71112. * Smart array of input and output textures for the post process.
  71113. * @hidden
  71114. */
  71115. _textures: SmartArray<InternalTexture>;
  71116. /**
  71117. * The index in _textures that corresponds to the output texture.
  71118. * @hidden
  71119. */
  71120. _currentRenderTextureInd: number;
  71121. private _effect;
  71122. private _samplers;
  71123. private _fragmentUrl;
  71124. private _vertexUrl;
  71125. private _parameters;
  71126. private _scaleRatio;
  71127. protected _indexParameters: any;
  71128. private _shareOutputWithPostProcess;
  71129. private _texelSize;
  71130. private _forcedOutputTexture;
  71131. /**
  71132. * Returns the fragment url or shader name used in the post process.
  71133. * @returns the fragment url or name in the shader store.
  71134. */
  71135. getEffectName(): string;
  71136. /**
  71137. * An event triggered when the postprocess is activated.
  71138. */
  71139. onActivateObservable: Observable<Camera>;
  71140. private _onActivateObserver;
  71141. /**
  71142. * A function that is added to the onActivateObservable
  71143. */
  71144. onActivate: Nullable<(camera: Camera) => void>;
  71145. /**
  71146. * An event triggered when the postprocess changes its size.
  71147. */
  71148. onSizeChangedObservable: Observable<PostProcess>;
  71149. private _onSizeChangedObserver;
  71150. /**
  71151. * A function that is added to the onSizeChangedObservable
  71152. */
  71153. onSizeChanged: (postProcess: PostProcess) => void;
  71154. /**
  71155. * An event triggered when the postprocess applies its effect.
  71156. */
  71157. onApplyObservable: Observable<Effect>;
  71158. private _onApplyObserver;
  71159. /**
  71160. * A function that is added to the onApplyObservable
  71161. */
  71162. onApply: (effect: Effect) => void;
  71163. /**
  71164. * An event triggered before rendering the postprocess
  71165. */
  71166. onBeforeRenderObservable: Observable<Effect>;
  71167. private _onBeforeRenderObserver;
  71168. /**
  71169. * A function that is added to the onBeforeRenderObservable
  71170. */
  71171. onBeforeRender: (effect: Effect) => void;
  71172. /**
  71173. * An event triggered after rendering the postprocess
  71174. */
  71175. onAfterRenderObservable: Observable<Effect>;
  71176. private _onAfterRenderObserver;
  71177. /**
  71178. * A function that is added to the onAfterRenderObservable
  71179. */
  71180. onAfterRender: (efect: Effect) => void;
  71181. /**
  71182. * 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
  71183. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71184. */
  71185. inputTexture: InternalTexture;
  71186. /**
  71187. * Gets the camera which post process is applied to.
  71188. * @returns The camera the post process is applied to.
  71189. */
  71190. getCamera(): Camera;
  71191. /**
  71192. * Gets the texel size of the postprocess.
  71193. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71194. */
  71195. readonly texelSize: Vector2;
  71196. /**
  71197. * Creates a new instance PostProcess
  71198. * @param name The name of the PostProcess.
  71199. * @param fragmentUrl The url of the fragment shader to be used.
  71200. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71201. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71202. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71203. * @param camera The camera to apply the render pass to.
  71204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71205. * @param engine The engine which the post process will be applied. (default: current engine)
  71206. * @param reusable If the post process can be reused on the same frame. (default: false)
  71207. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71208. * @param textureType Type of textures used when performing the post process. (default: 0)
  71209. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71210. * @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
  71211. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71212. */
  71213. constructor(
  71214. /** Name of the PostProcess. */
  71215. 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);
  71216. /**
  71217. * Gets a string idenfifying the name of the class
  71218. * @returns "PostProcess" string
  71219. */
  71220. getClassName(): string;
  71221. /**
  71222. * Gets the engine which this post process belongs to.
  71223. * @returns The engine the post process was enabled with.
  71224. */
  71225. getEngine(): Engine;
  71226. /**
  71227. * The effect that is created when initializing the post process.
  71228. * @returns The created effect corrisponding the the postprocess.
  71229. */
  71230. getEffect(): Effect;
  71231. /**
  71232. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71233. * @param postProcess The post process to share the output with.
  71234. * @returns This post process.
  71235. */
  71236. shareOutputWith(postProcess: PostProcess): PostProcess;
  71237. /**
  71238. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71239. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71240. */
  71241. useOwnOutput(): void;
  71242. /**
  71243. * Updates the effect with the current post process compile time values and recompiles the shader.
  71244. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71245. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71246. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71247. * @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
  71248. * @param onCompiled Called when the shader has been compiled.
  71249. * @param onError Called if there is an error when compiling a shader.
  71250. */
  71251. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71252. /**
  71253. * The post process is reusable if it can be used multiple times within one frame.
  71254. * @returns If the post process is reusable
  71255. */
  71256. isReusable(): boolean;
  71257. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71258. markTextureDirty(): void;
  71259. /**
  71260. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71261. * 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.
  71262. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71263. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71264. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71265. * @returns The target texture that was bound to be written to.
  71266. */
  71267. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71268. /**
  71269. * If the post process is supported.
  71270. */
  71271. readonly isSupported: boolean;
  71272. /**
  71273. * The aspect ratio of the output texture.
  71274. */
  71275. readonly aspectRatio: number;
  71276. /**
  71277. * Get a value indicating if the post-process is ready to be used
  71278. * @returns true if the post-process is ready (shader is compiled)
  71279. */
  71280. isReady(): boolean;
  71281. /**
  71282. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71283. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71284. */
  71285. apply(): Nullable<Effect>;
  71286. private _disposeTextures;
  71287. /**
  71288. * Disposes the post process.
  71289. * @param camera The camera to dispose the post process on.
  71290. */
  71291. dispose(camera?: Camera): void;
  71292. }
  71293. }
  71294. declare module BABYLON {
  71295. /**
  71296. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71297. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71298. */
  71299. export class PostProcessManager {
  71300. private _scene;
  71301. private _indexBuffer;
  71302. private _vertexBuffers;
  71303. /**
  71304. * Creates a new instance PostProcess
  71305. * @param scene The scene that the post process is associated with.
  71306. */
  71307. constructor(scene: Scene);
  71308. private _prepareBuffers;
  71309. private _buildIndexBuffer;
  71310. /**
  71311. * Rebuilds the vertex buffers of the manager.
  71312. * @hidden
  71313. */
  71314. _rebuild(): void;
  71315. /**
  71316. * Prepares a frame to be run through a post process.
  71317. * @param sourceTexture The input texture to the post procesess. (default: null)
  71318. * @param postProcesses An array of post processes to be run. (default: null)
  71319. * @returns True if the post processes were able to be run.
  71320. * @hidden
  71321. */
  71322. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71323. /**
  71324. * Manually render a set of post processes to a texture.
  71325. * @param postProcesses An array of post processes to be run.
  71326. * @param targetTexture The target texture to render to.
  71327. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71328. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71329. * @param lodLevel defines which lod of the texture to render to
  71330. */
  71331. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71332. /**
  71333. * Finalize the result of the output of the postprocesses.
  71334. * @param doNotPresent If true the result will not be displayed to the screen.
  71335. * @param targetTexture The target texture to render to.
  71336. * @param faceIndex The index of the face to bind the target texture to.
  71337. * @param postProcesses The array of post processes to render.
  71338. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71339. * @hidden
  71340. */
  71341. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71342. /**
  71343. * Disposes of the post process manager.
  71344. */
  71345. dispose(): void;
  71346. }
  71347. }
  71348. declare module BABYLON {
  71349. interface AbstractScene {
  71350. /**
  71351. * The list of layers (background and foreground) of the scene
  71352. */
  71353. layers: Array<Layer>;
  71354. }
  71355. /**
  71356. * Defines the layer scene component responsible to manage any layers
  71357. * in a given scene.
  71358. */
  71359. export class LayerSceneComponent implements ISceneComponent {
  71360. /**
  71361. * The component name helpfull to identify the component in the list of scene components.
  71362. */
  71363. readonly name: string;
  71364. /**
  71365. * The scene the component belongs to.
  71366. */
  71367. scene: Scene;
  71368. private _engine;
  71369. /**
  71370. * Creates a new instance of the component for the given scene
  71371. * @param scene Defines the scene to register the component in
  71372. */
  71373. constructor(scene: Scene);
  71374. /**
  71375. * Registers the component in a given scene
  71376. */
  71377. register(): void;
  71378. /**
  71379. * Rebuilds the elements related to this component in case of
  71380. * context lost for instance.
  71381. */
  71382. rebuild(): void;
  71383. /**
  71384. * Disposes the component and the associated ressources.
  71385. */
  71386. dispose(): void;
  71387. private _draw;
  71388. private _drawCameraPredicate;
  71389. private _drawCameraBackground;
  71390. private _drawCameraForeground;
  71391. private _drawRenderTargetPredicate;
  71392. private _drawRenderTargetBackground;
  71393. private _drawRenderTargetForeground;
  71394. }
  71395. }
  71396. declare module BABYLON {
  71397. /** @hidden */
  71398. export var layerPixelShader: {
  71399. name: string;
  71400. shader: string;
  71401. };
  71402. }
  71403. declare module BABYLON {
  71404. /** @hidden */
  71405. export var layerVertexShader: {
  71406. name: string;
  71407. shader: string;
  71408. };
  71409. }
  71410. declare module BABYLON {
  71411. /**
  71412. * This represents a full screen 2d layer.
  71413. * This can be useful to display a picture in the background of your scene for instance.
  71414. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71415. */
  71416. export class Layer {
  71417. /**
  71418. * Define the name of the layer.
  71419. */
  71420. name: string;
  71421. /**
  71422. * Define the texture the layer should display.
  71423. */
  71424. texture: Nullable<Texture>;
  71425. /**
  71426. * Is the layer in background or foreground.
  71427. */
  71428. isBackground: boolean;
  71429. /**
  71430. * Define the color of the layer (instead of texture).
  71431. */
  71432. color: Color4;
  71433. /**
  71434. * Define the scale of the layer in order to zoom in out of the texture.
  71435. */
  71436. scale: Vector2;
  71437. /**
  71438. * Define an offset for the layer in order to shift the texture.
  71439. */
  71440. offset: Vector2;
  71441. /**
  71442. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71443. */
  71444. alphaBlendingMode: number;
  71445. /**
  71446. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71447. * Alpha test will not mix with the background color in case of transparency.
  71448. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71449. */
  71450. alphaTest: boolean;
  71451. /**
  71452. * Define a mask to restrict the layer to only some of the scene cameras.
  71453. */
  71454. layerMask: number;
  71455. /**
  71456. * Define the list of render target the layer is visible into.
  71457. */
  71458. renderTargetTextures: RenderTargetTexture[];
  71459. /**
  71460. * Define if the layer is only used in renderTarget or if it also
  71461. * renders in the main frame buffer of the canvas.
  71462. */
  71463. renderOnlyInRenderTargetTextures: boolean;
  71464. private _scene;
  71465. private _vertexBuffers;
  71466. private _indexBuffer;
  71467. private _effect;
  71468. private _alphaTestEffect;
  71469. /**
  71470. * An event triggered when the layer is disposed.
  71471. */
  71472. onDisposeObservable: Observable<Layer>;
  71473. private _onDisposeObserver;
  71474. /**
  71475. * Back compatibility with callback before the onDisposeObservable existed.
  71476. * The set callback will be triggered when the layer has been disposed.
  71477. */
  71478. onDispose: () => void;
  71479. /**
  71480. * An event triggered before rendering the scene
  71481. */
  71482. onBeforeRenderObservable: Observable<Layer>;
  71483. private _onBeforeRenderObserver;
  71484. /**
  71485. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71486. * The set callback will be triggered just before rendering the layer.
  71487. */
  71488. onBeforeRender: () => void;
  71489. /**
  71490. * An event triggered after rendering the scene
  71491. */
  71492. onAfterRenderObservable: Observable<Layer>;
  71493. private _onAfterRenderObserver;
  71494. /**
  71495. * Back compatibility with callback before the onAfterRenderObservable existed.
  71496. * The set callback will be triggered just after rendering the layer.
  71497. */
  71498. onAfterRender: () => void;
  71499. /**
  71500. * Instantiates a new layer.
  71501. * This represents a full screen 2d layer.
  71502. * This can be useful to display a picture in the background of your scene for instance.
  71503. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71504. * @param name Define the name of the layer in the scene
  71505. * @param imgUrl Define the url of the texture to display in the layer
  71506. * @param scene Define the scene the layer belongs to
  71507. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71508. * @param color Defines a color for the layer
  71509. */
  71510. constructor(
  71511. /**
  71512. * Define the name of the layer.
  71513. */
  71514. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71515. private _createIndexBuffer;
  71516. /** @hidden */
  71517. _rebuild(): void;
  71518. /**
  71519. * Renders the layer in the scene.
  71520. */
  71521. render(): void;
  71522. /**
  71523. * Disposes and releases the associated ressources.
  71524. */
  71525. dispose(): void;
  71526. }
  71527. }
  71528. declare module BABYLON {
  71529. interface AbstractScene {
  71530. /**
  71531. * The list of procedural textures added to the scene
  71532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71533. */
  71534. proceduralTextures: Array<ProceduralTexture>;
  71535. }
  71536. /**
  71537. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71538. * in a given scene.
  71539. */
  71540. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71541. /**
  71542. * The component name helpfull to identify the component in the list of scene components.
  71543. */
  71544. readonly name: string;
  71545. /**
  71546. * The scene the component belongs to.
  71547. */
  71548. scene: Scene;
  71549. /**
  71550. * Creates a new instance of the component for the given scene
  71551. * @param scene Defines the scene to register the component in
  71552. */
  71553. constructor(scene: Scene);
  71554. /**
  71555. * Registers the component in a given scene
  71556. */
  71557. register(): void;
  71558. /**
  71559. * Rebuilds the elements related to this component in case of
  71560. * context lost for instance.
  71561. */
  71562. rebuild(): void;
  71563. /**
  71564. * Disposes the component and the associated ressources.
  71565. */
  71566. dispose(): void;
  71567. private _beforeClear;
  71568. }
  71569. }
  71570. declare module BABYLON {
  71571. /** @hidden */
  71572. export var proceduralVertexShader: {
  71573. name: string;
  71574. shader: string;
  71575. };
  71576. }
  71577. declare module BABYLON {
  71578. /**
  71579. * 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.
  71580. * This is the base class of any Procedural texture and contains most of the shareable code.
  71581. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71582. */
  71583. export class ProceduralTexture extends Texture {
  71584. isCube: boolean;
  71585. /**
  71586. * Define if the texture is enabled or not (disabled texture will not render)
  71587. */
  71588. isEnabled: boolean;
  71589. /**
  71590. * Define if the texture must be cleared before rendering (default is true)
  71591. */
  71592. autoClear: boolean;
  71593. /**
  71594. * Callback called when the texture is generated
  71595. */
  71596. onGenerated: () => void;
  71597. /**
  71598. * Event raised when the texture is generated
  71599. */
  71600. onGeneratedObservable: Observable<ProceduralTexture>;
  71601. /** @hidden */
  71602. _generateMipMaps: boolean;
  71603. /** @hidden **/
  71604. _effect: Effect;
  71605. /** @hidden */
  71606. _textures: {
  71607. [key: string]: Texture;
  71608. };
  71609. private _size;
  71610. private _currentRefreshId;
  71611. private _refreshRate;
  71612. private _vertexBuffers;
  71613. private _indexBuffer;
  71614. private _uniforms;
  71615. private _samplers;
  71616. private _fragment;
  71617. private _floats;
  71618. private _ints;
  71619. private _floatsArrays;
  71620. private _colors3;
  71621. private _colors4;
  71622. private _vectors2;
  71623. private _vectors3;
  71624. private _matrices;
  71625. private _fallbackTexture;
  71626. private _fallbackTextureUsed;
  71627. private _engine;
  71628. private _cachedDefines;
  71629. private _contentUpdateId;
  71630. private _contentData;
  71631. /**
  71632. * Instantiates a new procedural texture.
  71633. * 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.
  71634. * This is the base class of any Procedural texture and contains most of the shareable code.
  71635. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71636. * @param name Define the name of the texture
  71637. * @param size Define the size of the texture to create
  71638. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71639. * @param scene Define the scene the texture belongs to
  71640. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71641. * @param generateMipMaps Define if the texture should creates mip maps or not
  71642. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71643. */
  71644. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71645. /**
  71646. * The effect that is created when initializing the post process.
  71647. * @returns The created effect corrisponding the the postprocess.
  71648. */
  71649. getEffect(): Effect;
  71650. /**
  71651. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71652. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71653. */
  71654. getContent(): Nullable<ArrayBufferView>;
  71655. private _createIndexBuffer;
  71656. /** @hidden */
  71657. _rebuild(): void;
  71658. /**
  71659. * Resets the texture in order to recreate its associated resources.
  71660. * This can be called in case of context loss
  71661. */
  71662. reset(): void;
  71663. protected _getDefines(): string;
  71664. /**
  71665. * Is the texture ready to be used ? (rendered at least once)
  71666. * @returns true if ready, otherwise, false.
  71667. */
  71668. isReady(): boolean;
  71669. /**
  71670. * Resets the refresh counter of the texture and start bak from scratch.
  71671. * Could be useful to regenerate the texture if it is setup to render only once.
  71672. */
  71673. resetRefreshCounter(): void;
  71674. /**
  71675. * Set the fragment shader to use in order to render the texture.
  71676. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71677. */
  71678. setFragment(fragment: any): void;
  71679. /**
  71680. * Define the refresh rate of the texture or the rendering frequency.
  71681. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71682. */
  71683. refreshRate: number;
  71684. /** @hidden */
  71685. _shouldRender(): boolean;
  71686. /**
  71687. * Get the size the texture is rendering at.
  71688. * @returns the size (texture is always squared)
  71689. */
  71690. getRenderSize(): number;
  71691. /**
  71692. * Resize the texture to new value.
  71693. * @param size Define the new size the texture should have
  71694. * @param generateMipMaps Define whether the new texture should create mip maps
  71695. */
  71696. resize(size: number, generateMipMaps: boolean): void;
  71697. private _checkUniform;
  71698. /**
  71699. * Set a texture in the shader program used to render.
  71700. * @param name Define the name of the uniform samplers as defined in the shader
  71701. * @param texture Define the texture to bind to this sampler
  71702. * @return the texture itself allowing "fluent" like uniform updates
  71703. */
  71704. setTexture(name: string, texture: Texture): ProceduralTexture;
  71705. /**
  71706. * Set a float in the shader.
  71707. * @param name Define the name of the uniform as defined in the shader
  71708. * @param value Define the value to give to the uniform
  71709. * @return the texture itself allowing "fluent" like uniform updates
  71710. */
  71711. setFloat(name: string, value: number): ProceduralTexture;
  71712. /**
  71713. * Set a int in the shader.
  71714. * @param name Define the name of the uniform as defined in the shader
  71715. * @param value Define the value to give to the uniform
  71716. * @return the texture itself allowing "fluent" like uniform updates
  71717. */
  71718. setInt(name: string, value: number): ProceduralTexture;
  71719. /**
  71720. * Set an array of floats in the shader.
  71721. * @param name Define the name of the uniform as defined in the shader
  71722. * @param value Define the value to give to the uniform
  71723. * @return the texture itself allowing "fluent" like uniform updates
  71724. */
  71725. setFloats(name: string, value: number[]): ProceduralTexture;
  71726. /**
  71727. * Set a vec3 in the shader from a Color3.
  71728. * @param name Define the name of the uniform as defined in the shader
  71729. * @param value Define the value to give to the uniform
  71730. * @return the texture itself allowing "fluent" like uniform updates
  71731. */
  71732. setColor3(name: string, value: Color3): ProceduralTexture;
  71733. /**
  71734. * Set a vec4 in the shader from a Color4.
  71735. * @param name Define the name of the uniform as defined in the shader
  71736. * @param value Define the value to give to the uniform
  71737. * @return the texture itself allowing "fluent" like uniform updates
  71738. */
  71739. setColor4(name: string, value: Color4): ProceduralTexture;
  71740. /**
  71741. * Set a vec2 in the shader from a Vector2.
  71742. * @param name Define the name of the uniform as defined in the shader
  71743. * @param value Define the value to give to the uniform
  71744. * @return the texture itself allowing "fluent" like uniform updates
  71745. */
  71746. setVector2(name: string, value: Vector2): ProceduralTexture;
  71747. /**
  71748. * Set a vec3 in the shader from a Vector3.
  71749. * @param name Define the name of the uniform as defined in the shader
  71750. * @param value Define the value to give to the uniform
  71751. * @return the texture itself allowing "fluent" like uniform updates
  71752. */
  71753. setVector3(name: string, value: Vector3): ProceduralTexture;
  71754. /**
  71755. * Set a mat4 in the shader from a MAtrix.
  71756. * @param name Define the name of the uniform as defined in the shader
  71757. * @param value Define the value to give to the uniform
  71758. * @return the texture itself allowing "fluent" like uniform updates
  71759. */
  71760. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71761. /**
  71762. * Render the texture to its associated render target.
  71763. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71764. */
  71765. render(useCameraPostProcess?: boolean): void;
  71766. /**
  71767. * Clone the texture.
  71768. * @returns the cloned texture
  71769. */
  71770. clone(): ProceduralTexture;
  71771. /**
  71772. * Dispose the texture and release its asoociated resources.
  71773. */
  71774. dispose(): void;
  71775. }
  71776. }
  71777. declare module BABYLON {
  71778. /**
  71779. * This represents the base class for particle system in Babylon.
  71780. * 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.
  71781. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71782. * @example https://doc.babylonjs.com/babylon101/particles
  71783. */
  71784. export class BaseParticleSystem {
  71785. /**
  71786. * Source color is added to the destination color without alpha affecting the result
  71787. */
  71788. static BLENDMODE_ONEONE: number;
  71789. /**
  71790. * Blend current color and particle color using particle’s alpha
  71791. */
  71792. static BLENDMODE_STANDARD: number;
  71793. /**
  71794. * Add current color and particle color multiplied by particle’s alpha
  71795. */
  71796. static BLENDMODE_ADD: number;
  71797. /**
  71798. * Multiply current color with particle color
  71799. */
  71800. static BLENDMODE_MULTIPLY: number;
  71801. /**
  71802. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71803. */
  71804. static BLENDMODE_MULTIPLYADD: number;
  71805. /**
  71806. * List of animations used by the particle system.
  71807. */
  71808. animations: Animation[];
  71809. /**
  71810. * The id of the Particle system.
  71811. */
  71812. id: string;
  71813. /**
  71814. * The friendly name of the Particle system.
  71815. */
  71816. name: string;
  71817. /**
  71818. * The rendering group used by the Particle system to chose when to render.
  71819. */
  71820. renderingGroupId: number;
  71821. /**
  71822. * The emitter represents the Mesh or position we are attaching the particle system to.
  71823. */
  71824. emitter: Nullable<AbstractMesh | Vector3>;
  71825. /**
  71826. * The maximum number of particles to emit per frame
  71827. */
  71828. emitRate: number;
  71829. /**
  71830. * If you want to launch only a few particles at once, that can be done, as well.
  71831. */
  71832. manualEmitCount: number;
  71833. /**
  71834. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71835. */
  71836. updateSpeed: number;
  71837. /**
  71838. * The amount of time the particle system is running (depends of the overall update speed).
  71839. */
  71840. targetStopDuration: number;
  71841. /**
  71842. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71843. */
  71844. disposeOnStop: boolean;
  71845. /**
  71846. * Minimum power of emitting particles.
  71847. */
  71848. minEmitPower: number;
  71849. /**
  71850. * Maximum power of emitting particles.
  71851. */
  71852. maxEmitPower: number;
  71853. /**
  71854. * Minimum life time of emitting particles.
  71855. */
  71856. minLifeTime: number;
  71857. /**
  71858. * Maximum life time of emitting particles.
  71859. */
  71860. maxLifeTime: number;
  71861. /**
  71862. * Minimum Size of emitting particles.
  71863. */
  71864. minSize: number;
  71865. /**
  71866. * Maximum Size of emitting particles.
  71867. */
  71868. maxSize: number;
  71869. /**
  71870. * Minimum scale of emitting particles on X axis.
  71871. */
  71872. minScaleX: number;
  71873. /**
  71874. * Maximum scale of emitting particles on X axis.
  71875. */
  71876. maxScaleX: number;
  71877. /**
  71878. * Minimum scale of emitting particles on Y axis.
  71879. */
  71880. minScaleY: number;
  71881. /**
  71882. * Maximum scale of emitting particles on Y axis.
  71883. */
  71884. maxScaleY: number;
  71885. /**
  71886. * Gets or sets the minimal initial rotation in radians.
  71887. */
  71888. minInitialRotation: number;
  71889. /**
  71890. * Gets or sets the maximal initial rotation in radians.
  71891. */
  71892. maxInitialRotation: number;
  71893. /**
  71894. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71895. */
  71896. minAngularSpeed: number;
  71897. /**
  71898. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71899. */
  71900. maxAngularSpeed: number;
  71901. /**
  71902. * The texture used to render each particle. (this can be a spritesheet)
  71903. */
  71904. particleTexture: Nullable<Texture>;
  71905. /**
  71906. * The layer mask we are rendering the particles through.
  71907. */
  71908. layerMask: number;
  71909. /**
  71910. * This can help using your own shader to render the particle system.
  71911. * The according effect will be created
  71912. */
  71913. customShader: any;
  71914. /**
  71915. * By default particle system starts as soon as they are created. This prevents the
  71916. * automatic start to happen and let you decide when to start emitting particles.
  71917. */
  71918. preventAutoStart: boolean;
  71919. private _noiseTexture;
  71920. /**
  71921. * Gets or sets a texture used to add random noise to particle positions
  71922. */
  71923. noiseTexture: Nullable<ProceduralTexture>;
  71924. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71925. noiseStrength: Vector3;
  71926. /**
  71927. * Callback triggered when the particle animation is ending.
  71928. */
  71929. onAnimationEnd: Nullable<() => void>;
  71930. /**
  71931. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71932. */
  71933. blendMode: number;
  71934. /**
  71935. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71936. * to override the particles.
  71937. */
  71938. forceDepthWrite: boolean;
  71939. /** 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 */
  71940. preWarmCycles: number;
  71941. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71942. preWarmStepOffset: number;
  71943. /**
  71944. * 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)
  71945. */
  71946. spriteCellChangeSpeed: number;
  71947. /**
  71948. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71949. */
  71950. startSpriteCellID: number;
  71951. /**
  71952. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71953. */
  71954. endSpriteCellID: number;
  71955. /**
  71956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71957. */
  71958. spriteCellWidth: number;
  71959. /**
  71960. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71961. */
  71962. spriteCellHeight: number;
  71963. /**
  71964. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71965. */
  71966. spriteRandomStartCell: boolean;
  71967. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71968. translationPivot: Vector2;
  71969. /** @hidden */
  71970. protected _isAnimationSheetEnabled: boolean;
  71971. /**
  71972. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71973. */
  71974. beginAnimationOnStart: boolean;
  71975. /**
  71976. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71977. */
  71978. beginAnimationFrom: number;
  71979. /**
  71980. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71981. */
  71982. beginAnimationTo: number;
  71983. /**
  71984. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71985. */
  71986. beginAnimationLoop: boolean;
  71987. /**
  71988. * Gets or sets a world offset applied to all particles
  71989. */
  71990. worldOffset: Vector3;
  71991. /**
  71992. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71993. */
  71994. isAnimationSheetEnabled: boolean;
  71995. /**
  71996. * Get hosting scene
  71997. * @returns the scene
  71998. */
  71999. getScene(): Scene;
  72000. /**
  72001. * You can use gravity if you want to give an orientation to your particles.
  72002. */
  72003. gravity: Vector3;
  72004. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72005. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72006. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72007. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72008. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72009. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72010. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72011. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72012. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72013. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72014. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72015. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72016. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72017. /**
  72018. * Defines the delay in milliseconds before starting the system (0 by default)
  72019. */
  72020. startDelay: number;
  72021. /**
  72022. * Gets the current list of drag gradients.
  72023. * You must use addDragGradient and removeDragGradient to udpate this list
  72024. * @returns the list of drag gradients
  72025. */
  72026. getDragGradients(): Nullable<Array<FactorGradient>>;
  72027. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72028. limitVelocityDamping: number;
  72029. /**
  72030. * Gets the current list of limit velocity gradients.
  72031. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72032. * @returns the list of limit velocity gradients
  72033. */
  72034. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72035. /**
  72036. * Gets the current list of color gradients.
  72037. * You must use addColorGradient and removeColorGradient to udpate this list
  72038. * @returns the list of color gradients
  72039. */
  72040. getColorGradients(): Nullable<Array<ColorGradient>>;
  72041. /**
  72042. * Gets the current list of size gradients.
  72043. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72044. * @returns the list of size gradients
  72045. */
  72046. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72047. /**
  72048. * Gets the current list of color remap gradients.
  72049. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72050. * @returns the list of color remap gradients
  72051. */
  72052. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72053. /**
  72054. * Gets the current list of alpha remap gradients.
  72055. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72056. * @returns the list of alpha remap gradients
  72057. */
  72058. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72059. /**
  72060. * Gets the current list of life time gradients.
  72061. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72062. * @returns the list of life time gradients
  72063. */
  72064. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72065. /**
  72066. * Gets the current list of angular speed gradients.
  72067. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72068. * @returns the list of angular speed gradients
  72069. */
  72070. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72071. /**
  72072. * Gets the current list of velocity gradients.
  72073. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72074. * @returns the list of velocity gradients
  72075. */
  72076. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72077. /**
  72078. * Gets the current list of start size gradients.
  72079. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72080. * @returns the list of start size gradients
  72081. */
  72082. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72083. /**
  72084. * Gets the current list of emit rate gradients.
  72085. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72086. * @returns the list of emit rate gradients
  72087. */
  72088. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72089. /**
  72090. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72091. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72092. */
  72093. direction1: Vector3;
  72094. /**
  72095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72097. */
  72098. direction2: Vector3;
  72099. /**
  72100. * 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.
  72101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72102. */
  72103. minEmitBox: Vector3;
  72104. /**
  72105. * 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.
  72106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72107. */
  72108. maxEmitBox: Vector3;
  72109. /**
  72110. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72111. */
  72112. color1: Color4;
  72113. /**
  72114. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72115. */
  72116. color2: Color4;
  72117. /**
  72118. * Color the particle will have at the end of its lifetime
  72119. */
  72120. colorDead: Color4;
  72121. /**
  72122. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72123. */
  72124. textureMask: Color4;
  72125. /**
  72126. * The particle emitter type defines the emitter used by the particle system.
  72127. * It can be for example box, sphere, or cone...
  72128. */
  72129. particleEmitterType: IParticleEmitterType;
  72130. /** @hidden */
  72131. _isSubEmitter: boolean;
  72132. /**
  72133. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72134. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72135. */
  72136. billboardMode: number;
  72137. protected _isBillboardBased: boolean;
  72138. /**
  72139. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72140. */
  72141. isBillboardBased: boolean;
  72142. /**
  72143. * The scene the particle system belongs to.
  72144. */
  72145. protected _scene: Scene;
  72146. /**
  72147. * Local cache of defines for image processing.
  72148. */
  72149. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72150. /**
  72151. * Default configuration related to image processing available in the standard Material.
  72152. */
  72153. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72154. /**
  72155. * Gets the image processing configuration used either in this material.
  72156. */
  72157. /**
  72158. * Sets the Default image processing configuration used either in the this material.
  72159. *
  72160. * If sets to null, the scene one is in use.
  72161. */
  72162. imageProcessingConfiguration: ImageProcessingConfiguration;
  72163. /**
  72164. * Attaches a new image processing configuration to the Standard Material.
  72165. * @param configuration
  72166. */
  72167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72168. /** @hidden */
  72169. protected _reset(): void;
  72170. /** @hidden */
  72171. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72172. /**
  72173. * Instantiates a particle system.
  72174. * 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.
  72175. * @param name The name of the particle system
  72176. */
  72177. constructor(name: string);
  72178. /**
  72179. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72182. * @returns the emitter
  72183. */
  72184. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72185. /**
  72186. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72187. * @param radius The radius of the hemisphere to emit from
  72188. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72189. * @returns the emitter
  72190. */
  72191. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72192. /**
  72193. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72194. * @param radius The radius of the sphere to emit from
  72195. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72196. * @returns the emitter
  72197. */
  72198. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72199. /**
  72200. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72201. * @param radius The radius of the sphere to emit from
  72202. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72203. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72204. * @returns the emitter
  72205. */
  72206. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72207. /**
  72208. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72209. * @param radius The radius of the emission cylinder
  72210. * @param height The height of the emission cylinder
  72211. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72212. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72213. * @returns the emitter
  72214. */
  72215. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72216. /**
  72217. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72218. * @param radius The radius of the cylinder to emit from
  72219. * @param height The height of the emission cylinder
  72220. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72223. * @returns the emitter
  72224. */
  72225. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72226. /**
  72227. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72228. * @param radius The radius of the cone to emit from
  72229. * @param angle The base angle of the cone
  72230. * @returns the emitter
  72231. */
  72232. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72233. /**
  72234. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72237. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72238. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72239. * @returns the emitter
  72240. */
  72241. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72242. }
  72243. }
  72244. declare module BABYLON {
  72245. /**
  72246. * Type of sub emitter
  72247. */
  72248. export enum SubEmitterType {
  72249. /**
  72250. * Attached to the particle over it's lifetime
  72251. */
  72252. ATTACHED = 0,
  72253. /**
  72254. * Created when the particle dies
  72255. */
  72256. END = 1
  72257. }
  72258. /**
  72259. * Sub emitter class used to emit particles from an existing particle
  72260. */
  72261. export class SubEmitter {
  72262. /**
  72263. * the particle system to be used by the sub emitter
  72264. */
  72265. particleSystem: ParticleSystem;
  72266. /**
  72267. * Type of the submitter (Default: END)
  72268. */
  72269. type: SubEmitterType;
  72270. /**
  72271. * 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)
  72272. * Note: This only is supported when using an emitter of type Mesh
  72273. */
  72274. inheritDirection: boolean;
  72275. /**
  72276. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72277. */
  72278. inheritedVelocityAmount: number;
  72279. /**
  72280. * Creates a sub emitter
  72281. * @param particleSystem the particle system to be used by the sub emitter
  72282. */
  72283. constructor(
  72284. /**
  72285. * the particle system to be used by the sub emitter
  72286. */
  72287. particleSystem: ParticleSystem);
  72288. /**
  72289. * Clones the sub emitter
  72290. * @returns the cloned sub emitter
  72291. */
  72292. clone(): SubEmitter;
  72293. /**
  72294. * Serialize current object to a JSON object
  72295. * @returns the serialized object
  72296. */
  72297. serialize(): any;
  72298. /** @hidden */
  72299. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72300. /**
  72301. * Creates a new SubEmitter from a serialized JSON version
  72302. * @param serializationObject defines the JSON object to read from
  72303. * @param scene defines the hosting scene
  72304. * @param rootUrl defines the rootUrl for data loading
  72305. * @returns a new SubEmitter
  72306. */
  72307. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72308. /** Release associated resources */
  72309. dispose(): void;
  72310. }
  72311. }
  72312. declare module BABYLON {
  72313. /** @hidden */
  72314. export var clipPlaneFragmentDeclaration: {
  72315. name: string;
  72316. shader: string;
  72317. };
  72318. }
  72319. declare module BABYLON {
  72320. /** @hidden */
  72321. export var imageProcessingDeclaration: {
  72322. name: string;
  72323. shader: string;
  72324. };
  72325. }
  72326. declare module BABYLON {
  72327. /** @hidden */
  72328. export var imageProcessingFunctions: {
  72329. name: string;
  72330. shader: string;
  72331. };
  72332. }
  72333. declare module BABYLON {
  72334. /** @hidden */
  72335. export var clipPlaneFragment: {
  72336. name: string;
  72337. shader: string;
  72338. };
  72339. }
  72340. declare module BABYLON {
  72341. /** @hidden */
  72342. export var particlesPixelShader: {
  72343. name: string;
  72344. shader: string;
  72345. };
  72346. }
  72347. declare module BABYLON {
  72348. /** @hidden */
  72349. export var clipPlaneVertexDeclaration: {
  72350. name: string;
  72351. shader: string;
  72352. };
  72353. }
  72354. declare module BABYLON {
  72355. /** @hidden */
  72356. export var clipPlaneVertex: {
  72357. name: string;
  72358. shader: string;
  72359. };
  72360. }
  72361. declare module BABYLON {
  72362. /** @hidden */
  72363. export var particlesVertexShader: {
  72364. name: string;
  72365. shader: string;
  72366. };
  72367. }
  72368. declare module BABYLON {
  72369. /**
  72370. * This represents a particle system in Babylon.
  72371. * 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.
  72372. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72373. * @example https://doc.babylonjs.com/babylon101/particles
  72374. */
  72375. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72376. /**
  72377. * Billboard mode will only apply to Y axis
  72378. */
  72379. static readonly BILLBOARDMODE_Y: number;
  72380. /**
  72381. * Billboard mode will apply to all axes
  72382. */
  72383. static readonly BILLBOARDMODE_ALL: number;
  72384. /**
  72385. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72386. */
  72387. static readonly BILLBOARDMODE_STRETCHED: number;
  72388. /**
  72389. * This function can be defined to provide custom update for active particles.
  72390. * This function will be called instead of regular update (age, position, color, etc.).
  72391. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72392. */
  72393. updateFunction: (particles: Particle[]) => void;
  72394. private _emitterWorldMatrix;
  72395. /**
  72396. * This function can be defined to specify initial direction for every new particle.
  72397. * It by default use the emitterType defined function
  72398. */
  72399. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72400. /**
  72401. * This function can be defined to specify initial position for every new particle.
  72402. * It by default use the emitterType defined function
  72403. */
  72404. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72405. /**
  72406. * @hidden
  72407. */
  72408. _inheritedVelocityOffset: Vector3;
  72409. /**
  72410. * An event triggered when the system is disposed
  72411. */
  72412. onDisposeObservable: Observable<ParticleSystem>;
  72413. private _onDisposeObserver;
  72414. /**
  72415. * Sets a callback that will be triggered when the system is disposed
  72416. */
  72417. onDispose: () => void;
  72418. private _particles;
  72419. private _epsilon;
  72420. private _capacity;
  72421. private _stockParticles;
  72422. private _newPartsExcess;
  72423. private _vertexData;
  72424. private _vertexBuffer;
  72425. private _vertexBuffers;
  72426. private _spriteBuffer;
  72427. private _indexBuffer;
  72428. private _effect;
  72429. private _customEffect;
  72430. private _cachedDefines;
  72431. private _scaledColorStep;
  72432. private _colorDiff;
  72433. private _scaledDirection;
  72434. private _scaledGravity;
  72435. private _currentRenderId;
  72436. private _alive;
  72437. private _useInstancing;
  72438. private _started;
  72439. private _stopped;
  72440. private _actualFrame;
  72441. private _scaledUpdateSpeed;
  72442. private _vertexBufferSize;
  72443. /** @hidden */
  72444. _currentEmitRateGradient: Nullable<FactorGradient>;
  72445. /** @hidden */
  72446. _currentEmitRate1: number;
  72447. /** @hidden */
  72448. _currentEmitRate2: number;
  72449. /** @hidden */
  72450. _currentStartSizeGradient: Nullable<FactorGradient>;
  72451. /** @hidden */
  72452. _currentStartSize1: number;
  72453. /** @hidden */
  72454. _currentStartSize2: number;
  72455. private readonly _rawTextureWidth;
  72456. private _rampGradientsTexture;
  72457. private _useRampGradients;
  72458. /** Gets or sets a boolean indicating that ramp gradients must be used
  72459. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72460. */
  72461. useRampGradients: boolean;
  72462. /**
  72463. * 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.
  72464. * 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: [])
  72465. */
  72466. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72467. private _subEmitters;
  72468. /**
  72469. * @hidden
  72470. * If the particle systems emitter should be disposed when the particle system is disposed
  72471. */
  72472. _disposeEmitterOnDispose: boolean;
  72473. /**
  72474. * The current active Sub-systems, this property is used by the root particle system only.
  72475. */
  72476. activeSubSystems: Array<ParticleSystem>;
  72477. private _rootParticleSystem;
  72478. /**
  72479. * Gets the current list of active particles
  72480. */
  72481. readonly particles: Particle[];
  72482. /**
  72483. * Returns the string "ParticleSystem"
  72484. * @returns a string containing the class name
  72485. */
  72486. getClassName(): string;
  72487. /**
  72488. * Instantiates a particle system.
  72489. * 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.
  72490. * @param name The name of the particle system
  72491. * @param capacity The max number of particles alive at the same time
  72492. * @param scene The scene the particle system belongs to
  72493. * @param customEffect a custom effect used to change the way particles are rendered by default
  72494. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72495. * @param epsilon Offset used to render the particles
  72496. */
  72497. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72498. private _addFactorGradient;
  72499. private _removeFactorGradient;
  72500. /**
  72501. * Adds a new life time gradient
  72502. * @param gradient defines the gradient to use (between 0 and 1)
  72503. * @param factor defines the life time factor to affect to the specified gradient
  72504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72505. * @returns the current particle system
  72506. */
  72507. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72508. /**
  72509. * Remove a specific life time gradient
  72510. * @param gradient defines the gradient to remove
  72511. * @returns the current particle system
  72512. */
  72513. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72514. /**
  72515. * Adds a new size gradient
  72516. * @param gradient defines the gradient to use (between 0 and 1)
  72517. * @param factor defines the size factor to affect to the specified gradient
  72518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72519. * @returns the current particle system
  72520. */
  72521. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72522. /**
  72523. * Remove a specific size gradient
  72524. * @param gradient defines the gradient to remove
  72525. * @returns the current particle system
  72526. */
  72527. removeSizeGradient(gradient: number): IParticleSystem;
  72528. /**
  72529. * Adds a new color remap gradient
  72530. * @param gradient defines the gradient to use (between 0 and 1)
  72531. * @param min defines the color remap minimal range
  72532. * @param max defines the color remap maximal range
  72533. * @returns the current particle system
  72534. */
  72535. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72536. /**
  72537. * Remove a specific color remap gradient
  72538. * @param gradient defines the gradient to remove
  72539. * @returns the current particle system
  72540. */
  72541. removeColorRemapGradient(gradient: number): IParticleSystem;
  72542. /**
  72543. * Adds a new alpha remap gradient
  72544. * @param gradient defines the gradient to use (between 0 and 1)
  72545. * @param min defines the alpha remap minimal range
  72546. * @param max defines the alpha remap maximal range
  72547. * @returns the current particle system
  72548. */
  72549. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72550. /**
  72551. * Remove a specific alpha remap gradient
  72552. * @param gradient defines the gradient to remove
  72553. * @returns the current particle system
  72554. */
  72555. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72556. /**
  72557. * Adds a new angular speed gradient
  72558. * @param gradient defines the gradient to use (between 0 and 1)
  72559. * @param factor defines the angular speed to affect to the specified gradient
  72560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72561. * @returns the current particle system
  72562. */
  72563. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72564. /**
  72565. * Remove a specific angular speed gradient
  72566. * @param gradient defines the gradient to remove
  72567. * @returns the current particle system
  72568. */
  72569. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72570. /**
  72571. * Adds a new velocity gradient
  72572. * @param gradient defines the gradient to use (between 0 and 1)
  72573. * @param factor defines the velocity to affect to the specified gradient
  72574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72575. * @returns the current particle system
  72576. */
  72577. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72578. /**
  72579. * Remove a specific velocity gradient
  72580. * @param gradient defines the gradient to remove
  72581. * @returns the current particle system
  72582. */
  72583. removeVelocityGradient(gradient: number): IParticleSystem;
  72584. /**
  72585. * Adds a new limit velocity gradient
  72586. * @param gradient defines the gradient to use (between 0 and 1)
  72587. * @param factor defines the limit velocity value to affect to the specified gradient
  72588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72589. * @returns the current particle system
  72590. */
  72591. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72592. /**
  72593. * Remove a specific limit velocity gradient
  72594. * @param gradient defines the gradient to remove
  72595. * @returns the current particle system
  72596. */
  72597. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72598. /**
  72599. * Adds a new drag gradient
  72600. * @param gradient defines the gradient to use (between 0 and 1)
  72601. * @param factor defines the drag value to affect to the specified gradient
  72602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72603. * @returns the current particle system
  72604. */
  72605. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72606. /**
  72607. * Remove a specific drag gradient
  72608. * @param gradient defines the gradient to remove
  72609. * @returns the current particle system
  72610. */
  72611. removeDragGradient(gradient: number): IParticleSystem;
  72612. /**
  72613. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72614. * @param gradient defines the gradient to use (between 0 and 1)
  72615. * @param factor defines the emit rate value to affect to the specified gradient
  72616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72617. * @returns the current particle system
  72618. */
  72619. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72620. /**
  72621. * Remove a specific emit rate gradient
  72622. * @param gradient defines the gradient to remove
  72623. * @returns the current particle system
  72624. */
  72625. removeEmitRateGradient(gradient: number): IParticleSystem;
  72626. /**
  72627. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72628. * @param gradient defines the gradient to use (between 0 and 1)
  72629. * @param factor defines the start size value to affect to the specified gradient
  72630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72631. * @returns the current particle system
  72632. */
  72633. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72634. /**
  72635. * Remove a specific start size gradient
  72636. * @param gradient defines the gradient to remove
  72637. * @returns the current particle system
  72638. */
  72639. removeStartSizeGradient(gradient: number): IParticleSystem;
  72640. private _createRampGradientTexture;
  72641. /**
  72642. * Gets the current list of ramp gradients.
  72643. * You must use addRampGradient and removeRampGradient to udpate this list
  72644. * @returns the list of ramp gradients
  72645. */
  72646. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72647. /**
  72648. * Adds a new ramp gradient used to remap particle colors
  72649. * @param gradient defines the gradient to use (between 0 and 1)
  72650. * @param color defines the color to affect to the specified gradient
  72651. * @returns the current particle system
  72652. */
  72653. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72654. /**
  72655. * Remove a specific ramp gradient
  72656. * @param gradient defines the gradient to remove
  72657. * @returns the current particle system
  72658. */
  72659. removeRampGradient(gradient: number): ParticleSystem;
  72660. /**
  72661. * Adds a new color gradient
  72662. * @param gradient defines the gradient to use (between 0 and 1)
  72663. * @param color1 defines the color to affect to the specified gradient
  72664. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72665. * @returns this particle system
  72666. */
  72667. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72668. /**
  72669. * Remove a specific color gradient
  72670. * @param gradient defines the gradient to remove
  72671. * @returns this particle system
  72672. */
  72673. removeColorGradient(gradient: number): IParticleSystem;
  72674. private _fetchR;
  72675. protected _reset(): void;
  72676. private _resetEffect;
  72677. private _createVertexBuffers;
  72678. private _createIndexBuffer;
  72679. /**
  72680. * Gets the maximum number of particles active at the same time.
  72681. * @returns The max number of active particles.
  72682. */
  72683. getCapacity(): number;
  72684. /**
  72685. * Gets whether there are still active particles in the system.
  72686. * @returns True if it is alive, otherwise false.
  72687. */
  72688. isAlive(): boolean;
  72689. /**
  72690. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72691. * @returns True if it has been started, otherwise false.
  72692. */
  72693. isStarted(): boolean;
  72694. private _prepareSubEmitterInternalArray;
  72695. /**
  72696. * Starts the particle system and begins to emit
  72697. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72698. */
  72699. start(delay?: number): void;
  72700. /**
  72701. * Stops the particle system.
  72702. * @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.
  72703. */
  72704. stop(stopSubEmitters?: boolean): void;
  72705. /**
  72706. * Remove all active particles
  72707. */
  72708. reset(): void;
  72709. /**
  72710. * @hidden (for internal use only)
  72711. */
  72712. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72713. /**
  72714. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72715. * Its lifetime will start back at 0.
  72716. */
  72717. recycleParticle: (particle: Particle) => void;
  72718. private _stopSubEmitters;
  72719. private _createParticle;
  72720. private _removeFromRoot;
  72721. private _emitFromParticle;
  72722. private _update;
  72723. /** @hidden */
  72724. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72725. /** @hidden */
  72726. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72727. /** @hidden */
  72728. private _getEffect;
  72729. /**
  72730. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72731. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72732. */
  72733. animate(preWarmOnly?: boolean): void;
  72734. private _appendParticleVertices;
  72735. /**
  72736. * Rebuilds the particle system.
  72737. */
  72738. rebuild(): void;
  72739. /**
  72740. * Is this system ready to be used/rendered
  72741. * @return true if the system is ready
  72742. */
  72743. isReady(): boolean;
  72744. private _render;
  72745. /**
  72746. * Renders the particle system in its current state.
  72747. * @returns the current number of particles
  72748. */
  72749. render(): number;
  72750. /**
  72751. * Disposes the particle system and free the associated resources
  72752. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72753. */
  72754. dispose(disposeTexture?: boolean): void;
  72755. /**
  72756. * Clones the particle system.
  72757. * @param name The name of the cloned object
  72758. * @param newEmitter The new emitter to use
  72759. * @returns the cloned particle system
  72760. */
  72761. clone(name: string, newEmitter: any): ParticleSystem;
  72762. /**
  72763. * Serializes the particle system to a JSON object.
  72764. * @returns the JSON object
  72765. */
  72766. serialize(): any;
  72767. /** @hidden */
  72768. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72769. /** @hidden */
  72770. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72771. /**
  72772. * Parses a JSON object to create a particle system.
  72773. * @param parsedParticleSystem The JSON object to parse
  72774. * @param scene The scene to create the particle system in
  72775. * @param rootUrl The root url to use to load external dependencies like texture
  72776. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72777. * @returns the Parsed particle system
  72778. */
  72779. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72780. }
  72781. }
  72782. declare module BABYLON {
  72783. /**
  72784. * A particle represents one of the element emitted by a particle system.
  72785. * This is mainly define by its coordinates, direction, velocity and age.
  72786. */
  72787. export class Particle {
  72788. /**
  72789. * The particle system the particle belongs to.
  72790. */
  72791. particleSystem: ParticleSystem;
  72792. private static _Count;
  72793. /**
  72794. * Unique ID of the particle
  72795. */
  72796. id: number;
  72797. /**
  72798. * The world position of the particle in the scene.
  72799. */
  72800. position: Vector3;
  72801. /**
  72802. * The world direction of the particle in the scene.
  72803. */
  72804. direction: Vector3;
  72805. /**
  72806. * The color of the particle.
  72807. */
  72808. color: Color4;
  72809. /**
  72810. * The color change of the particle per step.
  72811. */
  72812. colorStep: Color4;
  72813. /**
  72814. * Defines how long will the life of the particle be.
  72815. */
  72816. lifeTime: number;
  72817. /**
  72818. * The current age of the particle.
  72819. */
  72820. age: number;
  72821. /**
  72822. * The current size of the particle.
  72823. */
  72824. size: number;
  72825. /**
  72826. * The current scale of the particle.
  72827. */
  72828. scale: Vector2;
  72829. /**
  72830. * The current angle of the particle.
  72831. */
  72832. angle: number;
  72833. /**
  72834. * Defines how fast is the angle changing.
  72835. */
  72836. angularSpeed: number;
  72837. /**
  72838. * Defines the cell index used by the particle to be rendered from a sprite.
  72839. */
  72840. cellIndex: number;
  72841. /**
  72842. * The information required to support color remapping
  72843. */
  72844. remapData: Vector4;
  72845. /** @hidden */
  72846. _randomCellOffset?: number;
  72847. /** @hidden */
  72848. _initialDirection: Nullable<Vector3>;
  72849. /** @hidden */
  72850. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72851. /** @hidden */
  72852. _initialStartSpriteCellID: number;
  72853. /** @hidden */
  72854. _initialEndSpriteCellID: number;
  72855. /** @hidden */
  72856. _currentColorGradient: Nullable<ColorGradient>;
  72857. /** @hidden */
  72858. _currentColor1: Color4;
  72859. /** @hidden */
  72860. _currentColor2: Color4;
  72861. /** @hidden */
  72862. _currentSizeGradient: Nullable<FactorGradient>;
  72863. /** @hidden */
  72864. _currentSize1: number;
  72865. /** @hidden */
  72866. _currentSize2: number;
  72867. /** @hidden */
  72868. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72869. /** @hidden */
  72870. _currentAngularSpeed1: number;
  72871. /** @hidden */
  72872. _currentAngularSpeed2: number;
  72873. /** @hidden */
  72874. _currentVelocityGradient: Nullable<FactorGradient>;
  72875. /** @hidden */
  72876. _currentVelocity1: number;
  72877. /** @hidden */
  72878. _currentVelocity2: number;
  72879. /** @hidden */
  72880. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72881. /** @hidden */
  72882. _currentLimitVelocity1: number;
  72883. /** @hidden */
  72884. _currentLimitVelocity2: number;
  72885. /** @hidden */
  72886. _currentDragGradient: Nullable<FactorGradient>;
  72887. /** @hidden */
  72888. _currentDrag1: number;
  72889. /** @hidden */
  72890. _currentDrag2: number;
  72891. /** @hidden */
  72892. _randomNoiseCoordinates1: Vector3;
  72893. /** @hidden */
  72894. _randomNoiseCoordinates2: Vector3;
  72895. /**
  72896. * Creates a new instance Particle
  72897. * @param particleSystem the particle system the particle belongs to
  72898. */
  72899. constructor(
  72900. /**
  72901. * The particle system the particle belongs to.
  72902. */
  72903. particleSystem: ParticleSystem);
  72904. private updateCellInfoFromSystem;
  72905. /**
  72906. * Defines how the sprite cell index is updated for the particle
  72907. */
  72908. updateCellIndex(): void;
  72909. /** @hidden */
  72910. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72911. /** @hidden */
  72912. _inheritParticleInfoToSubEmitters(): void;
  72913. /** @hidden */
  72914. _reset(): void;
  72915. /**
  72916. * Copy the properties of particle to another one.
  72917. * @param other the particle to copy the information to.
  72918. */
  72919. copyTo(other: Particle): void;
  72920. }
  72921. }
  72922. declare module BABYLON {
  72923. /**
  72924. * Particle emitter represents a volume emitting particles.
  72925. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72926. */
  72927. export interface IParticleEmitterType {
  72928. /**
  72929. * Called by the particle System when the direction is computed for the created particle.
  72930. * @param worldMatrix is the world matrix of the particle system
  72931. * @param directionToUpdate is the direction vector to update with the result
  72932. * @param particle is the particle we are computed the direction for
  72933. */
  72934. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72935. /**
  72936. * Called by the particle System when the position is computed for the created particle.
  72937. * @param worldMatrix is the world matrix of the particle system
  72938. * @param positionToUpdate is the position vector to update with the result
  72939. * @param particle is the particle we are computed the position for
  72940. */
  72941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72942. /**
  72943. * Clones the current emitter and returns a copy of it
  72944. * @returns the new emitter
  72945. */
  72946. clone(): IParticleEmitterType;
  72947. /**
  72948. * Called by the GPUParticleSystem to setup the update shader
  72949. * @param effect defines the update shader
  72950. */
  72951. applyToShader(effect: Effect): void;
  72952. /**
  72953. * Returns a string to use to update the GPU particles update shader
  72954. * @returns the effect defines string
  72955. */
  72956. getEffectDefines(): string;
  72957. /**
  72958. * Returns a string representing the class name
  72959. * @returns a string containing the class name
  72960. */
  72961. getClassName(): string;
  72962. /**
  72963. * Serializes the particle system to a JSON object.
  72964. * @returns the JSON object
  72965. */
  72966. serialize(): any;
  72967. /**
  72968. * Parse properties from a JSON object
  72969. * @param serializationObject defines the JSON object
  72970. */
  72971. parse(serializationObject: any): void;
  72972. }
  72973. }
  72974. declare module BABYLON {
  72975. /**
  72976. * Particle emitter emitting particles from the inside of a box.
  72977. * It emits the particles randomly between 2 given directions.
  72978. */
  72979. export class BoxParticleEmitter implements IParticleEmitterType {
  72980. /**
  72981. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72982. */
  72983. direction1: Vector3;
  72984. /**
  72985. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72986. */
  72987. direction2: Vector3;
  72988. /**
  72989. * 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.
  72990. */
  72991. minEmitBox: Vector3;
  72992. /**
  72993. * 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.
  72994. */
  72995. maxEmitBox: Vector3;
  72996. /**
  72997. * Creates a new instance BoxParticleEmitter
  72998. */
  72999. constructor();
  73000. /**
  73001. * Called by the particle System when the direction is computed for the created particle.
  73002. * @param worldMatrix is the world matrix of the particle system
  73003. * @param directionToUpdate is the direction vector to update with the result
  73004. * @param particle is the particle we are computed the direction for
  73005. */
  73006. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73007. /**
  73008. * Called by the particle System when the position is computed for the created particle.
  73009. * @param worldMatrix is the world matrix of the particle system
  73010. * @param positionToUpdate is the position vector to update with the result
  73011. * @param particle is the particle we are computed the position for
  73012. */
  73013. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73014. /**
  73015. * Clones the current emitter and returns a copy of it
  73016. * @returns the new emitter
  73017. */
  73018. clone(): BoxParticleEmitter;
  73019. /**
  73020. * Called by the GPUParticleSystem to setup the update shader
  73021. * @param effect defines the update shader
  73022. */
  73023. applyToShader(effect: Effect): void;
  73024. /**
  73025. * Returns a string to use to update the GPU particles update shader
  73026. * @returns a string containng the defines string
  73027. */
  73028. getEffectDefines(): string;
  73029. /**
  73030. * Returns the string "BoxParticleEmitter"
  73031. * @returns a string containing the class name
  73032. */
  73033. getClassName(): string;
  73034. /**
  73035. * Serializes the particle system to a JSON object.
  73036. * @returns the JSON object
  73037. */
  73038. serialize(): any;
  73039. /**
  73040. * Parse properties from a JSON object
  73041. * @param serializationObject defines the JSON object
  73042. */
  73043. parse(serializationObject: any): void;
  73044. }
  73045. }
  73046. declare module BABYLON {
  73047. /**
  73048. * Particle emitter emitting particles from the inside of a cone.
  73049. * It emits the particles alongside the cone volume from the base to the particle.
  73050. * The emission direction might be randomized.
  73051. */
  73052. export class ConeParticleEmitter implements IParticleEmitterType {
  73053. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73054. directionRandomizer: number;
  73055. private _radius;
  73056. private _angle;
  73057. private _height;
  73058. /**
  73059. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73060. */
  73061. radiusRange: number;
  73062. /**
  73063. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73064. */
  73065. heightRange: number;
  73066. /**
  73067. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73068. */
  73069. emitFromSpawnPointOnly: boolean;
  73070. /**
  73071. * Gets or sets the radius of the emission cone
  73072. */
  73073. radius: number;
  73074. /**
  73075. * Gets or sets the angle of the emission cone
  73076. */
  73077. angle: number;
  73078. private _buildHeight;
  73079. /**
  73080. * Creates a new instance ConeParticleEmitter
  73081. * @param radius the radius of the emission cone (1 by default)
  73082. * @param angle the cone base angle (PI by default)
  73083. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73084. */
  73085. constructor(radius?: number, angle?: number,
  73086. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73087. directionRandomizer?: number);
  73088. /**
  73089. * Called by the particle System when the direction is computed for the created particle.
  73090. * @param worldMatrix is the world matrix of the particle system
  73091. * @param directionToUpdate is the direction vector to update with the result
  73092. * @param particle is the particle we are computed the direction for
  73093. */
  73094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73095. /**
  73096. * Called by the particle System when the position is computed for the created particle.
  73097. * @param worldMatrix is the world matrix of the particle system
  73098. * @param positionToUpdate is the position vector to update with the result
  73099. * @param particle is the particle we are computed the position for
  73100. */
  73101. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73102. /**
  73103. * Clones the current emitter and returns a copy of it
  73104. * @returns the new emitter
  73105. */
  73106. clone(): ConeParticleEmitter;
  73107. /**
  73108. * Called by the GPUParticleSystem to setup the update shader
  73109. * @param effect defines the update shader
  73110. */
  73111. applyToShader(effect: Effect): void;
  73112. /**
  73113. * Returns a string to use to update the GPU particles update shader
  73114. * @returns a string containng the defines string
  73115. */
  73116. getEffectDefines(): string;
  73117. /**
  73118. * Returns the string "ConeParticleEmitter"
  73119. * @returns a string containing the class name
  73120. */
  73121. getClassName(): string;
  73122. /**
  73123. * Serializes the particle system to a JSON object.
  73124. * @returns the JSON object
  73125. */
  73126. serialize(): any;
  73127. /**
  73128. * Parse properties from a JSON object
  73129. * @param serializationObject defines the JSON object
  73130. */
  73131. parse(serializationObject: any): void;
  73132. }
  73133. }
  73134. declare module BABYLON {
  73135. /**
  73136. * Particle emitter emitting particles from the inside of a cylinder.
  73137. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73138. */
  73139. export class CylinderParticleEmitter implements IParticleEmitterType {
  73140. /**
  73141. * The radius of the emission cylinder.
  73142. */
  73143. radius: number;
  73144. /**
  73145. * The height of the emission cylinder.
  73146. */
  73147. height: number;
  73148. /**
  73149. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73150. */
  73151. radiusRange: number;
  73152. /**
  73153. * How much to randomize the particle direction [0-1].
  73154. */
  73155. directionRandomizer: number;
  73156. /**
  73157. * Creates a new instance CylinderParticleEmitter
  73158. * @param radius the radius of the emission cylinder (1 by default)
  73159. * @param height the height of the emission cylinder (1 by default)
  73160. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73161. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73162. */
  73163. constructor(
  73164. /**
  73165. * The radius of the emission cylinder.
  73166. */
  73167. radius?: number,
  73168. /**
  73169. * The height of the emission cylinder.
  73170. */
  73171. height?: number,
  73172. /**
  73173. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73174. */
  73175. radiusRange?: number,
  73176. /**
  73177. * How much to randomize the particle direction [0-1].
  73178. */
  73179. directionRandomizer?: number);
  73180. /**
  73181. * Called by the particle System when the direction is computed for the created particle.
  73182. * @param worldMatrix is the world matrix of the particle system
  73183. * @param directionToUpdate is the direction vector to update with the result
  73184. * @param particle is the particle we are computed the direction for
  73185. */
  73186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73187. /**
  73188. * Called by the particle System when the position is computed for the created particle.
  73189. * @param worldMatrix is the world matrix of the particle system
  73190. * @param positionToUpdate is the position vector to update with the result
  73191. * @param particle is the particle we are computed the position for
  73192. */
  73193. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73194. /**
  73195. * Clones the current emitter and returns a copy of it
  73196. * @returns the new emitter
  73197. */
  73198. clone(): CylinderParticleEmitter;
  73199. /**
  73200. * Called by the GPUParticleSystem to setup the update shader
  73201. * @param effect defines the update shader
  73202. */
  73203. applyToShader(effect: Effect): void;
  73204. /**
  73205. * Returns a string to use to update the GPU particles update shader
  73206. * @returns a string containng the defines string
  73207. */
  73208. getEffectDefines(): string;
  73209. /**
  73210. * Returns the string "CylinderParticleEmitter"
  73211. * @returns a string containing the class name
  73212. */
  73213. getClassName(): string;
  73214. /**
  73215. * Serializes the particle system to a JSON object.
  73216. * @returns the JSON object
  73217. */
  73218. serialize(): any;
  73219. /**
  73220. * Parse properties from a JSON object
  73221. * @param serializationObject defines the JSON object
  73222. */
  73223. parse(serializationObject: any): void;
  73224. }
  73225. /**
  73226. * Particle emitter emitting particles from the inside of a cylinder.
  73227. * It emits the particles randomly between two vectors.
  73228. */
  73229. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73230. /**
  73231. * The min limit of the emission direction.
  73232. */
  73233. direction1: Vector3;
  73234. /**
  73235. * The max limit of the emission direction.
  73236. */
  73237. direction2: Vector3;
  73238. /**
  73239. * Creates a new instance CylinderDirectedParticleEmitter
  73240. * @param radius the radius of the emission cylinder (1 by default)
  73241. * @param height the height of the emission cylinder (1 by default)
  73242. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73243. * @param direction1 the min limit of the emission direction (up vector by default)
  73244. * @param direction2 the max limit of the emission direction (up vector by default)
  73245. */
  73246. constructor(radius?: number, height?: number, radiusRange?: number,
  73247. /**
  73248. * The min limit of the emission direction.
  73249. */
  73250. direction1?: Vector3,
  73251. /**
  73252. * The max limit of the emission direction.
  73253. */
  73254. direction2?: Vector3);
  73255. /**
  73256. * Called by the particle System when the direction is computed for the created particle.
  73257. * @param worldMatrix is the world matrix of the particle system
  73258. * @param directionToUpdate is the direction vector to update with the result
  73259. * @param particle is the particle we are computed the direction for
  73260. */
  73261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73262. /**
  73263. * Clones the current emitter and returns a copy of it
  73264. * @returns the new emitter
  73265. */
  73266. clone(): CylinderDirectedParticleEmitter;
  73267. /**
  73268. * Called by the GPUParticleSystem to setup the update shader
  73269. * @param effect defines the update shader
  73270. */
  73271. applyToShader(effect: Effect): void;
  73272. /**
  73273. * Returns a string to use to update the GPU particles update shader
  73274. * @returns a string containng the defines string
  73275. */
  73276. getEffectDefines(): string;
  73277. /**
  73278. * Returns the string "CylinderDirectedParticleEmitter"
  73279. * @returns a string containing the class name
  73280. */
  73281. getClassName(): string;
  73282. /**
  73283. * Serializes the particle system to a JSON object.
  73284. * @returns the JSON object
  73285. */
  73286. serialize(): any;
  73287. /**
  73288. * Parse properties from a JSON object
  73289. * @param serializationObject defines the JSON object
  73290. */
  73291. parse(serializationObject: any): void;
  73292. }
  73293. }
  73294. declare module BABYLON {
  73295. /**
  73296. * Particle emitter emitting particles from the inside of a hemisphere.
  73297. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73298. */
  73299. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73300. /**
  73301. * The radius of the emission hemisphere.
  73302. */
  73303. radius: number;
  73304. /**
  73305. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73306. */
  73307. radiusRange: number;
  73308. /**
  73309. * How much to randomize the particle direction [0-1].
  73310. */
  73311. directionRandomizer: number;
  73312. /**
  73313. * Creates a new instance HemisphericParticleEmitter
  73314. * @param radius the radius of the emission hemisphere (1 by default)
  73315. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73316. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73317. */
  73318. constructor(
  73319. /**
  73320. * The radius of the emission hemisphere.
  73321. */
  73322. radius?: number,
  73323. /**
  73324. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73325. */
  73326. radiusRange?: number,
  73327. /**
  73328. * How much to randomize the particle direction [0-1].
  73329. */
  73330. directionRandomizer?: number);
  73331. /**
  73332. * Called by the particle System when the direction is computed for the created particle.
  73333. * @param worldMatrix is the world matrix of the particle system
  73334. * @param directionToUpdate is the direction vector to update with the result
  73335. * @param particle is the particle we are computed the direction for
  73336. */
  73337. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73338. /**
  73339. * Called by the particle System when the position is computed for the created particle.
  73340. * @param worldMatrix is the world matrix of the particle system
  73341. * @param positionToUpdate is the position vector to update with the result
  73342. * @param particle is the particle we are computed the position for
  73343. */
  73344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73345. /**
  73346. * Clones the current emitter and returns a copy of it
  73347. * @returns the new emitter
  73348. */
  73349. clone(): HemisphericParticleEmitter;
  73350. /**
  73351. * Called by the GPUParticleSystem to setup the update shader
  73352. * @param effect defines the update shader
  73353. */
  73354. applyToShader(effect: Effect): void;
  73355. /**
  73356. * Returns a string to use to update the GPU particles update shader
  73357. * @returns a string containng the defines string
  73358. */
  73359. getEffectDefines(): string;
  73360. /**
  73361. * Returns the string "HemisphericParticleEmitter"
  73362. * @returns a string containing the class name
  73363. */
  73364. getClassName(): string;
  73365. /**
  73366. * Serializes the particle system to a JSON object.
  73367. * @returns the JSON object
  73368. */
  73369. serialize(): any;
  73370. /**
  73371. * Parse properties from a JSON object
  73372. * @param serializationObject defines the JSON object
  73373. */
  73374. parse(serializationObject: any): void;
  73375. }
  73376. }
  73377. declare module BABYLON {
  73378. /**
  73379. * Particle emitter emitting particles from a point.
  73380. * It emits the particles randomly between 2 given directions.
  73381. */
  73382. export class PointParticleEmitter implements IParticleEmitterType {
  73383. /**
  73384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73385. */
  73386. direction1: Vector3;
  73387. /**
  73388. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73389. */
  73390. direction2: Vector3;
  73391. /**
  73392. * Creates a new instance PointParticleEmitter
  73393. */
  73394. constructor();
  73395. /**
  73396. * Called by the particle System when the direction is computed for the created particle.
  73397. * @param worldMatrix is the world matrix of the particle system
  73398. * @param directionToUpdate is the direction vector to update with the result
  73399. * @param particle is the particle we are computed the direction for
  73400. */
  73401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73402. /**
  73403. * Called by the particle System when the position is computed for the created particle.
  73404. * @param worldMatrix is the world matrix of the particle system
  73405. * @param positionToUpdate is the position vector to update with the result
  73406. * @param particle is the particle we are computed the position for
  73407. */
  73408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73409. /**
  73410. * Clones the current emitter and returns a copy of it
  73411. * @returns the new emitter
  73412. */
  73413. clone(): PointParticleEmitter;
  73414. /**
  73415. * Called by the GPUParticleSystem to setup the update shader
  73416. * @param effect defines the update shader
  73417. */
  73418. applyToShader(effect: Effect): void;
  73419. /**
  73420. * Returns a string to use to update the GPU particles update shader
  73421. * @returns a string containng the defines string
  73422. */
  73423. getEffectDefines(): string;
  73424. /**
  73425. * Returns the string "PointParticleEmitter"
  73426. * @returns a string containing the class name
  73427. */
  73428. getClassName(): string;
  73429. /**
  73430. * Serializes the particle system to a JSON object.
  73431. * @returns the JSON object
  73432. */
  73433. serialize(): any;
  73434. /**
  73435. * Parse properties from a JSON object
  73436. * @param serializationObject defines the JSON object
  73437. */
  73438. parse(serializationObject: any): void;
  73439. }
  73440. }
  73441. declare module BABYLON {
  73442. /**
  73443. * Particle emitter emitting particles from the inside of a sphere.
  73444. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73445. */
  73446. export class SphereParticleEmitter implements IParticleEmitterType {
  73447. /**
  73448. * The radius of the emission sphere.
  73449. */
  73450. radius: number;
  73451. /**
  73452. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73453. */
  73454. radiusRange: number;
  73455. /**
  73456. * How much to randomize the particle direction [0-1].
  73457. */
  73458. directionRandomizer: number;
  73459. /**
  73460. * Creates a new instance SphereParticleEmitter
  73461. * @param radius the radius of the emission sphere (1 by default)
  73462. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73463. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73464. */
  73465. constructor(
  73466. /**
  73467. * The radius of the emission sphere.
  73468. */
  73469. radius?: number,
  73470. /**
  73471. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73472. */
  73473. radiusRange?: number,
  73474. /**
  73475. * How much to randomize the particle direction [0-1].
  73476. */
  73477. directionRandomizer?: number);
  73478. /**
  73479. * Called by the particle System when the direction is computed for the created particle.
  73480. * @param worldMatrix is the world matrix of the particle system
  73481. * @param directionToUpdate is the direction vector to update with the result
  73482. * @param particle is the particle we are computed the direction for
  73483. */
  73484. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73485. /**
  73486. * Called by the particle System when the position is computed for the created particle.
  73487. * @param worldMatrix is the world matrix of the particle system
  73488. * @param positionToUpdate is the position vector to update with the result
  73489. * @param particle is the particle we are computed the position for
  73490. */
  73491. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73492. /**
  73493. * Clones the current emitter and returns a copy of it
  73494. * @returns the new emitter
  73495. */
  73496. clone(): SphereParticleEmitter;
  73497. /**
  73498. * Called by the GPUParticleSystem to setup the update shader
  73499. * @param effect defines the update shader
  73500. */
  73501. applyToShader(effect: Effect): void;
  73502. /**
  73503. * Returns a string to use to update the GPU particles update shader
  73504. * @returns a string containng the defines string
  73505. */
  73506. getEffectDefines(): string;
  73507. /**
  73508. * Returns the string "SphereParticleEmitter"
  73509. * @returns a string containing the class name
  73510. */
  73511. getClassName(): string;
  73512. /**
  73513. * Serializes the particle system to a JSON object.
  73514. * @returns the JSON object
  73515. */
  73516. serialize(): any;
  73517. /**
  73518. * Parse properties from a JSON object
  73519. * @param serializationObject defines the JSON object
  73520. */
  73521. parse(serializationObject: any): void;
  73522. }
  73523. /**
  73524. * Particle emitter emitting particles from the inside of a sphere.
  73525. * It emits the particles randomly between two vectors.
  73526. */
  73527. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73528. /**
  73529. * The min limit of the emission direction.
  73530. */
  73531. direction1: Vector3;
  73532. /**
  73533. * The max limit of the emission direction.
  73534. */
  73535. direction2: Vector3;
  73536. /**
  73537. * Creates a new instance SphereDirectedParticleEmitter
  73538. * @param radius the radius of the emission sphere (1 by default)
  73539. * @param direction1 the min limit of the emission direction (up vector by default)
  73540. * @param direction2 the max limit of the emission direction (up vector by default)
  73541. */
  73542. constructor(radius?: number,
  73543. /**
  73544. * The min limit of the emission direction.
  73545. */
  73546. direction1?: Vector3,
  73547. /**
  73548. * The max limit of the emission direction.
  73549. */
  73550. direction2?: Vector3);
  73551. /**
  73552. * Called by the particle System when the direction is computed for the created particle.
  73553. * @param worldMatrix is the world matrix of the particle system
  73554. * @param directionToUpdate is the direction vector to update with the result
  73555. * @param particle is the particle we are computed the direction for
  73556. */
  73557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73558. /**
  73559. * Clones the current emitter and returns a copy of it
  73560. * @returns the new emitter
  73561. */
  73562. clone(): SphereDirectedParticleEmitter;
  73563. /**
  73564. * Called by the GPUParticleSystem to setup the update shader
  73565. * @param effect defines the update shader
  73566. */
  73567. applyToShader(effect: Effect): void;
  73568. /**
  73569. * Returns a string to use to update the GPU particles update shader
  73570. * @returns a string containng the defines string
  73571. */
  73572. getEffectDefines(): string;
  73573. /**
  73574. * Returns the string "SphereDirectedParticleEmitter"
  73575. * @returns a string containing the class name
  73576. */
  73577. getClassName(): string;
  73578. /**
  73579. * Serializes the particle system to a JSON object.
  73580. * @returns the JSON object
  73581. */
  73582. serialize(): any;
  73583. /**
  73584. * Parse properties from a JSON object
  73585. * @param serializationObject defines the JSON object
  73586. */
  73587. parse(serializationObject: any): void;
  73588. }
  73589. }
  73590. declare module BABYLON {
  73591. /**
  73592. * Interface representing a particle system in Babylon.js.
  73593. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73594. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73595. */
  73596. export interface IParticleSystem {
  73597. /**
  73598. * List of animations used by the particle system.
  73599. */
  73600. animations: Animation[];
  73601. /**
  73602. * The id of the Particle system.
  73603. */
  73604. id: string;
  73605. /**
  73606. * The name of the Particle system.
  73607. */
  73608. name: string;
  73609. /**
  73610. * The emitter represents the Mesh or position we are attaching the particle system to.
  73611. */
  73612. emitter: Nullable<AbstractMesh | Vector3>;
  73613. /**
  73614. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73615. */
  73616. isBillboardBased: boolean;
  73617. /**
  73618. * The rendering group used by the Particle system to chose when to render.
  73619. */
  73620. renderingGroupId: number;
  73621. /**
  73622. * The layer mask we are rendering the particles through.
  73623. */
  73624. layerMask: number;
  73625. /**
  73626. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73627. */
  73628. updateSpeed: number;
  73629. /**
  73630. * The amount of time the particle system is running (depends of the overall update speed).
  73631. */
  73632. targetStopDuration: number;
  73633. /**
  73634. * The texture used to render each particle. (this can be a spritesheet)
  73635. */
  73636. particleTexture: Nullable<Texture>;
  73637. /**
  73638. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73639. */
  73640. blendMode: number;
  73641. /**
  73642. * Minimum life time of emitting particles.
  73643. */
  73644. minLifeTime: number;
  73645. /**
  73646. * Maximum life time of emitting particles.
  73647. */
  73648. maxLifeTime: number;
  73649. /**
  73650. * Minimum Size of emitting particles.
  73651. */
  73652. minSize: number;
  73653. /**
  73654. * Maximum Size of emitting particles.
  73655. */
  73656. maxSize: number;
  73657. /**
  73658. * Minimum scale of emitting particles on X axis.
  73659. */
  73660. minScaleX: number;
  73661. /**
  73662. * Maximum scale of emitting particles on X axis.
  73663. */
  73664. maxScaleX: number;
  73665. /**
  73666. * Minimum scale of emitting particles on Y axis.
  73667. */
  73668. minScaleY: number;
  73669. /**
  73670. * Maximum scale of emitting particles on Y axis.
  73671. */
  73672. maxScaleY: number;
  73673. /**
  73674. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73675. */
  73676. color1: Color4;
  73677. /**
  73678. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73679. */
  73680. color2: Color4;
  73681. /**
  73682. * Color the particle will have at the end of its lifetime.
  73683. */
  73684. colorDead: Color4;
  73685. /**
  73686. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73687. */
  73688. emitRate: number;
  73689. /**
  73690. * You can use gravity if you want to give an orientation to your particles.
  73691. */
  73692. gravity: Vector3;
  73693. /**
  73694. * Minimum power of emitting particles.
  73695. */
  73696. minEmitPower: number;
  73697. /**
  73698. * Maximum power of emitting particles.
  73699. */
  73700. maxEmitPower: number;
  73701. /**
  73702. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73703. */
  73704. minAngularSpeed: number;
  73705. /**
  73706. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73707. */
  73708. maxAngularSpeed: number;
  73709. /**
  73710. * Gets or sets the minimal initial rotation in radians.
  73711. */
  73712. minInitialRotation: number;
  73713. /**
  73714. * Gets or sets the maximal initial rotation in radians.
  73715. */
  73716. maxInitialRotation: number;
  73717. /**
  73718. * The particle emitter type defines the emitter used by the particle system.
  73719. * It can be for example box, sphere, or cone...
  73720. */
  73721. particleEmitterType: Nullable<IParticleEmitterType>;
  73722. /**
  73723. * Defines the delay in milliseconds before starting the system (0 by default)
  73724. */
  73725. startDelay: number;
  73726. /**
  73727. * 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
  73728. */
  73729. preWarmCycles: number;
  73730. /**
  73731. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73732. */
  73733. preWarmStepOffset: number;
  73734. /**
  73735. * 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)
  73736. */
  73737. spriteCellChangeSpeed: number;
  73738. /**
  73739. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73740. */
  73741. startSpriteCellID: number;
  73742. /**
  73743. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73744. */
  73745. endSpriteCellID: number;
  73746. /**
  73747. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73748. */
  73749. spriteCellWidth: number;
  73750. /**
  73751. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73752. */
  73753. spriteCellHeight: number;
  73754. /**
  73755. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73756. */
  73757. spriteRandomStartCell: boolean;
  73758. /**
  73759. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73760. */
  73761. isAnimationSheetEnabled: boolean;
  73762. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73763. translationPivot: Vector2;
  73764. /**
  73765. * Gets or sets a texture used to add random noise to particle positions
  73766. */
  73767. noiseTexture: Nullable<BaseTexture>;
  73768. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73769. noiseStrength: Vector3;
  73770. /**
  73771. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73772. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73773. */
  73774. billboardMode: number;
  73775. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73776. limitVelocityDamping: number;
  73777. /**
  73778. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73779. */
  73780. beginAnimationOnStart: boolean;
  73781. /**
  73782. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73783. */
  73784. beginAnimationFrom: number;
  73785. /**
  73786. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73787. */
  73788. beginAnimationTo: number;
  73789. /**
  73790. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73791. */
  73792. beginAnimationLoop: boolean;
  73793. /**
  73794. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73795. */
  73796. disposeOnStop: boolean;
  73797. /**
  73798. * Gets the maximum number of particles active at the same time.
  73799. * @returns The max number of active particles.
  73800. */
  73801. getCapacity(): number;
  73802. /**
  73803. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73804. * @returns True if it has been started, otherwise false.
  73805. */
  73806. isStarted(): boolean;
  73807. /**
  73808. * Animates the particle system for this frame.
  73809. */
  73810. animate(): void;
  73811. /**
  73812. * Renders the particle system in its current state.
  73813. * @returns the current number of particles
  73814. */
  73815. render(): number;
  73816. /**
  73817. * Dispose the particle system and frees its associated resources.
  73818. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73819. */
  73820. dispose(disposeTexture?: boolean): void;
  73821. /**
  73822. * Clones the particle system.
  73823. * @param name The name of the cloned object
  73824. * @param newEmitter The new emitter to use
  73825. * @returns the cloned particle system
  73826. */
  73827. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73828. /**
  73829. * Serializes the particle system to a JSON object.
  73830. * @returns the JSON object
  73831. */
  73832. serialize(): any;
  73833. /**
  73834. * Rebuild the particle system
  73835. */
  73836. rebuild(): void;
  73837. /**
  73838. * Starts the particle system and begins to emit
  73839. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73840. */
  73841. start(delay?: number): void;
  73842. /**
  73843. * Stops the particle system.
  73844. */
  73845. stop(): void;
  73846. /**
  73847. * Remove all active particles
  73848. */
  73849. reset(): void;
  73850. /**
  73851. * Is this system ready to be used/rendered
  73852. * @return true if the system is ready
  73853. */
  73854. isReady(): boolean;
  73855. /**
  73856. * Adds a new color gradient
  73857. * @param gradient defines the gradient to use (between 0 and 1)
  73858. * @param color1 defines the color to affect to the specified gradient
  73859. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73860. * @returns the current particle system
  73861. */
  73862. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73863. /**
  73864. * Remove a specific color gradient
  73865. * @param gradient defines the gradient to remove
  73866. * @returns the current particle system
  73867. */
  73868. removeColorGradient(gradient: number): IParticleSystem;
  73869. /**
  73870. * Adds a new size gradient
  73871. * @param gradient defines the gradient to use (between 0 and 1)
  73872. * @param factor defines the size factor to affect to the specified gradient
  73873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73874. * @returns the current particle system
  73875. */
  73876. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73877. /**
  73878. * Remove a specific size gradient
  73879. * @param gradient defines the gradient to remove
  73880. * @returns the current particle system
  73881. */
  73882. removeSizeGradient(gradient: number): IParticleSystem;
  73883. /**
  73884. * Gets the current list of color gradients.
  73885. * You must use addColorGradient and removeColorGradient to udpate this list
  73886. * @returns the list of color gradients
  73887. */
  73888. getColorGradients(): Nullable<Array<ColorGradient>>;
  73889. /**
  73890. * Gets the current list of size gradients.
  73891. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73892. * @returns the list of size gradients
  73893. */
  73894. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73895. /**
  73896. * Gets the current list of angular speed gradients.
  73897. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73898. * @returns the list of angular speed gradients
  73899. */
  73900. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73901. /**
  73902. * Adds a new angular speed gradient
  73903. * @param gradient defines the gradient to use (between 0 and 1)
  73904. * @param factor defines the angular speed to affect to the specified gradient
  73905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73906. * @returns the current particle system
  73907. */
  73908. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73909. /**
  73910. * Remove a specific angular speed gradient
  73911. * @param gradient defines the gradient to remove
  73912. * @returns the current particle system
  73913. */
  73914. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73915. /**
  73916. * Gets the current list of velocity gradients.
  73917. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73918. * @returns the list of velocity gradients
  73919. */
  73920. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73921. /**
  73922. * Adds a new velocity gradient
  73923. * @param gradient defines the gradient to use (between 0 and 1)
  73924. * @param factor defines the velocity to affect to the specified gradient
  73925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73926. * @returns the current particle system
  73927. */
  73928. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73929. /**
  73930. * Remove a specific velocity gradient
  73931. * @param gradient defines the gradient to remove
  73932. * @returns the current particle system
  73933. */
  73934. removeVelocityGradient(gradient: number): IParticleSystem;
  73935. /**
  73936. * Gets the current list of limit velocity gradients.
  73937. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73938. * @returns the list of limit velocity gradients
  73939. */
  73940. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73941. /**
  73942. * Adds a new limit velocity gradient
  73943. * @param gradient defines the gradient to use (between 0 and 1)
  73944. * @param factor defines the limit velocity to affect to the specified gradient
  73945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73946. * @returns the current particle system
  73947. */
  73948. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73949. /**
  73950. * Remove a specific limit velocity gradient
  73951. * @param gradient defines the gradient to remove
  73952. * @returns the current particle system
  73953. */
  73954. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73955. /**
  73956. * Adds a new drag gradient
  73957. * @param gradient defines the gradient to use (between 0 and 1)
  73958. * @param factor defines the drag to affect to the specified gradient
  73959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73960. * @returns the current particle system
  73961. */
  73962. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73963. /**
  73964. * Remove a specific drag gradient
  73965. * @param gradient defines the gradient to remove
  73966. * @returns the current particle system
  73967. */
  73968. removeDragGradient(gradient: number): IParticleSystem;
  73969. /**
  73970. * Gets the current list of drag gradients.
  73971. * You must use addDragGradient and removeDragGradient to udpate this list
  73972. * @returns the list of drag gradients
  73973. */
  73974. getDragGradients(): Nullable<Array<FactorGradient>>;
  73975. /**
  73976. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73977. * @param gradient defines the gradient to use (between 0 and 1)
  73978. * @param factor defines the emit rate to affect to the specified gradient
  73979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73980. * @returns the current particle system
  73981. */
  73982. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73983. /**
  73984. * Remove a specific emit rate gradient
  73985. * @param gradient defines the gradient to remove
  73986. * @returns the current particle system
  73987. */
  73988. removeEmitRateGradient(gradient: number): IParticleSystem;
  73989. /**
  73990. * Gets the current list of emit rate gradients.
  73991. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73992. * @returns the list of emit rate gradients
  73993. */
  73994. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73995. /**
  73996. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73997. * @param gradient defines the gradient to use (between 0 and 1)
  73998. * @param factor defines the start size to affect to the specified gradient
  73999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74000. * @returns the current particle system
  74001. */
  74002. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74003. /**
  74004. * Remove a specific start size gradient
  74005. * @param gradient defines the gradient to remove
  74006. * @returns the current particle system
  74007. */
  74008. removeStartSizeGradient(gradient: number): IParticleSystem;
  74009. /**
  74010. * Gets the current list of start size gradients.
  74011. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74012. * @returns the list of start size gradients
  74013. */
  74014. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74015. /**
  74016. * Adds a new life time gradient
  74017. * @param gradient defines the gradient to use (between 0 and 1)
  74018. * @param factor defines the life time factor to affect to the specified gradient
  74019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74020. * @returns the current particle system
  74021. */
  74022. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74023. /**
  74024. * Remove a specific life time gradient
  74025. * @param gradient defines the gradient to remove
  74026. * @returns the current particle system
  74027. */
  74028. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74029. /**
  74030. * Gets the current list of life time gradients.
  74031. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74032. * @returns the list of life time gradients
  74033. */
  74034. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74035. /**
  74036. * Gets the current list of color gradients.
  74037. * You must use addColorGradient and removeColorGradient to udpate this list
  74038. * @returns the list of color gradients
  74039. */
  74040. getColorGradients(): Nullable<Array<ColorGradient>>;
  74041. /**
  74042. * Adds a new ramp gradient used to remap particle colors
  74043. * @param gradient defines the gradient to use (between 0 and 1)
  74044. * @param color defines the color to affect to the specified gradient
  74045. * @returns the current particle system
  74046. */
  74047. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74048. /**
  74049. * Gets the current list of ramp gradients.
  74050. * You must use addRampGradient and removeRampGradient to udpate this list
  74051. * @returns the list of ramp gradients
  74052. */
  74053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74054. /** Gets or sets a boolean indicating that ramp gradients must be used
  74055. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74056. */
  74057. useRampGradients: boolean;
  74058. /**
  74059. * Adds a new color remap gradient
  74060. * @param gradient defines the gradient to use (between 0 and 1)
  74061. * @param min defines the color remap minimal range
  74062. * @param max defines the color remap maximal range
  74063. * @returns the current particle system
  74064. */
  74065. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74066. /**
  74067. * Gets the current list of color remap gradients.
  74068. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74069. * @returns the list of color remap gradients
  74070. */
  74071. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74072. /**
  74073. * Adds a new alpha remap gradient
  74074. * @param gradient defines the gradient to use (between 0 and 1)
  74075. * @param min defines the alpha remap minimal range
  74076. * @param max defines the alpha remap maximal range
  74077. * @returns the current particle system
  74078. */
  74079. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74080. /**
  74081. * Gets the current list of alpha remap gradients.
  74082. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74083. * @returns the list of alpha remap gradients
  74084. */
  74085. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74086. /**
  74087. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74088. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74089. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74090. * @returns the emitter
  74091. */
  74092. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74093. /**
  74094. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74095. * @param radius The radius of the hemisphere to emit from
  74096. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74097. * @returns the emitter
  74098. */
  74099. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74100. /**
  74101. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74102. * @param radius The radius of the sphere to emit from
  74103. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74104. * @returns the emitter
  74105. */
  74106. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74107. /**
  74108. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74109. * @param radius The radius of the sphere to emit from
  74110. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74111. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74112. * @returns the emitter
  74113. */
  74114. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74115. /**
  74116. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74117. * @param radius The radius of the emission cylinder
  74118. * @param height The height of the emission cylinder
  74119. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74120. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74121. * @returns the emitter
  74122. */
  74123. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74124. /**
  74125. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74126. * @param radius The radius of the cylinder to emit from
  74127. * @param height The height of the emission cylinder
  74128. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74129. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74130. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74131. * @returns the emitter
  74132. */
  74133. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74134. /**
  74135. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74136. * @param radius The radius of the cone to emit from
  74137. * @param angle The base angle of the cone
  74138. * @returns the emitter
  74139. */
  74140. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74141. /**
  74142. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74145. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74146. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74147. * @returns the emitter
  74148. */
  74149. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74150. /**
  74151. * Get hosting scene
  74152. * @returns the scene
  74153. */
  74154. getScene(): Scene;
  74155. }
  74156. }
  74157. declare module BABYLON {
  74158. /**
  74159. * Creates an instance based on a source mesh.
  74160. */
  74161. export class InstancedMesh extends AbstractMesh {
  74162. private _sourceMesh;
  74163. private _currentLOD;
  74164. /** @hidden */
  74165. _indexInSourceMeshInstanceArray: number;
  74166. constructor(name: string, source: Mesh);
  74167. /**
  74168. * Returns the string "InstancedMesh".
  74169. */
  74170. getClassName(): string;
  74171. /**
  74172. * If the source mesh receives shadows
  74173. */
  74174. readonly receiveShadows: boolean;
  74175. /**
  74176. * The material of the source mesh
  74177. */
  74178. readonly material: Nullable<Material>;
  74179. /**
  74180. * Visibility of the source mesh
  74181. */
  74182. readonly visibility: number;
  74183. /**
  74184. * Skeleton of the source mesh
  74185. */
  74186. readonly skeleton: Nullable<Skeleton>;
  74187. /**
  74188. * Rendering ground id of the source mesh
  74189. */
  74190. renderingGroupId: number;
  74191. /**
  74192. * Returns the total number of vertices (integer).
  74193. */
  74194. getTotalVertices(): number;
  74195. /**
  74196. * Returns a positive integer : the total number of indices in this mesh geometry.
  74197. * @returns the numner of indices or zero if the mesh has no geometry.
  74198. */
  74199. getTotalIndices(): number;
  74200. /**
  74201. * The source mesh of the instance
  74202. */
  74203. readonly sourceMesh: Mesh;
  74204. /**
  74205. * Is this node ready to be used/rendered
  74206. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74207. * @return {boolean} is it ready
  74208. */
  74209. isReady(completeCheck?: boolean): boolean;
  74210. /**
  74211. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74212. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74213. * @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.
  74214. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74215. */
  74216. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74217. /**
  74218. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74219. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74220. * The `data` are either a numeric array either a Float32Array.
  74221. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74222. * 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).
  74223. * Note that a new underlying VertexBuffer object is created each call.
  74224. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74225. *
  74226. * Possible `kind` values :
  74227. * - VertexBuffer.PositionKind
  74228. * - VertexBuffer.UVKind
  74229. * - VertexBuffer.UV2Kind
  74230. * - VertexBuffer.UV3Kind
  74231. * - VertexBuffer.UV4Kind
  74232. * - VertexBuffer.UV5Kind
  74233. * - VertexBuffer.UV6Kind
  74234. * - VertexBuffer.ColorKind
  74235. * - VertexBuffer.MatricesIndicesKind
  74236. * - VertexBuffer.MatricesIndicesExtraKind
  74237. * - VertexBuffer.MatricesWeightsKind
  74238. * - VertexBuffer.MatricesWeightsExtraKind
  74239. *
  74240. * Returns the Mesh.
  74241. */
  74242. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74243. /**
  74244. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74245. * If the mesh has no geometry, it is simply returned as it is.
  74246. * The `data` are either a numeric array either a Float32Array.
  74247. * No new underlying VertexBuffer object is created.
  74248. * 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.
  74249. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74250. *
  74251. * Possible `kind` values :
  74252. * - VertexBuffer.PositionKind
  74253. * - VertexBuffer.UVKind
  74254. * - VertexBuffer.UV2Kind
  74255. * - VertexBuffer.UV3Kind
  74256. * - VertexBuffer.UV4Kind
  74257. * - VertexBuffer.UV5Kind
  74258. * - VertexBuffer.UV6Kind
  74259. * - VertexBuffer.ColorKind
  74260. * - VertexBuffer.MatricesIndicesKind
  74261. * - VertexBuffer.MatricesIndicesExtraKind
  74262. * - VertexBuffer.MatricesWeightsKind
  74263. * - VertexBuffer.MatricesWeightsExtraKind
  74264. *
  74265. * Returns the Mesh.
  74266. */
  74267. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74268. /**
  74269. * Sets the mesh indices.
  74270. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74271. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74272. * This method creates a new index buffer each call.
  74273. * Returns the Mesh.
  74274. */
  74275. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74276. /**
  74277. * Boolean : True if the mesh owns the requested kind of data.
  74278. */
  74279. isVerticesDataPresent(kind: string): boolean;
  74280. /**
  74281. * Returns an array of indices (IndicesArray).
  74282. */
  74283. getIndices(): Nullable<IndicesArray>;
  74284. readonly _positions: Nullable<Vector3[]>;
  74285. /**
  74286. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74287. * This means the mesh underlying bounding box and sphere are recomputed.
  74288. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74289. * @returns the current mesh
  74290. */
  74291. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74292. /** @hidden */
  74293. _preActivate(): InstancedMesh;
  74294. /** @hidden */
  74295. _activate(renderId: number): InstancedMesh;
  74296. /**
  74297. * Returns the current associated LOD AbstractMesh.
  74298. */
  74299. getLOD(camera: Camera): AbstractMesh;
  74300. /** @hidden */
  74301. _syncSubMeshes(): InstancedMesh;
  74302. /** @hidden */
  74303. _generatePointsArray(): boolean;
  74304. /**
  74305. * Creates a new InstancedMesh from the current mesh.
  74306. * - name (string) : the cloned mesh name
  74307. * - newParent (optional Node) : the optional Node to parent the clone to.
  74308. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74309. *
  74310. * Returns the clone.
  74311. */
  74312. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74313. /**
  74314. * Disposes the InstancedMesh.
  74315. * Returns nothing.
  74316. */
  74317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74318. }
  74319. }
  74320. declare module BABYLON {
  74321. /**
  74322. * Defines the options associated with the creation of a shader material.
  74323. */
  74324. export interface IShaderMaterialOptions {
  74325. /**
  74326. * Does the material work in alpha blend mode
  74327. */
  74328. needAlphaBlending: boolean;
  74329. /**
  74330. * Does the material work in alpha test mode
  74331. */
  74332. needAlphaTesting: boolean;
  74333. /**
  74334. * The list of attribute names used in the shader
  74335. */
  74336. attributes: string[];
  74337. /**
  74338. * The list of unifrom names used in the shader
  74339. */
  74340. uniforms: string[];
  74341. /**
  74342. * The list of UBO names used in the shader
  74343. */
  74344. uniformBuffers: string[];
  74345. /**
  74346. * The list of sampler names used in the shader
  74347. */
  74348. samplers: string[];
  74349. /**
  74350. * The list of defines used in the shader
  74351. */
  74352. defines: string[];
  74353. }
  74354. /**
  74355. * 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.
  74356. *
  74357. * This returned material effects how the mesh will look based on the code in the shaders.
  74358. *
  74359. * @see http://doc.babylonjs.com/how_to/shader_material
  74360. */
  74361. export class ShaderMaterial extends Material {
  74362. private _shaderPath;
  74363. private _options;
  74364. private _textures;
  74365. private _textureArrays;
  74366. private _floats;
  74367. private _ints;
  74368. private _floatsArrays;
  74369. private _colors3;
  74370. private _colors3Arrays;
  74371. private _colors4;
  74372. private _vectors2;
  74373. private _vectors3;
  74374. private _vectors4;
  74375. private _matrices;
  74376. private _matrices3x3;
  74377. private _matrices2x2;
  74378. private _vectors2Arrays;
  74379. private _vectors3Arrays;
  74380. private _cachedWorldViewMatrix;
  74381. private _renderId;
  74382. /**
  74383. * Instantiate a new shader material.
  74384. * 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.
  74385. * This returned material effects how the mesh will look based on the code in the shaders.
  74386. * @see http://doc.babylonjs.com/how_to/shader_material
  74387. * @param name Define the name of the material in the scene
  74388. * @param scene Define the scene the material belongs to
  74389. * @param shaderPath Defines the route to the shader code in one of three ways:
  74390. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74391. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74392. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74393. * @param options Define the options used to create the shader
  74394. */
  74395. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74396. /**
  74397. * Gets the options used to compile the shader.
  74398. * They can be modified to trigger a new compilation
  74399. */
  74400. readonly options: IShaderMaterialOptions;
  74401. /**
  74402. * Gets the current class name of the material e.g. "ShaderMaterial"
  74403. * Mainly use in serialization.
  74404. * @returns the class name
  74405. */
  74406. getClassName(): string;
  74407. /**
  74408. * Specifies if the material will require alpha blending
  74409. * @returns a boolean specifying if alpha blending is needed
  74410. */
  74411. needAlphaBlending(): boolean;
  74412. /**
  74413. * Specifies if this material should be rendered in alpha test mode
  74414. * @returns a boolean specifying if an alpha test is needed.
  74415. */
  74416. needAlphaTesting(): boolean;
  74417. private _checkUniform;
  74418. /**
  74419. * Set a texture in the shader.
  74420. * @param name Define the name of the uniform samplers as defined in the shader
  74421. * @param texture Define the texture to bind to this sampler
  74422. * @return the material itself allowing "fluent" like uniform updates
  74423. */
  74424. setTexture(name: string, texture: Texture): ShaderMaterial;
  74425. /**
  74426. * Set a texture array in the shader.
  74427. * @param name Define the name of the uniform sampler array as defined in the shader
  74428. * @param textures Define the list of textures to bind to this sampler
  74429. * @return the material itself allowing "fluent" like uniform updates
  74430. */
  74431. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74432. /**
  74433. * Set a float in the shader.
  74434. * @param name Define the name of the uniform as defined in the shader
  74435. * @param value Define the value to give to the uniform
  74436. * @return the material itself allowing "fluent" like uniform updates
  74437. */
  74438. setFloat(name: string, value: number): ShaderMaterial;
  74439. /**
  74440. * Set a int in the shader.
  74441. * @param name Define the name of the uniform as defined in the shader
  74442. * @param value Define the value to give to the uniform
  74443. * @return the material itself allowing "fluent" like uniform updates
  74444. */
  74445. setInt(name: string, value: number): ShaderMaterial;
  74446. /**
  74447. * Set an array of floats in the shader.
  74448. * @param name Define the name of the uniform as defined in the shader
  74449. * @param value Define the value to give to the uniform
  74450. * @return the material itself allowing "fluent" like uniform updates
  74451. */
  74452. setFloats(name: string, value: number[]): ShaderMaterial;
  74453. /**
  74454. * Set a vec3 in the shader from a Color3.
  74455. * @param name Define the name of the uniform as defined in the shader
  74456. * @param value Define the value to give to the uniform
  74457. * @return the material itself allowing "fluent" like uniform updates
  74458. */
  74459. setColor3(name: string, value: Color3): ShaderMaterial;
  74460. /**
  74461. * Set a vec3 array in the shader from a Color3 array.
  74462. * @param name Define the name of the uniform as defined in the shader
  74463. * @param value Define the value to give to the uniform
  74464. * @return the material itself allowing "fluent" like uniform updates
  74465. */
  74466. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74467. /**
  74468. * Set a vec4 in the shader from a Color4.
  74469. * @param name Define the name of the uniform as defined in the shader
  74470. * @param value Define the value to give to the uniform
  74471. * @return the material itself allowing "fluent" like uniform updates
  74472. */
  74473. setColor4(name: string, value: Color4): ShaderMaterial;
  74474. /**
  74475. * Set a vec2 in the shader from a Vector2.
  74476. * @param name Define the name of the uniform as defined in the shader
  74477. * @param value Define the value to give to the uniform
  74478. * @return the material itself allowing "fluent" like uniform updates
  74479. */
  74480. setVector2(name: string, value: Vector2): ShaderMaterial;
  74481. /**
  74482. * Set a vec3 in the shader from a Vector3.
  74483. * @param name Define the name of the uniform as defined in the shader
  74484. * @param value Define the value to give to the uniform
  74485. * @return the material itself allowing "fluent" like uniform updates
  74486. */
  74487. setVector3(name: string, value: Vector3): ShaderMaterial;
  74488. /**
  74489. * Set a vec4 in the shader from a Vector4.
  74490. * @param name Define the name of the uniform as defined in the shader
  74491. * @param value Define the value to give to the uniform
  74492. * @return the material itself allowing "fluent" like uniform updates
  74493. */
  74494. setVector4(name: string, value: Vector4): ShaderMaterial;
  74495. /**
  74496. * Set a mat4 in the shader from a Matrix.
  74497. * @param name Define the name of the uniform as defined in the shader
  74498. * @param value Define the value to give to the uniform
  74499. * @return the material itself allowing "fluent" like uniform updates
  74500. */
  74501. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74502. /**
  74503. * Set a mat3 in the shader from a Float32Array.
  74504. * @param name Define the name of the uniform as defined in the shader
  74505. * @param value Define the value to give to the uniform
  74506. * @return the material itself allowing "fluent" like uniform updates
  74507. */
  74508. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74509. /**
  74510. * Set a mat2 in the shader from a Float32Array.
  74511. * @param name Define the name of the uniform as defined in the shader
  74512. * @param value Define the value to give to the uniform
  74513. * @return the material itself allowing "fluent" like uniform updates
  74514. */
  74515. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74516. /**
  74517. * Set a vec2 array in the shader from a number array.
  74518. * @param name Define the name of the uniform as defined in the shader
  74519. * @param value Define the value to give to the uniform
  74520. * @return the material itself allowing "fluent" like uniform updates
  74521. */
  74522. setArray2(name: string, value: number[]): ShaderMaterial;
  74523. /**
  74524. * Set a vec3 array in the shader from a number array.
  74525. * @param name Define the name of the uniform as defined in the shader
  74526. * @param value Define the value to give to the uniform
  74527. * @return the material itself allowing "fluent" like uniform updates
  74528. */
  74529. setArray3(name: string, value: number[]): ShaderMaterial;
  74530. private _checkCache;
  74531. /**
  74532. * Checks if the material is ready to render the requested mesh
  74533. * @param mesh Define the mesh to render
  74534. * @param useInstances Define whether or not the material is used with instances
  74535. * @returns true if ready, otherwise false
  74536. */
  74537. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74538. /**
  74539. * Binds the world matrix to the material
  74540. * @param world defines the world transformation matrix
  74541. */
  74542. bindOnlyWorldMatrix(world: Matrix): void;
  74543. /**
  74544. * Binds the material to the mesh
  74545. * @param world defines the world transformation matrix
  74546. * @param mesh defines the mesh to bind the material to
  74547. */
  74548. bind(world: Matrix, mesh?: Mesh): void;
  74549. /**
  74550. * Gets the active textures from the material
  74551. * @returns an array of textures
  74552. */
  74553. getActiveTextures(): BaseTexture[];
  74554. /**
  74555. * Specifies if the material uses a texture
  74556. * @param texture defines the texture to check against the material
  74557. * @returns a boolean specifying if the material uses the texture
  74558. */
  74559. hasTexture(texture: BaseTexture): boolean;
  74560. /**
  74561. * Makes a duplicate of the material, and gives it a new name
  74562. * @param name defines the new name for the duplicated material
  74563. * @returns the cloned material
  74564. */
  74565. clone(name: string): ShaderMaterial;
  74566. /**
  74567. * Disposes the material
  74568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74570. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74571. */
  74572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74573. /**
  74574. * Serializes this material in a JSON representation
  74575. * @returns the serialized material object
  74576. */
  74577. serialize(): any;
  74578. /**
  74579. * Creates a shader material from parsed shader material data
  74580. * @param source defines the JSON represnetation of the material
  74581. * @param scene defines the hosting scene
  74582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74583. * @returns a new material
  74584. */
  74585. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74586. }
  74587. }
  74588. declare module BABYLON {
  74589. /** @hidden */
  74590. export var colorPixelShader: {
  74591. name: string;
  74592. shader: string;
  74593. };
  74594. }
  74595. declare module BABYLON {
  74596. /** @hidden */
  74597. export var colorVertexShader: {
  74598. name: string;
  74599. shader: string;
  74600. };
  74601. }
  74602. declare module BABYLON {
  74603. /**
  74604. * Line mesh
  74605. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74606. */
  74607. export class LinesMesh extends Mesh {
  74608. /**
  74609. * If vertex color should be applied to the mesh
  74610. */
  74611. useVertexColor?: boolean | undefined;
  74612. /**
  74613. * If vertex alpha should be applied to the mesh
  74614. */
  74615. useVertexAlpha?: boolean | undefined;
  74616. /**
  74617. * Color of the line (Default: White)
  74618. */
  74619. color: Color3;
  74620. /**
  74621. * Alpha of the line (Default: 1)
  74622. */
  74623. alpha: number;
  74624. /**
  74625. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74626. * This margin is expressed in world space coordinates, so its value may vary.
  74627. * Default value is 0.1
  74628. */
  74629. intersectionThreshold: number;
  74630. private _colorShader;
  74631. /**
  74632. * Creates a new LinesMesh
  74633. * @param name defines the name
  74634. * @param scene defines the hosting scene
  74635. * @param parent defines the parent mesh if any
  74636. * @param source defines the optional source LinesMesh used to clone data from
  74637. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74638. * When false, achieved by calling a clone(), also passing False.
  74639. * This will make creation of children, recursive.
  74640. * @param useVertexColor defines if this LinesMesh supports vertex color
  74641. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74642. */
  74643. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74644. /**
  74645. * If vertex color should be applied to the mesh
  74646. */
  74647. useVertexColor?: boolean | undefined,
  74648. /**
  74649. * If vertex alpha should be applied to the mesh
  74650. */
  74651. useVertexAlpha?: boolean | undefined);
  74652. private _addClipPlaneDefine;
  74653. private _removeClipPlaneDefine;
  74654. isReady(): boolean;
  74655. /**
  74656. * Returns the string "LineMesh"
  74657. */
  74658. getClassName(): string;
  74659. /**
  74660. * @hidden
  74661. */
  74662. /**
  74663. * @hidden
  74664. */
  74665. material: Material;
  74666. /**
  74667. * @hidden
  74668. */
  74669. readonly checkCollisions: boolean;
  74670. /** @hidden */
  74671. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74672. /** @hidden */
  74673. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74674. /**
  74675. * Disposes of the line mesh
  74676. * @param doNotRecurse If children should be disposed
  74677. */
  74678. dispose(doNotRecurse?: boolean): void;
  74679. /**
  74680. * Returns a new LineMesh object cloned from the current one.
  74681. */
  74682. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74683. /**
  74684. * Creates a new InstancedLinesMesh object from the mesh model.
  74685. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74686. * @param name defines the name of the new instance
  74687. * @returns a new InstancedLinesMesh
  74688. */
  74689. createInstance(name: string): InstancedLinesMesh;
  74690. }
  74691. /**
  74692. * Creates an instance based on a source LinesMesh
  74693. */
  74694. export class InstancedLinesMesh extends InstancedMesh {
  74695. /**
  74696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74697. * This margin is expressed in world space coordinates, so its value may vary.
  74698. * Initilized with the intersectionThreshold value of the source LinesMesh
  74699. */
  74700. intersectionThreshold: number;
  74701. constructor(name: string, source: LinesMesh);
  74702. /**
  74703. * Returns the string "InstancedLinesMesh".
  74704. */
  74705. getClassName(): string;
  74706. }
  74707. }
  74708. declare module BABYLON {
  74709. /** @hidden */
  74710. export var linePixelShader: {
  74711. name: string;
  74712. shader: string;
  74713. };
  74714. }
  74715. declare module BABYLON {
  74716. /** @hidden */
  74717. export var lineVertexShader: {
  74718. name: string;
  74719. shader: string;
  74720. };
  74721. }
  74722. declare module BABYLON {
  74723. interface AbstractMesh {
  74724. /**
  74725. * Disables the mesh edge rendering mode
  74726. * @returns the currentAbstractMesh
  74727. */
  74728. disableEdgesRendering(): AbstractMesh;
  74729. /**
  74730. * Enables the edge rendering mode on the mesh.
  74731. * This mode makes the mesh edges visible
  74732. * @param epsilon defines the maximal distance between two angles to detect a face
  74733. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74734. * @returns the currentAbstractMesh
  74735. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74736. */
  74737. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74738. /**
  74739. * Gets the edgesRenderer associated with the mesh
  74740. */
  74741. edgesRenderer: Nullable<EdgesRenderer>;
  74742. }
  74743. interface LinesMesh {
  74744. /**
  74745. * Enables the edge rendering mode on the mesh.
  74746. * This mode makes the mesh edges visible
  74747. * @param epsilon defines the maximal distance between two angles to detect a face
  74748. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74749. * @returns the currentAbstractMesh
  74750. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74751. */
  74752. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74753. }
  74754. interface InstancedLinesMesh {
  74755. /**
  74756. * Enables the edge rendering mode on the mesh.
  74757. * This mode makes the mesh edges visible
  74758. * @param epsilon defines the maximal distance between two angles to detect a face
  74759. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74760. * @returns the current InstancedLinesMesh
  74761. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74762. */
  74763. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74764. }
  74765. /**
  74766. * Defines the minimum contract an Edges renderer should follow.
  74767. */
  74768. export interface IEdgesRenderer extends IDisposable {
  74769. /**
  74770. * Gets or sets a boolean indicating if the edgesRenderer is active
  74771. */
  74772. isEnabled: boolean;
  74773. /**
  74774. * Renders the edges of the attached mesh,
  74775. */
  74776. render(): void;
  74777. /**
  74778. * Checks wether or not the edges renderer is ready to render.
  74779. * @return true if ready, otherwise false.
  74780. */
  74781. isReady(): boolean;
  74782. }
  74783. /**
  74784. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74785. */
  74786. export class EdgesRenderer implements IEdgesRenderer {
  74787. /**
  74788. * Define the size of the edges with an orthographic camera
  74789. */
  74790. edgesWidthScalerForOrthographic: number;
  74791. /**
  74792. * Define the size of the edges with a perspective camera
  74793. */
  74794. edgesWidthScalerForPerspective: number;
  74795. protected _source: AbstractMesh;
  74796. protected _linesPositions: number[];
  74797. protected _linesNormals: number[];
  74798. protected _linesIndices: number[];
  74799. protected _epsilon: number;
  74800. protected _indicesCount: number;
  74801. protected _lineShader: ShaderMaterial;
  74802. protected _ib: WebGLBuffer;
  74803. protected _buffers: {
  74804. [key: string]: Nullable<VertexBuffer>;
  74805. };
  74806. protected _checkVerticesInsteadOfIndices: boolean;
  74807. private _meshRebuildObserver;
  74808. private _meshDisposeObserver;
  74809. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74810. isEnabled: boolean;
  74811. /**
  74812. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74813. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74814. * @param source Mesh used to create edges
  74815. * @param epsilon sum of angles in adjacency to check for edge
  74816. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74817. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74818. */
  74819. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74820. protected _prepareRessources(): void;
  74821. /** @hidden */
  74822. _rebuild(): void;
  74823. /**
  74824. * Releases the required resources for the edges renderer
  74825. */
  74826. dispose(): void;
  74827. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74828. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74829. /**
  74830. * Checks if the pair of p0 and p1 is en edge
  74831. * @param faceIndex
  74832. * @param edge
  74833. * @param faceNormals
  74834. * @param p0
  74835. * @param p1
  74836. * @private
  74837. */
  74838. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74839. /**
  74840. * push line into the position, normal and index buffer
  74841. * @protected
  74842. */
  74843. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74844. /**
  74845. * Generates lines edges from adjacencjes
  74846. * @private
  74847. */
  74848. _generateEdgesLines(): void;
  74849. /**
  74850. * Checks wether or not the edges renderer is ready to render.
  74851. * @return true if ready, otherwise false.
  74852. */
  74853. isReady(): boolean;
  74854. /**
  74855. * Renders the edges of the attached mesh,
  74856. */
  74857. render(): void;
  74858. }
  74859. /**
  74860. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74861. */
  74862. export class LineEdgesRenderer extends EdgesRenderer {
  74863. /**
  74864. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74865. * @param source LineMesh used to generate edges
  74866. * @param epsilon not important (specified angle for edge detection)
  74867. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74868. */
  74869. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74870. /**
  74871. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74872. */
  74873. _generateEdgesLines(): void;
  74874. }
  74875. }
  74876. declare module BABYLON {
  74877. /**
  74878. * This represents the object necessary to create a rendering group.
  74879. * This is exclusively used and created by the rendering manager.
  74880. * To modify the behavior, you use the available helpers in your scene or meshes.
  74881. * @hidden
  74882. */
  74883. export class RenderingGroup {
  74884. index: number;
  74885. private _scene;
  74886. private _opaqueSubMeshes;
  74887. private _transparentSubMeshes;
  74888. private _alphaTestSubMeshes;
  74889. private _depthOnlySubMeshes;
  74890. private _particleSystems;
  74891. private _spriteManagers;
  74892. private _opaqueSortCompareFn;
  74893. private _alphaTestSortCompareFn;
  74894. private _transparentSortCompareFn;
  74895. private _renderOpaque;
  74896. private _renderAlphaTest;
  74897. private _renderTransparent;
  74898. private _edgesRenderers;
  74899. onBeforeTransparentRendering: () => void;
  74900. /**
  74901. * Set the opaque sort comparison function.
  74902. * If null the sub meshes will be render in the order they were created
  74903. */
  74904. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74905. /**
  74906. * Set the alpha test sort comparison function.
  74907. * If null the sub meshes will be render in the order they were created
  74908. */
  74909. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74910. /**
  74911. * Set the transparent sort comparison function.
  74912. * If null the sub meshes will be render in the order they were created
  74913. */
  74914. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74915. /**
  74916. * Creates a new rendering group.
  74917. * @param index The rendering group index
  74918. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74919. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74920. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74921. */
  74922. 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>);
  74923. /**
  74924. * Render all the sub meshes contained in the group.
  74925. * @param customRenderFunction Used to override the default render behaviour of the group.
  74926. * @returns true if rendered some submeshes.
  74927. */
  74928. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74929. /**
  74930. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74931. * @param subMeshes The submeshes to render
  74932. */
  74933. private renderOpaqueSorted;
  74934. /**
  74935. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74936. * @param subMeshes The submeshes to render
  74937. */
  74938. private renderAlphaTestSorted;
  74939. /**
  74940. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74941. * @param subMeshes The submeshes to render
  74942. */
  74943. private renderTransparentSorted;
  74944. /**
  74945. * Renders the submeshes in a specified order.
  74946. * @param subMeshes The submeshes to sort before render
  74947. * @param sortCompareFn The comparison function use to sort
  74948. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74949. * @param transparent Specifies to activate blending if true
  74950. */
  74951. private static renderSorted;
  74952. /**
  74953. * Renders the submeshes in the order they were dispatched (no sort applied).
  74954. * @param subMeshes The submeshes to render
  74955. */
  74956. private static renderUnsorted;
  74957. /**
  74958. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74959. * are rendered back to front if in the same alpha index.
  74960. *
  74961. * @param a The first submesh
  74962. * @param b The second submesh
  74963. * @returns The result of the comparison
  74964. */
  74965. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74966. /**
  74967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74968. * are rendered back to front.
  74969. *
  74970. * @param a The first submesh
  74971. * @param b The second submesh
  74972. * @returns The result of the comparison
  74973. */
  74974. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74975. /**
  74976. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74977. * are rendered front to back (prevent overdraw).
  74978. *
  74979. * @param a The first submesh
  74980. * @param b The second submesh
  74981. * @returns The result of the comparison
  74982. */
  74983. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74984. /**
  74985. * Resets the different lists of submeshes to prepare a new frame.
  74986. */
  74987. prepare(): void;
  74988. dispose(): void;
  74989. /**
  74990. * Inserts the submesh in its correct queue depending on its material.
  74991. * @param subMesh The submesh to dispatch
  74992. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74993. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74994. */
  74995. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74996. dispatchSprites(spriteManager: ISpriteManager): void;
  74997. dispatchParticles(particleSystem: IParticleSystem): void;
  74998. private _renderParticles;
  74999. private _renderSprites;
  75000. }
  75001. }
  75002. declare module BABYLON {
  75003. /**
  75004. * Interface describing the different options available in the rendering manager
  75005. * regarding Auto Clear between groups.
  75006. */
  75007. export interface IRenderingManagerAutoClearSetup {
  75008. /**
  75009. * Defines whether or not autoclear is enable.
  75010. */
  75011. autoClear: boolean;
  75012. /**
  75013. * Defines whether or not to autoclear the depth buffer.
  75014. */
  75015. depth: boolean;
  75016. /**
  75017. * Defines whether or not to autoclear the stencil buffer.
  75018. */
  75019. stencil: boolean;
  75020. }
  75021. /**
  75022. * This class is used by the onRenderingGroupObservable
  75023. */
  75024. export class RenderingGroupInfo {
  75025. /**
  75026. * The Scene that being rendered
  75027. */
  75028. scene: Scene;
  75029. /**
  75030. * The camera currently used for the rendering pass
  75031. */
  75032. camera: Nullable<Camera>;
  75033. /**
  75034. * The ID of the renderingGroup being processed
  75035. */
  75036. renderingGroupId: number;
  75037. }
  75038. /**
  75039. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75040. * It is enable to manage the different groups as well as the different necessary sort functions.
  75041. * This should not be used directly aside of the few static configurations
  75042. */
  75043. export class RenderingManager {
  75044. /**
  75045. * The max id used for rendering groups (not included)
  75046. */
  75047. static MAX_RENDERINGGROUPS: number;
  75048. /**
  75049. * The min id used for rendering groups (included)
  75050. */
  75051. static MIN_RENDERINGGROUPS: number;
  75052. /**
  75053. * Used to globally prevent autoclearing scenes.
  75054. */
  75055. static AUTOCLEAR: boolean;
  75056. /**
  75057. * @hidden
  75058. */
  75059. _useSceneAutoClearSetup: boolean;
  75060. private _scene;
  75061. private _renderingGroups;
  75062. private _depthStencilBufferAlreadyCleaned;
  75063. private _autoClearDepthStencil;
  75064. private _customOpaqueSortCompareFn;
  75065. private _customAlphaTestSortCompareFn;
  75066. private _customTransparentSortCompareFn;
  75067. private _renderingGroupInfo;
  75068. /**
  75069. * Instantiates a new rendering group for a particular scene
  75070. * @param scene Defines the scene the groups belongs to
  75071. */
  75072. constructor(scene: Scene);
  75073. private _clearDepthStencilBuffer;
  75074. /**
  75075. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75076. * @hidden
  75077. */
  75078. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75079. /**
  75080. * Resets the different information of the group to prepare a new frame
  75081. * @hidden
  75082. */
  75083. reset(): void;
  75084. /**
  75085. * Dispose and release the group and its associated resources.
  75086. * @hidden
  75087. */
  75088. dispose(): void;
  75089. /**
  75090. * Clear the info related to rendering groups preventing retention points during dispose.
  75091. */
  75092. freeRenderingGroups(): void;
  75093. private _prepareRenderingGroup;
  75094. /**
  75095. * Add a sprite manager to the rendering manager in order to render it this frame.
  75096. * @param spriteManager Define the sprite manager to render
  75097. */
  75098. dispatchSprites(spriteManager: ISpriteManager): void;
  75099. /**
  75100. * Add a particle system to the rendering manager in order to render it this frame.
  75101. * @param particleSystem Define the particle system to render
  75102. */
  75103. dispatchParticles(particleSystem: IParticleSystem): void;
  75104. /**
  75105. * Add a submesh to the manager in order to render it this frame
  75106. * @param subMesh The submesh to dispatch
  75107. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75108. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75109. */
  75110. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75111. /**
  75112. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75113. * This allowed control for front to back rendering or reversly depending of the special needs.
  75114. *
  75115. * @param renderingGroupId The rendering group id corresponding to its index
  75116. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75117. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75118. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75119. */
  75120. 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;
  75121. /**
  75122. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75123. *
  75124. * @param renderingGroupId The rendering group id corresponding to its index
  75125. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75126. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75127. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75128. */
  75129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75130. /**
  75131. * Gets the current auto clear configuration for one rendering group of the rendering
  75132. * manager.
  75133. * @param index the rendering group index to get the information for
  75134. * @returns The auto clear setup for the requested rendering group
  75135. */
  75136. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75137. }
  75138. }
  75139. declare module BABYLON {
  75140. /**
  75141. * This Helps creating a texture that will be created from a camera in your scene.
  75142. * It is basically a dynamic texture that could be used to create special effects for instance.
  75143. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75144. */
  75145. export class RenderTargetTexture extends Texture {
  75146. isCube: boolean;
  75147. /**
  75148. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75149. */
  75150. static readonly REFRESHRATE_RENDER_ONCE: number;
  75151. /**
  75152. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75153. */
  75154. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75155. /**
  75156. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75157. * the central point of your effect and can save a lot of performances.
  75158. */
  75159. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75160. /**
  75161. * Use this predicate to dynamically define the list of mesh you want to render.
  75162. * If set, the renderList property will be overwritten.
  75163. */
  75164. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75165. private _renderList;
  75166. /**
  75167. * Use this list to define the list of mesh you want to render.
  75168. */
  75169. renderList: Nullable<Array<AbstractMesh>>;
  75170. private _hookArray;
  75171. /**
  75172. * Define if particles should be rendered in your texture.
  75173. */
  75174. renderParticles: boolean;
  75175. /**
  75176. * Define if sprites should be rendered in your texture.
  75177. */
  75178. renderSprites: boolean;
  75179. /**
  75180. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75181. */
  75182. coordinatesMode: number;
  75183. /**
  75184. * Define the camera used to render the texture.
  75185. */
  75186. activeCamera: Nullable<Camera>;
  75187. /**
  75188. * Override the render function of the texture with your own one.
  75189. */
  75190. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75191. /**
  75192. * Define if camera post processes should be use while rendering the texture.
  75193. */
  75194. useCameraPostProcesses: boolean;
  75195. /**
  75196. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75197. */
  75198. ignoreCameraViewport: boolean;
  75199. private _postProcessManager;
  75200. private _postProcesses;
  75201. private _resizeObserver;
  75202. /**
  75203. * An event triggered when the texture is unbind.
  75204. */
  75205. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75206. /**
  75207. * An event triggered when the texture is unbind.
  75208. */
  75209. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75210. private _onAfterUnbindObserver;
  75211. /**
  75212. * Set a after unbind callback in the texture.
  75213. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75214. */
  75215. onAfterUnbind: () => void;
  75216. /**
  75217. * An event triggered before rendering the texture
  75218. */
  75219. onBeforeRenderObservable: Observable<number>;
  75220. private _onBeforeRenderObserver;
  75221. /**
  75222. * Set a before render callback in the texture.
  75223. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75224. */
  75225. onBeforeRender: (faceIndex: number) => void;
  75226. /**
  75227. * An event triggered after rendering the texture
  75228. */
  75229. onAfterRenderObservable: Observable<number>;
  75230. private _onAfterRenderObserver;
  75231. /**
  75232. * Set a after render callback in the texture.
  75233. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75234. */
  75235. onAfterRender: (faceIndex: number) => void;
  75236. /**
  75237. * An event triggered after the texture clear
  75238. */
  75239. onClearObservable: Observable<Engine>;
  75240. private _onClearObserver;
  75241. /**
  75242. * Set a clear callback in the texture.
  75243. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75244. */
  75245. onClear: (Engine: Engine) => void;
  75246. /**
  75247. * Define the clear color of the Render Target if it should be different from the scene.
  75248. */
  75249. clearColor: Color4;
  75250. protected _size: number | {
  75251. width: number;
  75252. height: number;
  75253. };
  75254. protected _initialSizeParameter: number | {
  75255. width: number;
  75256. height: number;
  75257. } | {
  75258. ratio: number;
  75259. };
  75260. protected _sizeRatio: Nullable<number>;
  75261. /** @hidden */
  75262. _generateMipMaps: boolean;
  75263. protected _renderingManager: RenderingManager;
  75264. /** @hidden */
  75265. _waitingRenderList: string[];
  75266. protected _doNotChangeAspectRatio: boolean;
  75267. protected _currentRefreshId: number;
  75268. protected _refreshRate: number;
  75269. protected _textureMatrix: Matrix;
  75270. protected _samples: number;
  75271. protected _renderTargetOptions: RenderTargetCreationOptions;
  75272. /**
  75273. * Gets render target creation options that were used.
  75274. */
  75275. readonly renderTargetOptions: RenderTargetCreationOptions;
  75276. protected _engine: Engine;
  75277. protected _onRatioRescale(): void;
  75278. /**
  75279. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75280. * It must define where the camera used to render the texture is set
  75281. */
  75282. boundingBoxPosition: Vector3;
  75283. private _boundingBoxSize;
  75284. /**
  75285. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75286. * When defined, the cubemap will switch to local mode
  75287. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75288. * @example https://www.babylonjs-playground.com/#RNASML
  75289. */
  75290. boundingBoxSize: Vector3;
  75291. /**
  75292. * In case the RTT has been created with a depth texture, get the associated
  75293. * depth texture.
  75294. * Otherwise, return null.
  75295. */
  75296. depthStencilTexture: Nullable<InternalTexture>;
  75297. /**
  75298. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75299. * or used a shadow, depth texture...
  75300. * @param name The friendly name of the texture
  75301. * @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)
  75302. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75303. * @param generateMipMaps True if mip maps need to be generated after render.
  75304. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75305. * @param type The type of the buffer in the RTT (int, half float, float...)
  75306. * @param isCube True if a cube texture needs to be created
  75307. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75308. * @param generateDepthBuffer True to generate a depth buffer
  75309. * @param generateStencilBuffer True to generate a stencil buffer
  75310. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75311. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75312. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75313. */
  75314. constructor(name: string, size: number | {
  75315. width: number;
  75316. height: number;
  75317. } | {
  75318. ratio: number;
  75319. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75320. /**
  75321. * Creates a depth stencil texture.
  75322. * This is only available in WebGL 2 or with the depth texture extension available.
  75323. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75324. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75325. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75326. */
  75327. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75328. private _processSizeParameter;
  75329. /**
  75330. * Define the number of samples to use in case of MSAA.
  75331. * It defaults to one meaning no MSAA has been enabled.
  75332. */
  75333. samples: number;
  75334. /**
  75335. * Resets the refresh counter of the texture and start bak from scratch.
  75336. * Could be useful to regenerate the texture if it is setup to render only once.
  75337. */
  75338. resetRefreshCounter(): void;
  75339. /**
  75340. * Define the refresh rate of the texture or the rendering frequency.
  75341. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75342. */
  75343. refreshRate: number;
  75344. /**
  75345. * Adds a post process to the render target rendering passes.
  75346. * @param postProcess define the post process to add
  75347. */
  75348. addPostProcess(postProcess: PostProcess): void;
  75349. /**
  75350. * Clear all the post processes attached to the render target
  75351. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75352. */
  75353. clearPostProcesses(dispose?: boolean): void;
  75354. /**
  75355. * Remove one of the post process from the list of attached post processes to the texture
  75356. * @param postProcess define the post process to remove from the list
  75357. */
  75358. removePostProcess(postProcess: PostProcess): void;
  75359. /** @hidden */
  75360. _shouldRender(): boolean;
  75361. /**
  75362. * Gets the actual render size of the texture.
  75363. * @returns the width of the render size
  75364. */
  75365. getRenderSize(): number;
  75366. /**
  75367. * Gets the actual render width of the texture.
  75368. * @returns the width of the render size
  75369. */
  75370. getRenderWidth(): number;
  75371. /**
  75372. * Gets the actual render height of the texture.
  75373. * @returns the height of the render size
  75374. */
  75375. getRenderHeight(): number;
  75376. /**
  75377. * Get if the texture can be rescaled or not.
  75378. */
  75379. readonly canRescale: boolean;
  75380. /**
  75381. * Resize the texture using a ratio.
  75382. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75383. */
  75384. scale(ratio: number): void;
  75385. /**
  75386. * Get the texture reflection matrix used to rotate/transform the reflection.
  75387. * @returns the reflection matrix
  75388. */
  75389. getReflectionTextureMatrix(): Matrix;
  75390. /**
  75391. * Resize the texture to a new desired size.
  75392. * Be carrefull as it will recreate all the data in the new texture.
  75393. * @param size Define the new size. It can be:
  75394. * - a number for squared texture,
  75395. * - an object containing { width: number, height: number }
  75396. * - or an object containing a ratio { ratio: number }
  75397. */
  75398. resize(size: number | {
  75399. width: number;
  75400. height: number;
  75401. } | {
  75402. ratio: number;
  75403. }): void;
  75404. /**
  75405. * Renders all the objects from the render list into the texture.
  75406. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75407. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75408. */
  75409. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75410. private _bestReflectionRenderTargetDimension;
  75411. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75412. private renderToTarget;
  75413. /**
  75414. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75415. * This allowed control for front to back rendering or reversly depending of the special needs.
  75416. *
  75417. * @param renderingGroupId The rendering group id corresponding to its index
  75418. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75419. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75420. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75421. */
  75422. 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;
  75423. /**
  75424. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75425. *
  75426. * @param renderingGroupId The rendering group id corresponding to its index
  75427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75428. */
  75429. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75430. /**
  75431. * Clones the texture.
  75432. * @returns the cloned texture
  75433. */
  75434. clone(): RenderTargetTexture;
  75435. /**
  75436. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75437. * @returns The JSON representation of the texture
  75438. */
  75439. serialize(): any;
  75440. /**
  75441. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75442. */
  75443. disposeFramebufferObjects(): void;
  75444. /**
  75445. * Dispose the texture and release its associated resources.
  75446. */
  75447. dispose(): void;
  75448. /** @hidden */
  75449. _rebuild(): void;
  75450. /**
  75451. * Clear the info related to rendering groups preventing retention point in material dispose.
  75452. */
  75453. freeRenderingGroups(): void;
  75454. }
  75455. }
  75456. declare module BABYLON {
  75457. /**
  75458. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75459. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75460. * You can then easily use it as a reflectionTexture on a flat surface.
  75461. * In case the surface is not a plane, please consider relying on reflection probes.
  75462. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75463. */
  75464. export class MirrorTexture extends RenderTargetTexture {
  75465. private scene;
  75466. /**
  75467. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75468. * 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.
  75469. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75470. */
  75471. mirrorPlane: Plane;
  75472. /**
  75473. * Define the blur ratio used to blur the reflection if needed.
  75474. */
  75475. blurRatio: number;
  75476. /**
  75477. * Define the adaptive blur kernel used to blur the reflection if needed.
  75478. * This will autocompute the closest best match for the `blurKernel`
  75479. */
  75480. adaptiveBlurKernel: number;
  75481. /**
  75482. * Define the blur kernel used to blur the reflection if needed.
  75483. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75484. */
  75485. blurKernel: number;
  75486. /**
  75487. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75488. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75489. */
  75490. blurKernelX: number;
  75491. /**
  75492. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75493. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75494. */
  75495. blurKernelY: number;
  75496. private _autoComputeBlurKernel;
  75497. protected _onRatioRescale(): void;
  75498. private _updateGammaSpace;
  75499. private _imageProcessingConfigChangeObserver;
  75500. private _transformMatrix;
  75501. private _mirrorMatrix;
  75502. private _savedViewMatrix;
  75503. private _blurX;
  75504. private _blurY;
  75505. private _adaptiveBlurKernel;
  75506. private _blurKernelX;
  75507. private _blurKernelY;
  75508. private _blurRatio;
  75509. /**
  75510. * Instantiates a Mirror Texture.
  75511. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75512. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75513. * You can then easily use it as a reflectionTexture on a flat surface.
  75514. * In case the surface is not a plane, please consider relying on reflection probes.
  75515. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75516. * @param name
  75517. * @param size
  75518. * @param scene
  75519. * @param generateMipMaps
  75520. * @param type
  75521. * @param samplingMode
  75522. * @param generateDepthBuffer
  75523. */
  75524. constructor(name: string, size: number | {
  75525. width: number;
  75526. height: number;
  75527. } | {
  75528. ratio: number;
  75529. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75530. private _preparePostProcesses;
  75531. /**
  75532. * Clone the mirror texture.
  75533. * @returns the cloned texture
  75534. */
  75535. clone(): MirrorTexture;
  75536. /**
  75537. * Serialize the texture to a JSON representation you could use in Parse later on
  75538. * @returns the serialized JSON representation
  75539. */
  75540. serialize(): any;
  75541. /**
  75542. * Dispose the texture and release its associated resources.
  75543. */
  75544. dispose(): void;
  75545. }
  75546. }
  75547. declare module BABYLON {
  75548. /**
  75549. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75550. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75551. */
  75552. export class Texture extends BaseTexture {
  75553. /** @hidden */
  75554. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75555. /** @hidden */
  75556. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75557. /** @hidden */
  75558. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75559. /** nearest is mag = nearest and min = nearest and mip = linear */
  75560. static readonly NEAREST_SAMPLINGMODE: number;
  75561. /** nearest is mag = nearest and min = nearest and mip = linear */
  75562. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75564. static readonly BILINEAR_SAMPLINGMODE: number;
  75565. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75566. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75567. /** Trilinear is mag = linear and min = linear and mip = linear */
  75568. static readonly TRILINEAR_SAMPLINGMODE: number;
  75569. /** Trilinear is mag = linear and min = linear and mip = linear */
  75570. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75571. /** mag = nearest and min = nearest and mip = nearest */
  75572. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75573. /** mag = nearest and min = linear and mip = nearest */
  75574. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75575. /** mag = nearest and min = linear and mip = linear */
  75576. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75577. /** mag = nearest and min = linear and mip = none */
  75578. static readonly NEAREST_LINEAR: number;
  75579. /** mag = nearest and min = nearest and mip = none */
  75580. static readonly NEAREST_NEAREST: number;
  75581. /** mag = linear and min = nearest and mip = nearest */
  75582. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75583. /** mag = linear and min = nearest and mip = linear */
  75584. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75585. /** mag = linear and min = linear and mip = none */
  75586. static readonly LINEAR_LINEAR: number;
  75587. /** mag = linear and min = nearest and mip = none */
  75588. static readonly LINEAR_NEAREST: number;
  75589. /** Explicit coordinates mode */
  75590. static readonly EXPLICIT_MODE: number;
  75591. /** Spherical coordinates mode */
  75592. static readonly SPHERICAL_MODE: number;
  75593. /** Planar coordinates mode */
  75594. static readonly PLANAR_MODE: number;
  75595. /** Cubic coordinates mode */
  75596. static readonly CUBIC_MODE: number;
  75597. /** Projection coordinates mode */
  75598. static readonly PROJECTION_MODE: number;
  75599. /** Inverse Cubic coordinates mode */
  75600. static readonly SKYBOX_MODE: number;
  75601. /** Inverse Cubic coordinates mode */
  75602. static readonly INVCUBIC_MODE: number;
  75603. /** Equirectangular coordinates mode */
  75604. static readonly EQUIRECTANGULAR_MODE: number;
  75605. /** Equirectangular Fixed coordinates mode */
  75606. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75607. /** Equirectangular Fixed Mirrored coordinates mode */
  75608. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75609. /** Texture is not repeating outside of 0..1 UVs */
  75610. static readonly CLAMP_ADDRESSMODE: number;
  75611. /** Texture is repeating outside of 0..1 UVs */
  75612. static readonly WRAP_ADDRESSMODE: number;
  75613. /** Texture is repeating and mirrored */
  75614. static readonly MIRROR_ADDRESSMODE: number;
  75615. /**
  75616. * 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
  75617. */
  75618. static UseSerializedUrlIfAny: boolean;
  75619. /**
  75620. * Define the url of the texture.
  75621. */
  75622. url: Nullable<string>;
  75623. /**
  75624. * Define an offset on the texture to offset the u coordinates of the UVs
  75625. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75626. */
  75627. uOffset: number;
  75628. /**
  75629. * Define an offset on the texture to offset the v coordinates of the UVs
  75630. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75631. */
  75632. vOffset: number;
  75633. /**
  75634. * Define an offset on the texture to scale the u coordinates of the UVs
  75635. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75636. */
  75637. uScale: number;
  75638. /**
  75639. * Define an offset on the texture to scale the v coordinates of the UVs
  75640. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75641. */
  75642. vScale: number;
  75643. /**
  75644. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75645. * @see http://doc.babylonjs.com/how_to/more_materials
  75646. */
  75647. uAng: number;
  75648. /**
  75649. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75650. * @see http://doc.babylonjs.com/how_to/more_materials
  75651. */
  75652. vAng: number;
  75653. /**
  75654. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75655. * @see http://doc.babylonjs.com/how_to/more_materials
  75656. */
  75657. wAng: number;
  75658. /**
  75659. * Defines the center of rotation (U)
  75660. */
  75661. uRotationCenter: number;
  75662. /**
  75663. * Defines the center of rotation (V)
  75664. */
  75665. vRotationCenter: number;
  75666. /**
  75667. * Defines the center of rotation (W)
  75668. */
  75669. wRotationCenter: number;
  75670. /**
  75671. * Are mip maps generated for this texture or not.
  75672. */
  75673. readonly noMipmap: boolean;
  75674. private _noMipmap;
  75675. /** @hidden */
  75676. _invertY: boolean;
  75677. private _rowGenerationMatrix;
  75678. private _cachedTextureMatrix;
  75679. private _projectionModeMatrix;
  75680. private _t0;
  75681. private _t1;
  75682. private _t2;
  75683. private _cachedUOffset;
  75684. private _cachedVOffset;
  75685. private _cachedUScale;
  75686. private _cachedVScale;
  75687. private _cachedUAng;
  75688. private _cachedVAng;
  75689. private _cachedWAng;
  75690. private _cachedProjectionMatrixId;
  75691. private _cachedCoordinatesMode;
  75692. /** @hidden */
  75693. protected _initialSamplingMode: number;
  75694. /** @hidden */
  75695. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75696. private _deleteBuffer;
  75697. protected _format: Nullable<number>;
  75698. private _delayedOnLoad;
  75699. private _delayedOnError;
  75700. /**
  75701. * Observable triggered once the texture has been loaded.
  75702. */
  75703. onLoadObservable: Observable<Texture>;
  75704. protected _isBlocking: boolean;
  75705. /**
  75706. * Is the texture preventing material to render while loading.
  75707. * If false, a default texture will be used instead of the loading one during the preparation step.
  75708. */
  75709. isBlocking: boolean;
  75710. /**
  75711. * Get the current sampling mode associated with the texture.
  75712. */
  75713. readonly samplingMode: number;
  75714. /**
  75715. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75716. */
  75717. readonly invertY: boolean;
  75718. /**
  75719. * Instantiates a new texture.
  75720. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75721. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75722. * @param url define the url of the picture to load as a texture
  75723. * @param scene define the scene the texture will belong to
  75724. * @param noMipmap define if the texture will require mip maps or not
  75725. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75726. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75727. * @param onLoad define a callback triggered when the texture has been loaded
  75728. * @param onError define a callback triggered when an error occurred during the loading session
  75729. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75730. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75731. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75732. */
  75733. 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);
  75734. /**
  75735. * Update the url (and optional buffer) of this texture if url was null during construction.
  75736. * @param url the url of the texture
  75737. * @param buffer the buffer of the texture (defaults to null)
  75738. * @param onLoad callback called when the texture is loaded (defaults to null)
  75739. */
  75740. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75741. /**
  75742. * Finish the loading sequence of a texture flagged as delayed load.
  75743. * @hidden
  75744. */
  75745. delayLoad(): void;
  75746. private _prepareRowForTextureGeneration;
  75747. /**
  75748. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75749. * @returns the transform matrix of the texture.
  75750. */
  75751. getTextureMatrix(): Matrix;
  75752. /**
  75753. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75754. * @returns The reflection texture transform
  75755. */
  75756. getReflectionTextureMatrix(): Matrix;
  75757. /**
  75758. * Clones the texture.
  75759. * @returns the cloned texture
  75760. */
  75761. clone(): Texture;
  75762. /**
  75763. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75764. * @returns The JSON representation of the texture
  75765. */
  75766. serialize(): any;
  75767. /**
  75768. * Get the current class name of the texture useful for serialization or dynamic coding.
  75769. * @returns "Texture"
  75770. */
  75771. getClassName(): string;
  75772. /**
  75773. * Dispose the texture and release its associated resources.
  75774. */
  75775. dispose(): void;
  75776. /**
  75777. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75778. * @param parsedTexture Define the JSON representation of the texture
  75779. * @param scene Define the scene the parsed texture should be instantiated in
  75780. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75781. * @returns The parsed texture if successful
  75782. */
  75783. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75784. /**
  75785. * Creates a texture from its base 64 representation.
  75786. * @param data Define the base64 payload without the data: prefix
  75787. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75788. * @param scene Define the scene the texture should belong to
  75789. * @param noMipmap Forces the texture to not create mip map information if true
  75790. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75791. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75792. * @param onLoad define a callback triggered when the texture has been loaded
  75793. * @param onError define a callback triggered when an error occurred during the loading session
  75794. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75795. * @returns the created texture
  75796. */
  75797. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75798. /**
  75799. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75800. * @param data Define the base64 payload without the data: prefix
  75801. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75802. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75803. * @param scene Define the scene the texture should belong to
  75804. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75805. * @param noMipmap Forces the texture to not create mip map information if true
  75806. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75807. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75808. * @param onLoad define a callback triggered when the texture has been loaded
  75809. * @param onError define a callback triggered when an error occurred during the loading session
  75810. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75811. * @returns the created texture
  75812. */
  75813. 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;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /**
  75818. * Raw texture can help creating a texture directly from an array of data.
  75819. * This can be super useful if you either get the data from an uncompressed source or
  75820. * if you wish to create your texture pixel by pixel.
  75821. */
  75822. export class RawTexture extends Texture {
  75823. /**
  75824. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75825. */
  75826. format: number;
  75827. private _engine;
  75828. /**
  75829. * Instantiates a new RawTexture.
  75830. * Raw texture can help creating a texture directly from an array of data.
  75831. * This can be super useful if you either get the data from an uncompressed source or
  75832. * if you wish to create your texture pixel by pixel.
  75833. * @param data define the array of data to use to create the texture
  75834. * @param width define the width of the texture
  75835. * @param height define the height of the texture
  75836. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75837. * @param scene define the scene the texture belongs to
  75838. * @param generateMipMaps define whether mip maps should be generated or not
  75839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75841. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75842. */
  75843. constructor(data: ArrayBufferView, width: number, height: number,
  75844. /**
  75845. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75846. */
  75847. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75848. /**
  75849. * Updates the texture underlying data.
  75850. * @param data Define the new data of the texture
  75851. */
  75852. update(data: ArrayBufferView): void;
  75853. /**
  75854. * Creates a luminance texture from some data.
  75855. * @param data Define the texture data
  75856. * @param width Define the width of the texture
  75857. * @param height Define the height of the texture
  75858. * @param scene Define the scene the texture belongs to
  75859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75862. * @returns the luminance texture
  75863. */
  75864. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75865. /**
  75866. * Creates a luminance alpha texture from some data.
  75867. * @param data Define the texture data
  75868. * @param width Define the width of the texture
  75869. * @param height Define the height of the texture
  75870. * @param scene Define the scene the texture belongs to
  75871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75874. * @returns the luminance alpha texture
  75875. */
  75876. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75877. /**
  75878. * Creates an alpha texture from some data.
  75879. * @param data Define the texture data
  75880. * @param width Define the width of the texture
  75881. * @param height Define the height of the texture
  75882. * @param scene Define the scene the texture belongs to
  75883. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75884. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75885. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75886. * @returns the alpha texture
  75887. */
  75888. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75889. /**
  75890. * Creates a RGB texture from some data.
  75891. * @param data Define the texture data
  75892. * @param width Define the width of the texture
  75893. * @param height Define the height of the texture
  75894. * @param scene Define the scene the texture belongs to
  75895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75899. * @returns the RGB alpha texture
  75900. */
  75901. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75902. /**
  75903. * Creates a RGBA texture from some data.
  75904. * @param data Define the texture data
  75905. * @param width Define the width of the texture
  75906. * @param height Define the height of the texture
  75907. * @param scene Define the scene the texture belongs to
  75908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75912. * @returns the RGBA texture
  75913. */
  75914. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75915. /**
  75916. * Creates a R texture from some data.
  75917. * @param data Define the texture data
  75918. * @param width Define the width of the texture
  75919. * @param height Define the height of the texture
  75920. * @param scene Define the scene the texture belongs to
  75921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75924. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75925. * @returns the R texture
  75926. */
  75927. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75928. }
  75929. }
  75930. declare module BABYLON {
  75931. /**
  75932. * Defines a runtime animation
  75933. */
  75934. export class RuntimeAnimation {
  75935. private _events;
  75936. /**
  75937. * The current frame of the runtime animation
  75938. */
  75939. private _currentFrame;
  75940. /**
  75941. * The animation used by the runtime animation
  75942. */
  75943. private _animation;
  75944. /**
  75945. * The target of the runtime animation
  75946. */
  75947. private _target;
  75948. /**
  75949. * The initiating animatable
  75950. */
  75951. private _host;
  75952. /**
  75953. * The original value of the runtime animation
  75954. */
  75955. private _originalValue;
  75956. /**
  75957. * The original blend value of the runtime animation
  75958. */
  75959. private _originalBlendValue;
  75960. /**
  75961. * The offsets cache of the runtime animation
  75962. */
  75963. private _offsetsCache;
  75964. /**
  75965. * The high limits cache of the runtime animation
  75966. */
  75967. private _highLimitsCache;
  75968. /**
  75969. * Specifies if the runtime animation has been stopped
  75970. */
  75971. private _stopped;
  75972. /**
  75973. * The blending factor of the runtime animation
  75974. */
  75975. private _blendingFactor;
  75976. /**
  75977. * The BabylonJS scene
  75978. */
  75979. private _scene;
  75980. /**
  75981. * The current value of the runtime animation
  75982. */
  75983. private _currentValue;
  75984. /** @hidden */
  75985. _workValue: any;
  75986. /**
  75987. * The active target of the runtime animation
  75988. */
  75989. private _activeTarget;
  75990. /**
  75991. * The target path of the runtime animation
  75992. */
  75993. private _targetPath;
  75994. /**
  75995. * The weight of the runtime animation
  75996. */
  75997. private _weight;
  75998. /**
  75999. * The ratio offset of the runtime animation
  76000. */
  76001. private _ratioOffset;
  76002. /**
  76003. * The previous delay of the runtime animation
  76004. */
  76005. private _previousDelay;
  76006. /**
  76007. * The previous ratio of the runtime animation
  76008. */
  76009. private _previousRatio;
  76010. /**
  76011. * Gets the current frame of the runtime animation
  76012. */
  76013. readonly currentFrame: number;
  76014. /**
  76015. * Gets the weight of the runtime animation
  76016. */
  76017. readonly weight: number;
  76018. /**
  76019. * Gets the current value of the runtime animation
  76020. */
  76021. readonly currentValue: any;
  76022. /**
  76023. * Gets the target path of the runtime animation
  76024. */
  76025. readonly targetPath: string;
  76026. /**
  76027. * Gets the actual target of the runtime animation
  76028. */
  76029. readonly target: any;
  76030. /**
  76031. * Create a new RuntimeAnimation object
  76032. * @param target defines the target of the animation
  76033. * @param animation defines the source animation object
  76034. * @param scene defines the hosting scene
  76035. * @param host defines the initiating Animatable
  76036. */
  76037. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76038. /**
  76039. * Gets the animation from the runtime animation
  76040. */
  76041. readonly animation: Animation;
  76042. /**
  76043. * Resets the runtime animation to the beginning
  76044. * @param restoreOriginal defines whether to restore the target property to the original value
  76045. */
  76046. reset(restoreOriginal?: boolean): void;
  76047. /**
  76048. * Specifies if the runtime animation is stopped
  76049. * @returns Boolean specifying if the runtime animation is stopped
  76050. */
  76051. isStopped(): boolean;
  76052. /**
  76053. * Disposes of the runtime animation
  76054. */
  76055. dispose(): void;
  76056. /**
  76057. * Interpolates the animation from the current frame
  76058. * @param currentFrame The frame to interpolate the animation to
  76059. * @param repeatCount The number of times that the animation should loop
  76060. * @param loopMode The type of looping mode to use
  76061. * @param offsetValue Animation offset value
  76062. * @param highLimitValue The high limit value
  76063. * @returns The interpolated value
  76064. */
  76065. private _interpolate;
  76066. /**
  76067. * Apply the interpolated value to the target
  76068. * @param currentValue defines the value computed by the animation
  76069. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76070. */
  76071. setValue(currentValue: any, weight?: number): void;
  76072. private _setValue;
  76073. /**
  76074. * Gets the loop pmode of the runtime animation
  76075. * @returns Loop Mode
  76076. */
  76077. private _getCorrectLoopMode;
  76078. /**
  76079. * Move the current animation to a given frame
  76080. * @param frame defines the frame to move to
  76081. */
  76082. goToFrame(frame: number): void;
  76083. /**
  76084. * @hidden Internal use only
  76085. */
  76086. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76087. /**
  76088. * Execute the current animation
  76089. * @param delay defines the delay to add to the current frame
  76090. * @param from defines the lower bound of the animation range
  76091. * @param to defines the upper bound of the animation range
  76092. * @param loop defines if the current animation must loop
  76093. * @param speedRatio defines the current speed ratio
  76094. * @param weight defines the weight of the animation (default is -1 so no weight)
  76095. * @param onLoop optional callback called when animation loops
  76096. * @returns a boolean indicating if the animation is running
  76097. */
  76098. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76099. }
  76100. }
  76101. declare module BABYLON {
  76102. /**
  76103. * Class used to store an actual running animation
  76104. */
  76105. export class Animatable {
  76106. /** defines the target object */
  76107. target: any;
  76108. /** defines the starting frame number (default is 0) */
  76109. fromFrame: number;
  76110. /** defines the ending frame number (default is 100) */
  76111. toFrame: number;
  76112. /** defines if the animation must loop (default is false) */
  76113. loopAnimation: boolean;
  76114. /** defines a callback to call when animation ends if it is not looping */
  76115. onAnimationEnd?: (() => void) | null | undefined;
  76116. /** defines a callback to call when animation loops */
  76117. onAnimationLoop?: (() => void) | null | undefined;
  76118. private _localDelayOffset;
  76119. private _pausedDelay;
  76120. private _runtimeAnimations;
  76121. private _paused;
  76122. private _scene;
  76123. private _speedRatio;
  76124. private _weight;
  76125. private _syncRoot;
  76126. /**
  76127. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76128. * This will only apply for non looping animation (default is true)
  76129. */
  76130. disposeOnEnd: boolean;
  76131. /**
  76132. * Gets a boolean indicating if the animation has started
  76133. */
  76134. animationStarted: boolean;
  76135. /**
  76136. * Observer raised when the animation ends
  76137. */
  76138. onAnimationEndObservable: Observable<Animatable>;
  76139. /**
  76140. * Observer raised when the animation loops
  76141. */
  76142. onAnimationLoopObservable: Observable<Animatable>;
  76143. /**
  76144. * Gets the root Animatable used to synchronize and normalize animations
  76145. */
  76146. readonly syncRoot: Animatable;
  76147. /**
  76148. * Gets the current frame of the first RuntimeAnimation
  76149. * Used to synchronize Animatables
  76150. */
  76151. readonly masterFrame: number;
  76152. /**
  76153. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76154. */
  76155. weight: number;
  76156. /**
  76157. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76158. */
  76159. speedRatio: number;
  76160. /**
  76161. * Creates a new Animatable
  76162. * @param scene defines the hosting scene
  76163. * @param target defines the target object
  76164. * @param fromFrame defines the starting frame number (default is 0)
  76165. * @param toFrame defines the ending frame number (default is 100)
  76166. * @param loopAnimation defines if the animation must loop (default is false)
  76167. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76168. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76169. * @param animations defines a group of animation to add to the new Animatable
  76170. * @param onAnimationLoop defines a callback to call when animation loops
  76171. */
  76172. constructor(scene: Scene,
  76173. /** defines the target object */
  76174. target: any,
  76175. /** defines the starting frame number (default is 0) */
  76176. fromFrame?: number,
  76177. /** defines the ending frame number (default is 100) */
  76178. toFrame?: number,
  76179. /** defines if the animation must loop (default is false) */
  76180. loopAnimation?: boolean, speedRatio?: number,
  76181. /** defines a callback to call when animation ends if it is not looping */
  76182. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76183. /** defines a callback to call when animation loops */
  76184. onAnimationLoop?: (() => void) | null | undefined);
  76185. /**
  76186. * Synchronize and normalize current Animatable with a source Animatable
  76187. * This is useful when using animation weights and when animations are not of the same length
  76188. * @param root defines the root Animatable to synchronize with
  76189. * @returns the current Animatable
  76190. */
  76191. syncWith(root: Animatable): Animatable;
  76192. /**
  76193. * Gets the list of runtime animations
  76194. * @returns an array of RuntimeAnimation
  76195. */
  76196. getAnimations(): RuntimeAnimation[];
  76197. /**
  76198. * Adds more animations to the current animatable
  76199. * @param target defines the target of the animations
  76200. * @param animations defines the new animations to add
  76201. */
  76202. appendAnimations(target: any, animations: Animation[]): void;
  76203. /**
  76204. * Gets the source animation for a specific property
  76205. * @param property defines the propertyu to look for
  76206. * @returns null or the source animation for the given property
  76207. */
  76208. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76209. /**
  76210. * Gets the runtime animation for a specific property
  76211. * @param property defines the propertyu to look for
  76212. * @returns null or the runtime animation for the given property
  76213. */
  76214. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76215. /**
  76216. * Resets the animatable to its original state
  76217. */
  76218. reset(): void;
  76219. /**
  76220. * Allows the animatable to blend with current running animations
  76221. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76222. * @param blendingSpeed defines the blending speed to use
  76223. */
  76224. enableBlending(blendingSpeed: number): void;
  76225. /**
  76226. * Disable animation blending
  76227. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76228. */
  76229. disableBlending(): void;
  76230. /**
  76231. * Jump directly to a given frame
  76232. * @param frame defines the frame to jump to
  76233. */
  76234. goToFrame(frame: number): void;
  76235. /**
  76236. * Pause the animation
  76237. */
  76238. pause(): void;
  76239. /**
  76240. * Restart the animation
  76241. */
  76242. restart(): void;
  76243. private _raiseOnAnimationEnd;
  76244. /**
  76245. * Stop and delete the current animation
  76246. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76247. * @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)
  76248. */
  76249. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76250. /**
  76251. * Wait asynchronously for the animation to end
  76252. * @returns a promise which will be fullfilled when the animation ends
  76253. */
  76254. waitAsync(): Promise<Animatable>;
  76255. /** @hidden */
  76256. _animate(delay: number): boolean;
  76257. }
  76258. interface Scene {
  76259. /** @hidden */
  76260. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76261. /** @hidden */
  76262. _processLateAnimationBindingsForMatrices(holder: {
  76263. totalWeight: number;
  76264. animations: RuntimeAnimation[];
  76265. originalValue: Matrix;
  76266. }): any;
  76267. /** @hidden */
  76268. _processLateAnimationBindingsForQuaternions(holder: {
  76269. totalWeight: number;
  76270. animations: RuntimeAnimation[];
  76271. originalValue: Quaternion;
  76272. }, refQuaternion: Quaternion): Quaternion;
  76273. /** @hidden */
  76274. _processLateAnimationBindings(): void;
  76275. /**
  76276. * Will start the animation sequence of a given target
  76277. * @param target defines the target
  76278. * @param from defines from which frame should animation start
  76279. * @param to defines until which frame should animation run.
  76280. * @param weight defines the weight to apply to the animation (1.0 by default)
  76281. * @param loop defines if the animation loops
  76282. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76283. * @param onAnimationEnd defines the function to be executed when the animation ends
  76284. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76285. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76286. * @param onAnimationLoop defines the callback to call when an animation loops
  76287. * @returns the animatable object created for this animation
  76288. */
  76289. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76290. /**
  76291. * Will start the animation sequence of a given target
  76292. * @param target defines the target
  76293. * @param from defines from which frame should animation start
  76294. * @param to defines until which frame should animation run.
  76295. * @param loop defines if the animation loops
  76296. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76297. * @param onAnimationEnd defines the function to be executed when the animation ends
  76298. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76299. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76300. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76301. * @param onAnimationLoop defines the callback to call when an animation loops
  76302. * @returns the animatable object created for this animation
  76303. */
  76304. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76305. /**
  76306. * Will start the animation sequence of a given target and its hierarchy
  76307. * @param target defines the target
  76308. * @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.
  76309. * @param from defines from which frame should animation start
  76310. * @param to defines until which frame should animation run.
  76311. * @param loop defines if the animation loops
  76312. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76313. * @param onAnimationEnd defines the function to be executed when the animation ends
  76314. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76315. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76316. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76317. * @param onAnimationLoop defines the callback to call when an animation loops
  76318. * @returns the list of created animatables
  76319. */
  76320. 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[];
  76321. /**
  76322. * Begin a new animation on a given node
  76323. * @param target defines the target where the animation will take place
  76324. * @param animations defines the list of animations to start
  76325. * @param from defines the initial value
  76326. * @param to defines the final value
  76327. * @param loop defines if you want animation to loop (off by default)
  76328. * @param speedRatio defines the speed ratio to apply to all animations
  76329. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76330. * @param onAnimationLoop defines the callback to call when an animation loops
  76331. * @returns the list of created animatables
  76332. */
  76333. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76334. /**
  76335. * Begin a new animation on a given node and its hierarchy
  76336. * @param target defines the root node where the animation will take place
  76337. * @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.
  76338. * @param animations defines the list of animations to start
  76339. * @param from defines the initial value
  76340. * @param to defines the final value
  76341. * @param loop defines if you want animation to loop (off by default)
  76342. * @param speedRatio defines the speed ratio to apply to all animations
  76343. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76344. * @param onAnimationLoop defines the callback to call when an animation loops
  76345. * @returns the list of animatables created for all nodes
  76346. */
  76347. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76348. /**
  76349. * Gets the animatable associated with a specific target
  76350. * @param target defines the target of the animatable
  76351. * @returns the required animatable if found
  76352. */
  76353. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76354. /**
  76355. * Gets all animatables associated with a given target
  76356. * @param target defines the target to look animatables for
  76357. * @returns an array of Animatables
  76358. */
  76359. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76360. /**
  76361. * Will stop the animation of the given target
  76362. * @param target - the target
  76363. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76364. * @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)
  76365. */
  76366. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76367. /**
  76368. * Stops and removes all animations that have been applied to the scene
  76369. */
  76370. stopAllAnimations(): void;
  76371. }
  76372. interface Bone {
  76373. /**
  76374. * Copy an animation range from another bone
  76375. * @param source defines the source bone
  76376. * @param rangeName defines the range name to copy
  76377. * @param frameOffset defines the frame offset
  76378. * @param rescaleAsRequired defines if rescaling must be applied if required
  76379. * @param skelDimensionsRatio defines the scaling ratio
  76380. * @returns true if operation was successful
  76381. */
  76382. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76383. }
  76384. }
  76385. declare module BABYLON {
  76386. /**
  76387. * Class used to handle skinning animations
  76388. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76389. */
  76390. export class Skeleton implements IAnimatable {
  76391. /** defines the skeleton name */
  76392. name: string;
  76393. /** defines the skeleton Id */
  76394. id: string;
  76395. /**
  76396. * Defines the list of child bones
  76397. */
  76398. bones: Bone[];
  76399. /**
  76400. * Defines an estimate of the dimension of the skeleton at rest
  76401. */
  76402. dimensionsAtRest: Vector3;
  76403. /**
  76404. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76405. */
  76406. needInitialSkinMatrix: boolean;
  76407. /**
  76408. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76409. */
  76410. overrideMesh: Nullable<AbstractMesh>;
  76411. /**
  76412. * Gets the list of animations attached to this skeleton
  76413. */
  76414. animations: Array<Animation>;
  76415. private _scene;
  76416. private _isDirty;
  76417. private _transformMatrices;
  76418. private _transformMatrixTexture;
  76419. private _meshesWithPoseMatrix;
  76420. private _animatables;
  76421. private _identity;
  76422. private _synchronizedWithMesh;
  76423. private _ranges;
  76424. private _lastAbsoluteTransformsUpdateId;
  76425. private _canUseTextureForBones;
  76426. /** @hidden */
  76427. _numBonesWithLinkedTransformNode: number;
  76428. /**
  76429. * Specifies if the skeleton should be serialized
  76430. */
  76431. doNotSerialize: boolean;
  76432. private _useTextureToStoreBoneMatrices;
  76433. /**
  76434. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76435. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76436. */
  76437. useTextureToStoreBoneMatrices: boolean;
  76438. private _animationPropertiesOverride;
  76439. /**
  76440. * Gets or sets the animation properties override
  76441. */
  76442. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76443. /**
  76444. * An observable triggered before computing the skeleton's matrices
  76445. */
  76446. onBeforeComputeObservable: Observable<Skeleton>;
  76447. /**
  76448. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76449. */
  76450. readonly isUsingTextureForMatrices: boolean;
  76451. /**
  76452. * Creates a new skeleton
  76453. * @param name defines the skeleton name
  76454. * @param id defines the skeleton Id
  76455. * @param scene defines the hosting scene
  76456. */
  76457. constructor(
  76458. /** defines the skeleton name */
  76459. name: string,
  76460. /** defines the skeleton Id */
  76461. id: string, scene: Scene);
  76462. /**
  76463. * Gets the current object class name.
  76464. * @return the class name
  76465. */
  76466. getClassName(): string;
  76467. /**
  76468. * Returns an array containing the root bones
  76469. * @returns an array containing the root bones
  76470. */
  76471. getChildren(): Array<Bone>;
  76472. /**
  76473. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76474. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76475. * @returns a Float32Array containing matrices data
  76476. */
  76477. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76478. /**
  76479. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76480. * @returns a raw texture containing the data
  76481. */
  76482. getTransformMatrixTexture(): Nullable<RawTexture>;
  76483. /**
  76484. * Gets the current hosting scene
  76485. * @returns a scene object
  76486. */
  76487. getScene(): Scene;
  76488. /**
  76489. * Gets a string representing the current skeleton data
  76490. * @param fullDetails defines a boolean indicating if we want a verbose version
  76491. * @returns a string representing the current skeleton data
  76492. */
  76493. toString(fullDetails?: boolean): string;
  76494. /**
  76495. * Get bone's index searching by name
  76496. * @param name defines bone's name to search for
  76497. * @return the indice of the bone. Returns -1 if not found
  76498. */
  76499. getBoneIndexByName(name: string): number;
  76500. /**
  76501. * Creater a new animation range
  76502. * @param name defines the name of the range
  76503. * @param from defines the start key
  76504. * @param to defines the end key
  76505. */
  76506. createAnimationRange(name: string, from: number, to: number): void;
  76507. /**
  76508. * Delete a specific animation range
  76509. * @param name defines the name of the range
  76510. * @param deleteFrames defines if frames must be removed as well
  76511. */
  76512. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76513. /**
  76514. * Gets a specific animation range
  76515. * @param name defines the name of the range to look for
  76516. * @returns the requested animation range or null if not found
  76517. */
  76518. getAnimationRange(name: string): Nullable<AnimationRange>;
  76519. /**
  76520. * Gets the list of all animation ranges defined on this skeleton
  76521. * @returns an array
  76522. */
  76523. getAnimationRanges(): Nullable<AnimationRange>[];
  76524. /**
  76525. * Copy animation range from a source skeleton.
  76526. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76527. * @param source defines the source skeleton
  76528. * @param name defines the name of the range to copy
  76529. * @param rescaleAsRequired defines if rescaling must be applied if required
  76530. * @returns true if operation was successful
  76531. */
  76532. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76533. /**
  76534. * Forces the skeleton to go to rest pose
  76535. */
  76536. returnToRest(): void;
  76537. private _getHighestAnimationFrame;
  76538. /**
  76539. * Begin a specific animation range
  76540. * @param name defines the name of the range to start
  76541. * @param loop defines if looping must be turned on (false by default)
  76542. * @param speedRatio defines the speed ratio to apply (1 by default)
  76543. * @param onAnimationEnd defines a callback which will be called when animation will end
  76544. * @returns a new animatable
  76545. */
  76546. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76547. /** @hidden */
  76548. _markAsDirty(): void;
  76549. /** @hidden */
  76550. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76551. /** @hidden */
  76552. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76553. private _computeTransformMatrices;
  76554. /**
  76555. * Build all resources required to render a skeleton
  76556. */
  76557. prepare(): void;
  76558. /**
  76559. * Gets the list of animatables currently running for this skeleton
  76560. * @returns an array of animatables
  76561. */
  76562. getAnimatables(): IAnimatable[];
  76563. /**
  76564. * Clone the current skeleton
  76565. * @param name defines the name of the new skeleton
  76566. * @param id defines the id of the enw skeleton
  76567. * @returns the new skeleton
  76568. */
  76569. clone(name: string, id: string): Skeleton;
  76570. /**
  76571. * Enable animation blending for this skeleton
  76572. * @param blendingSpeed defines the blending speed to apply
  76573. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76574. */
  76575. enableBlending(blendingSpeed?: number): void;
  76576. /**
  76577. * Releases all resources associated with the current skeleton
  76578. */
  76579. dispose(): void;
  76580. /**
  76581. * Serialize the skeleton in a JSON object
  76582. * @returns a JSON object
  76583. */
  76584. serialize(): any;
  76585. /**
  76586. * Creates a new skeleton from serialized data
  76587. * @param parsedSkeleton defines the serialized data
  76588. * @param scene defines the hosting scene
  76589. * @returns a new skeleton
  76590. */
  76591. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76592. /**
  76593. * Compute all node absolute transforms
  76594. * @param forceUpdate defines if computation must be done even if cache is up to date
  76595. */
  76596. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76597. /**
  76598. * Gets the root pose matrix
  76599. * @returns a matrix
  76600. */
  76601. getPoseMatrix(): Nullable<Matrix>;
  76602. /**
  76603. * Sorts bones per internal index
  76604. */
  76605. sortBones(): void;
  76606. private _sortBones;
  76607. }
  76608. }
  76609. declare module BABYLON {
  76610. /**
  76611. * Defines a target to use with MorphTargetManager
  76612. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76613. */
  76614. export class MorphTarget implements IAnimatable {
  76615. /** defines the name of the target */
  76616. name: string;
  76617. /**
  76618. * Gets or sets the list of animations
  76619. */
  76620. animations: Animation[];
  76621. private _scene;
  76622. private _positions;
  76623. private _normals;
  76624. private _tangents;
  76625. private _influence;
  76626. /**
  76627. * Observable raised when the influence changes
  76628. */
  76629. onInfluenceChanged: Observable<boolean>;
  76630. /** @hidden */
  76631. _onDataLayoutChanged: Observable<void>;
  76632. /**
  76633. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76634. */
  76635. influence: number;
  76636. /**
  76637. * Gets or sets the id of the morph Target
  76638. */
  76639. id: string;
  76640. private _animationPropertiesOverride;
  76641. /**
  76642. * Gets or sets the animation properties override
  76643. */
  76644. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76645. /**
  76646. * Creates a new MorphTarget
  76647. * @param name defines the name of the target
  76648. * @param influence defines the influence to use
  76649. * @param scene defines the scene the morphtarget belongs to
  76650. */
  76651. constructor(
  76652. /** defines the name of the target */
  76653. name: string, influence?: number, scene?: Nullable<Scene>);
  76654. /**
  76655. * Gets a boolean defining if the target contains position data
  76656. */
  76657. readonly hasPositions: boolean;
  76658. /**
  76659. * Gets a boolean defining if the target contains normal data
  76660. */
  76661. readonly hasNormals: boolean;
  76662. /**
  76663. * Gets a boolean defining if the target contains tangent data
  76664. */
  76665. readonly hasTangents: boolean;
  76666. /**
  76667. * Affects position data to this target
  76668. * @param data defines the position data to use
  76669. */
  76670. setPositions(data: Nullable<FloatArray>): void;
  76671. /**
  76672. * Gets the position data stored in this target
  76673. * @returns a FloatArray containing the position data (or null if not present)
  76674. */
  76675. getPositions(): Nullable<FloatArray>;
  76676. /**
  76677. * Affects normal data to this target
  76678. * @param data defines the normal data to use
  76679. */
  76680. setNormals(data: Nullable<FloatArray>): void;
  76681. /**
  76682. * Gets the normal data stored in this target
  76683. * @returns a FloatArray containing the normal data (or null if not present)
  76684. */
  76685. getNormals(): Nullable<FloatArray>;
  76686. /**
  76687. * Affects tangent data to this target
  76688. * @param data defines the tangent data to use
  76689. */
  76690. setTangents(data: Nullable<FloatArray>): void;
  76691. /**
  76692. * Gets the tangent data stored in this target
  76693. * @returns a FloatArray containing the tangent data (or null if not present)
  76694. */
  76695. getTangents(): Nullable<FloatArray>;
  76696. /**
  76697. * Serializes the current target into a Serialization object
  76698. * @returns the serialized object
  76699. */
  76700. serialize(): any;
  76701. /**
  76702. * Returns the string "MorphTarget"
  76703. * @returns "MorphTarget"
  76704. */
  76705. getClassName(): string;
  76706. /**
  76707. * Creates a new target from serialized data
  76708. * @param serializationObject defines the serialized data to use
  76709. * @returns a new MorphTarget
  76710. */
  76711. static Parse(serializationObject: any): MorphTarget;
  76712. /**
  76713. * Creates a MorphTarget from mesh data
  76714. * @param mesh defines the source mesh
  76715. * @param name defines the name to use for the new target
  76716. * @param influence defines the influence to attach to the target
  76717. * @returns a new MorphTarget
  76718. */
  76719. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76720. }
  76721. }
  76722. declare module BABYLON {
  76723. /**
  76724. * This class is used to deform meshes using morphing between different targets
  76725. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76726. */
  76727. export class MorphTargetManager {
  76728. private _targets;
  76729. private _targetInfluenceChangedObservers;
  76730. private _targetDataLayoutChangedObservers;
  76731. private _activeTargets;
  76732. private _scene;
  76733. private _influences;
  76734. private _supportsNormals;
  76735. private _supportsTangents;
  76736. private _vertexCount;
  76737. private _uniqueId;
  76738. private _tempInfluences;
  76739. /**
  76740. * Creates a new MorphTargetManager
  76741. * @param scene defines the current scene
  76742. */
  76743. constructor(scene?: Nullable<Scene>);
  76744. /**
  76745. * Gets the unique ID of this manager
  76746. */
  76747. readonly uniqueId: number;
  76748. /**
  76749. * Gets the number of vertices handled by this manager
  76750. */
  76751. readonly vertexCount: number;
  76752. /**
  76753. * Gets a boolean indicating if this manager supports morphing of normals
  76754. */
  76755. readonly supportsNormals: boolean;
  76756. /**
  76757. * Gets a boolean indicating if this manager supports morphing of tangents
  76758. */
  76759. readonly supportsTangents: boolean;
  76760. /**
  76761. * Gets the number of targets stored in this manager
  76762. */
  76763. readonly numTargets: number;
  76764. /**
  76765. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76766. */
  76767. readonly numInfluencers: number;
  76768. /**
  76769. * Gets the list of influences (one per target)
  76770. */
  76771. readonly influences: Float32Array;
  76772. /**
  76773. * Gets the active target at specified index. An active target is a target with an influence > 0
  76774. * @param index defines the index to check
  76775. * @returns the requested target
  76776. */
  76777. getActiveTarget(index: number): MorphTarget;
  76778. /**
  76779. * Gets the target at specified index
  76780. * @param index defines the index to check
  76781. * @returns the requested target
  76782. */
  76783. getTarget(index: number): MorphTarget;
  76784. /**
  76785. * Add a new target to this manager
  76786. * @param target defines the target to add
  76787. */
  76788. addTarget(target: MorphTarget): void;
  76789. /**
  76790. * Removes a target from the manager
  76791. * @param target defines the target to remove
  76792. */
  76793. removeTarget(target: MorphTarget): void;
  76794. /**
  76795. * Serializes the current manager into a Serialization object
  76796. * @returns the serialized object
  76797. */
  76798. serialize(): any;
  76799. private _syncActiveTargets;
  76800. /**
  76801. * Syncrhonize the targets with all the meshes using this morph target manager
  76802. */
  76803. synchronize(): void;
  76804. /**
  76805. * Creates a new MorphTargetManager from serialized data
  76806. * @param serializationObject defines the serialized data
  76807. * @param scene defines the hosting scene
  76808. * @returns the new MorphTargetManager
  76809. */
  76810. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76811. }
  76812. }
  76813. declare module BABYLON {
  76814. /**
  76815. * Mesh representing the gorund
  76816. */
  76817. export class GroundMesh extends Mesh {
  76818. /** If octree should be generated */
  76819. generateOctree: boolean;
  76820. private _heightQuads;
  76821. /** @hidden */
  76822. _subdivisionsX: number;
  76823. /** @hidden */
  76824. _subdivisionsY: number;
  76825. /** @hidden */
  76826. _width: number;
  76827. /** @hidden */
  76828. _height: number;
  76829. /** @hidden */
  76830. _minX: number;
  76831. /** @hidden */
  76832. _maxX: number;
  76833. /** @hidden */
  76834. _minZ: number;
  76835. /** @hidden */
  76836. _maxZ: number;
  76837. constructor(name: string, scene: Scene);
  76838. /**
  76839. * "GroundMesh"
  76840. * @returns "GroundMesh"
  76841. */
  76842. getClassName(): string;
  76843. /**
  76844. * The minimum of x and y subdivisions
  76845. */
  76846. readonly subdivisions: number;
  76847. /**
  76848. * X subdivisions
  76849. */
  76850. readonly subdivisionsX: number;
  76851. /**
  76852. * Y subdivisions
  76853. */
  76854. readonly subdivisionsY: number;
  76855. /**
  76856. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76857. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76858. * @param chunksCount the number of subdivisions for x and y
  76859. * @param octreeBlocksSize (Default: 32)
  76860. */
  76861. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76862. /**
  76863. * Returns a height (y) value in the Worl system :
  76864. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76865. * @param x x coordinate
  76866. * @param z z coordinate
  76867. * @returns the ground y position if (x, z) are outside the ground surface.
  76868. */
  76869. getHeightAtCoordinates(x: number, z: number): number;
  76870. /**
  76871. * Returns a normalized vector (Vector3) orthogonal to the ground
  76872. * at the ground coordinates (x, z) expressed in the World system.
  76873. * @param x x coordinate
  76874. * @param z z coordinate
  76875. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76876. */
  76877. getNormalAtCoordinates(x: number, z: number): Vector3;
  76878. /**
  76879. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76880. * at the ground coordinates (x, z) expressed in the World system.
  76881. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76882. * @param x x coordinate
  76883. * @param z z coordinate
  76884. * @param ref vector to store the result
  76885. * @returns the GroundMesh.
  76886. */
  76887. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76888. /**
  76889. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76890. * if the ground has been updated.
  76891. * This can be used in the render loop.
  76892. * @returns the GroundMesh.
  76893. */
  76894. updateCoordinateHeights(): GroundMesh;
  76895. private _getFacetAt;
  76896. private _initHeightQuads;
  76897. private _computeHeightQuads;
  76898. /**
  76899. * Serializes this ground mesh
  76900. * @param serializationObject object to write serialization to
  76901. */
  76902. serialize(serializationObject: any): void;
  76903. /**
  76904. * Parses a serialized ground mesh
  76905. * @param parsedMesh the serialized mesh
  76906. * @param scene the scene to create the ground mesh in
  76907. * @returns the created ground mesh
  76908. */
  76909. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76910. }
  76911. }
  76912. declare module BABYLON {
  76913. /**
  76914. * Interface for Physics-Joint data
  76915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76916. */
  76917. export interface PhysicsJointData {
  76918. /**
  76919. * The main pivot of the joint
  76920. */
  76921. mainPivot?: Vector3;
  76922. /**
  76923. * The connected pivot of the joint
  76924. */
  76925. connectedPivot?: Vector3;
  76926. /**
  76927. * The main axis of the joint
  76928. */
  76929. mainAxis?: Vector3;
  76930. /**
  76931. * The connected axis of the joint
  76932. */
  76933. connectedAxis?: Vector3;
  76934. /**
  76935. * The collision of the joint
  76936. */
  76937. collision?: boolean;
  76938. /**
  76939. * Native Oimo/Cannon/Energy data
  76940. */
  76941. nativeParams?: any;
  76942. }
  76943. /**
  76944. * This is a holder class for the physics joint created by the physics plugin
  76945. * It holds a set of functions to control the underlying joint
  76946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76947. */
  76948. export class PhysicsJoint {
  76949. /**
  76950. * The type of the physics joint
  76951. */
  76952. type: number;
  76953. /**
  76954. * The data for the physics joint
  76955. */
  76956. jointData: PhysicsJointData;
  76957. private _physicsJoint;
  76958. protected _physicsPlugin: IPhysicsEnginePlugin;
  76959. /**
  76960. * Initializes the physics joint
  76961. * @param type The type of the physics joint
  76962. * @param jointData The data for the physics joint
  76963. */
  76964. constructor(
  76965. /**
  76966. * The type of the physics joint
  76967. */
  76968. type: number,
  76969. /**
  76970. * The data for the physics joint
  76971. */
  76972. jointData: PhysicsJointData);
  76973. /**
  76974. * Gets the physics joint
  76975. */
  76976. /**
  76977. * Sets the physics joint
  76978. */
  76979. physicsJoint: any;
  76980. /**
  76981. * Sets the physics plugin
  76982. */
  76983. physicsPlugin: IPhysicsEnginePlugin;
  76984. /**
  76985. * Execute a function that is physics-plugin specific.
  76986. * @param {Function} func the function that will be executed.
  76987. * It accepts two parameters: the physics world and the physics joint
  76988. */
  76989. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76990. /**
  76991. * Distance-Joint type
  76992. */
  76993. static DistanceJoint: number;
  76994. /**
  76995. * Hinge-Joint type
  76996. */
  76997. static HingeJoint: number;
  76998. /**
  76999. * Ball-and-Socket joint type
  77000. */
  77001. static BallAndSocketJoint: number;
  77002. /**
  77003. * Wheel-Joint type
  77004. */
  77005. static WheelJoint: number;
  77006. /**
  77007. * Slider-Joint type
  77008. */
  77009. static SliderJoint: number;
  77010. /**
  77011. * Prismatic-Joint type
  77012. */
  77013. static PrismaticJoint: number;
  77014. /**
  77015. * Universal-Joint type
  77016. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77017. */
  77018. static UniversalJoint: number;
  77019. /**
  77020. * Hinge-Joint 2 type
  77021. */
  77022. static Hinge2Joint: number;
  77023. /**
  77024. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77025. */
  77026. static PointToPointJoint: number;
  77027. /**
  77028. * Spring-Joint type
  77029. */
  77030. static SpringJoint: number;
  77031. /**
  77032. * Lock-Joint type
  77033. */
  77034. static LockJoint: number;
  77035. }
  77036. /**
  77037. * A class representing a physics distance joint
  77038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77039. */
  77040. export class DistanceJoint extends PhysicsJoint {
  77041. /**
  77042. *
  77043. * @param jointData The data for the Distance-Joint
  77044. */
  77045. constructor(jointData: DistanceJointData);
  77046. /**
  77047. * Update the predefined distance.
  77048. * @param maxDistance The maximum preferred distance
  77049. * @param minDistance The minimum preferred distance
  77050. */
  77051. updateDistance(maxDistance: number, minDistance?: number): void;
  77052. }
  77053. /**
  77054. * Represents a Motor-Enabled Joint
  77055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77056. */
  77057. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77058. /**
  77059. * Initializes the Motor-Enabled Joint
  77060. * @param type The type of the joint
  77061. * @param jointData The physica joint data for the joint
  77062. */
  77063. constructor(type: number, jointData: PhysicsJointData);
  77064. /**
  77065. * Set the motor values.
  77066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77067. * @param force the force to apply
  77068. * @param maxForce max force for this motor.
  77069. */
  77070. setMotor(force?: number, maxForce?: number): void;
  77071. /**
  77072. * Set the motor's limits.
  77073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77074. * @param upperLimit The upper limit of the motor
  77075. * @param lowerLimit The lower limit of the motor
  77076. */
  77077. setLimit(upperLimit: number, lowerLimit?: number): void;
  77078. }
  77079. /**
  77080. * This class represents a single physics Hinge-Joint
  77081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77082. */
  77083. export class HingeJoint extends MotorEnabledJoint {
  77084. /**
  77085. * Initializes the Hinge-Joint
  77086. * @param jointData The joint data for the Hinge-Joint
  77087. */
  77088. constructor(jointData: PhysicsJointData);
  77089. /**
  77090. * Set the motor values.
  77091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77092. * @param {number} force the force to apply
  77093. * @param {number} maxForce max force for this motor.
  77094. */
  77095. setMotor(force?: number, maxForce?: number): void;
  77096. /**
  77097. * Set the motor's limits.
  77098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77099. * @param upperLimit The upper limit of the motor
  77100. * @param lowerLimit The lower limit of the motor
  77101. */
  77102. setLimit(upperLimit: number, lowerLimit?: number): void;
  77103. }
  77104. /**
  77105. * This class represents a dual hinge physics joint (same as wheel joint)
  77106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77107. */
  77108. export class Hinge2Joint extends MotorEnabledJoint {
  77109. /**
  77110. * Initializes the Hinge2-Joint
  77111. * @param jointData The joint data for the Hinge2-Joint
  77112. */
  77113. constructor(jointData: PhysicsJointData);
  77114. /**
  77115. * Set the motor values.
  77116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77117. * @param {number} targetSpeed the speed the motor is to reach
  77118. * @param {number} maxForce max force for this motor.
  77119. * @param {motorIndex} the motor's index, 0 or 1.
  77120. */
  77121. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77122. /**
  77123. * Set the motor limits.
  77124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77125. * @param {number} upperLimit the upper limit
  77126. * @param {number} lowerLimit lower limit
  77127. * @param {motorIndex} the motor's index, 0 or 1.
  77128. */
  77129. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77130. }
  77131. /**
  77132. * Interface for a motor enabled joint
  77133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77134. */
  77135. export interface IMotorEnabledJoint {
  77136. /**
  77137. * Physics joint
  77138. */
  77139. physicsJoint: any;
  77140. /**
  77141. * Sets the motor of the motor-enabled joint
  77142. * @param force The force of the motor
  77143. * @param maxForce The maximum force of the motor
  77144. * @param motorIndex The index of the motor
  77145. */
  77146. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77147. /**
  77148. * Sets the limit of the motor
  77149. * @param upperLimit The upper limit of the motor
  77150. * @param lowerLimit The lower limit of the motor
  77151. * @param motorIndex The index of the motor
  77152. */
  77153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77154. }
  77155. /**
  77156. * Joint data for a Distance-Joint
  77157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77158. */
  77159. export interface DistanceJointData extends PhysicsJointData {
  77160. /**
  77161. * Max distance the 2 joint objects can be apart
  77162. */
  77163. maxDistance: number;
  77164. }
  77165. /**
  77166. * Joint data from a spring joint
  77167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77168. */
  77169. export interface SpringJointData extends PhysicsJointData {
  77170. /**
  77171. * Length of the spring
  77172. */
  77173. length: number;
  77174. /**
  77175. * Stiffness of the spring
  77176. */
  77177. stiffness: number;
  77178. /**
  77179. * Damping of the spring
  77180. */
  77181. damping: number;
  77182. /** this callback will be called when applying the force to the impostors. */
  77183. forceApplicationCallback: () => void;
  77184. }
  77185. }
  77186. declare module BABYLON {
  77187. /**
  77188. * Interface used to describe a physics joint
  77189. */
  77190. export interface PhysicsImpostorJoint {
  77191. /** Defines the main impostor to which the joint is linked */
  77192. mainImpostor: PhysicsImpostor;
  77193. /** Defines the impostor that is connected to the main impostor using this joint */
  77194. connectedImpostor: PhysicsImpostor;
  77195. /** Defines the joint itself */
  77196. joint: PhysicsJoint;
  77197. }
  77198. /** @hidden */
  77199. export interface IPhysicsEnginePlugin {
  77200. world: any;
  77201. name: string;
  77202. setGravity(gravity: Vector3): void;
  77203. setTimeStep(timeStep: number): void;
  77204. getTimeStep(): number;
  77205. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77206. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77207. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77208. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77209. removePhysicsBody(impostor: PhysicsImpostor): void;
  77210. generateJoint(joint: PhysicsImpostorJoint): void;
  77211. removeJoint(joint: PhysicsImpostorJoint): void;
  77212. isSupported(): boolean;
  77213. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77214. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77215. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77216. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77217. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77218. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77219. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77220. getBodyMass(impostor: PhysicsImpostor): number;
  77221. getBodyFriction(impostor: PhysicsImpostor): number;
  77222. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77223. getBodyRestitution(impostor: PhysicsImpostor): number;
  77224. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77225. sleepBody(impostor: PhysicsImpostor): void;
  77226. wakeUpBody(impostor: PhysicsImpostor): void;
  77227. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77228. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77229. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77230. getRadius(impostor: PhysicsImpostor): number;
  77231. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77232. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77233. dispose(): void;
  77234. }
  77235. /**
  77236. * Interface used to define a physics engine
  77237. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77238. */
  77239. export interface IPhysicsEngine {
  77240. /**
  77241. * Gets the gravity vector used by the simulation
  77242. */
  77243. gravity: Vector3;
  77244. /**
  77245. * Sets the gravity vector used by the simulation
  77246. * @param gravity defines the gravity vector to use
  77247. */
  77248. setGravity(gravity: Vector3): void;
  77249. /**
  77250. * Set the time step of the physics engine.
  77251. * Default is 1/60.
  77252. * To slow it down, enter 1/600 for example.
  77253. * To speed it up, 1/30
  77254. * @param newTimeStep the new timestep to apply to this world.
  77255. */
  77256. setTimeStep(newTimeStep: number): void;
  77257. /**
  77258. * Get the time step of the physics engine.
  77259. * @returns the current time step
  77260. */
  77261. getTimeStep(): number;
  77262. /**
  77263. * Release all resources
  77264. */
  77265. dispose(): void;
  77266. /**
  77267. * Gets the name of the current physics plugin
  77268. * @returns the name of the plugin
  77269. */
  77270. getPhysicsPluginName(): string;
  77271. /**
  77272. * Adding a new impostor for the impostor tracking.
  77273. * This will be done by the impostor itself.
  77274. * @param impostor the impostor to add
  77275. */
  77276. addImpostor(impostor: PhysicsImpostor): void;
  77277. /**
  77278. * Remove an impostor from the engine.
  77279. * This impostor and its mesh will not longer be updated by the physics engine.
  77280. * @param impostor the impostor to remove
  77281. */
  77282. removeImpostor(impostor: PhysicsImpostor): void;
  77283. /**
  77284. * Add a joint to the physics engine
  77285. * @param mainImpostor defines the main impostor to which the joint is added.
  77286. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77287. * @param joint defines the joint that will connect both impostors.
  77288. */
  77289. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77290. /**
  77291. * Removes a joint from the simulation
  77292. * @param mainImpostor defines the impostor used with the joint
  77293. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77294. * @param joint defines the joint to remove
  77295. */
  77296. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77297. /**
  77298. * Gets the current plugin used to run the simulation
  77299. * @returns current plugin
  77300. */
  77301. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77302. /**
  77303. * Gets the list of physic impostors
  77304. * @returns an array of PhysicsImpostor
  77305. */
  77306. getImpostors(): Array<PhysicsImpostor>;
  77307. /**
  77308. * Gets the impostor for a physics enabled object
  77309. * @param object defines the object impersonated by the impostor
  77310. * @returns the PhysicsImpostor or null if not found
  77311. */
  77312. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77313. /**
  77314. * Gets the impostor for a physics body object
  77315. * @param body defines physics body used by the impostor
  77316. * @returns the PhysicsImpostor or null if not found
  77317. */
  77318. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77319. /**
  77320. * Called by the scene. No need to call it.
  77321. * @param delta defines the timespam between frames
  77322. */
  77323. _step(delta: number): void;
  77324. }
  77325. }
  77326. declare module BABYLON {
  77327. /**
  77328. * The interface for the physics imposter parameters
  77329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77330. */
  77331. export interface PhysicsImpostorParameters {
  77332. /**
  77333. * The mass of the physics imposter
  77334. */
  77335. mass: number;
  77336. /**
  77337. * The friction of the physics imposter
  77338. */
  77339. friction?: number;
  77340. /**
  77341. * The coefficient of restitution of the physics imposter
  77342. */
  77343. restitution?: number;
  77344. /**
  77345. * The native options of the physics imposter
  77346. */
  77347. nativeOptions?: any;
  77348. /**
  77349. * Specifies if the parent should be ignored
  77350. */
  77351. ignoreParent?: boolean;
  77352. /**
  77353. * Specifies if bi-directional transformations should be disabled
  77354. */
  77355. disableBidirectionalTransformation?: boolean;
  77356. }
  77357. /**
  77358. * Interface for a physics-enabled object
  77359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77360. */
  77361. export interface IPhysicsEnabledObject {
  77362. /**
  77363. * The position of the physics-enabled object
  77364. */
  77365. position: Vector3;
  77366. /**
  77367. * The rotation of the physics-enabled object
  77368. */
  77369. rotationQuaternion: Nullable<Quaternion>;
  77370. /**
  77371. * The scale of the physics-enabled object
  77372. */
  77373. scaling: Vector3;
  77374. /**
  77375. * The rotation of the physics-enabled object
  77376. */
  77377. rotation?: Vector3;
  77378. /**
  77379. * The parent of the physics-enabled object
  77380. */
  77381. parent?: any;
  77382. /**
  77383. * The bounding info of the physics-enabled object
  77384. * @returns The bounding info of the physics-enabled object
  77385. */
  77386. getBoundingInfo(): BoundingInfo;
  77387. /**
  77388. * Computes the world matrix
  77389. * @param force Specifies if the world matrix should be computed by force
  77390. * @returns A world matrix
  77391. */
  77392. computeWorldMatrix(force: boolean): Matrix;
  77393. /**
  77394. * Gets the world matrix
  77395. * @returns A world matrix
  77396. */
  77397. getWorldMatrix?(): Matrix;
  77398. /**
  77399. * Gets the child meshes
  77400. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77401. * @returns An array of abstract meshes
  77402. */
  77403. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77404. /**
  77405. * Gets the vertex data
  77406. * @param kind The type of vertex data
  77407. * @returns A nullable array of numbers, or a float32 array
  77408. */
  77409. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77410. /**
  77411. * Gets the indices from the mesh
  77412. * @returns A nullable array of index arrays
  77413. */
  77414. getIndices?(): Nullable<IndicesArray>;
  77415. /**
  77416. * Gets the scene from the mesh
  77417. * @returns the indices array or null
  77418. */
  77419. getScene?(): Scene;
  77420. /**
  77421. * Gets the absolute position from the mesh
  77422. * @returns the absolute position
  77423. */
  77424. getAbsolutePosition(): Vector3;
  77425. /**
  77426. * Gets the absolute pivot point from the mesh
  77427. * @returns the absolute pivot point
  77428. */
  77429. getAbsolutePivotPoint(): Vector3;
  77430. /**
  77431. * Rotates the mesh
  77432. * @param axis The axis of rotation
  77433. * @param amount The amount of rotation
  77434. * @param space The space of the rotation
  77435. * @returns The rotation transform node
  77436. */
  77437. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77438. /**
  77439. * Translates the mesh
  77440. * @param axis The axis of translation
  77441. * @param distance The distance of translation
  77442. * @param space The space of the translation
  77443. * @returns The transform node
  77444. */
  77445. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77446. /**
  77447. * Sets the absolute position of the mesh
  77448. * @param absolutePosition The absolute position of the mesh
  77449. * @returns The transform node
  77450. */
  77451. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77452. /**
  77453. * Gets the class name of the mesh
  77454. * @returns The class name
  77455. */
  77456. getClassName(): string;
  77457. }
  77458. /**
  77459. * Represents a physics imposter
  77460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77461. */
  77462. export class PhysicsImpostor {
  77463. /**
  77464. * The physics-enabled object used as the physics imposter
  77465. */
  77466. object: IPhysicsEnabledObject;
  77467. /**
  77468. * The type of the physics imposter
  77469. */
  77470. type: number;
  77471. private _options;
  77472. private _scene?;
  77473. /**
  77474. * The default object size of the imposter
  77475. */
  77476. static DEFAULT_OBJECT_SIZE: Vector3;
  77477. /**
  77478. * The identity quaternion of the imposter
  77479. */
  77480. static IDENTITY_QUATERNION: Quaternion;
  77481. /** @hidden */
  77482. _pluginData: any;
  77483. private _physicsEngine;
  77484. private _physicsBody;
  77485. private _bodyUpdateRequired;
  77486. private _onBeforePhysicsStepCallbacks;
  77487. private _onAfterPhysicsStepCallbacks;
  77488. /** @hidden */
  77489. _onPhysicsCollideCallbacks: Array<{
  77490. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77491. otherImpostors: Array<PhysicsImpostor>;
  77492. }>;
  77493. private _deltaPosition;
  77494. private _deltaRotation;
  77495. private _deltaRotationConjugated;
  77496. private _parent;
  77497. private _isDisposed;
  77498. private static _tmpVecs;
  77499. private static _tmpQuat;
  77500. /**
  77501. * Specifies if the physics imposter is disposed
  77502. */
  77503. readonly isDisposed: boolean;
  77504. /**
  77505. * Gets the mass of the physics imposter
  77506. */
  77507. mass: number;
  77508. /**
  77509. * Gets the coefficient of friction
  77510. */
  77511. /**
  77512. * Sets the coefficient of friction
  77513. */
  77514. friction: number;
  77515. /**
  77516. * Gets the coefficient of restitution
  77517. */
  77518. /**
  77519. * Sets the coefficient of restitution
  77520. */
  77521. restitution: number;
  77522. /**
  77523. * The unique id of the physics imposter
  77524. * set by the physics engine when adding this impostor to the array
  77525. */
  77526. uniqueId: number;
  77527. private _joints;
  77528. /**
  77529. * Initializes the physics imposter
  77530. * @param object The physics-enabled object used as the physics imposter
  77531. * @param type The type of the physics imposter
  77532. * @param _options The options for the physics imposter
  77533. * @param _scene The Babylon scene
  77534. */
  77535. constructor(
  77536. /**
  77537. * The physics-enabled object used as the physics imposter
  77538. */
  77539. object: IPhysicsEnabledObject,
  77540. /**
  77541. * The type of the physics imposter
  77542. */
  77543. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77544. /**
  77545. * This function will completly initialize this impostor.
  77546. * It will create a new body - but only if this mesh has no parent.
  77547. * If it has, this impostor will not be used other than to define the impostor
  77548. * of the child mesh.
  77549. * @hidden
  77550. */
  77551. _init(): void;
  77552. private _getPhysicsParent;
  77553. /**
  77554. * Should a new body be generated.
  77555. * @returns boolean specifying if body initialization is required
  77556. */
  77557. isBodyInitRequired(): boolean;
  77558. /**
  77559. * Sets the updated scaling
  77560. * @param updated Specifies if the scaling is updated
  77561. */
  77562. setScalingUpdated(): void;
  77563. /**
  77564. * Force a regeneration of this or the parent's impostor's body.
  77565. * Use under cautious - This will remove all joints already implemented.
  77566. */
  77567. forceUpdate(): void;
  77568. /**
  77569. * Gets the body that holds this impostor. Either its own, or its parent.
  77570. */
  77571. /**
  77572. * Set the physics body. Used mainly by the physics engine/plugin
  77573. */
  77574. physicsBody: any;
  77575. /**
  77576. * Get the parent of the physics imposter
  77577. * @returns Physics imposter or null
  77578. */
  77579. /**
  77580. * Sets the parent of the physics imposter
  77581. */
  77582. parent: Nullable<PhysicsImpostor>;
  77583. /**
  77584. * Resets the update flags
  77585. */
  77586. resetUpdateFlags(): void;
  77587. /**
  77588. * Gets the object extend size
  77589. * @returns the object extend size
  77590. */
  77591. getObjectExtendSize(): Vector3;
  77592. /**
  77593. * Gets the object center
  77594. * @returns The object center
  77595. */
  77596. getObjectCenter(): Vector3;
  77597. /**
  77598. * Get a specific parametes from the options parameter
  77599. * @param paramName The object parameter name
  77600. * @returns The object parameter
  77601. */
  77602. getParam(paramName: string): any;
  77603. /**
  77604. * Sets a specific parameter in the options given to the physics plugin
  77605. * @param paramName The parameter name
  77606. * @param value The value of the parameter
  77607. */
  77608. setParam(paramName: string, value: number): void;
  77609. /**
  77610. * Specifically change the body's mass option. Won't recreate the physics body object
  77611. * @param mass The mass of the physics imposter
  77612. */
  77613. setMass(mass: number): void;
  77614. /**
  77615. * Gets the linear velocity
  77616. * @returns linear velocity or null
  77617. */
  77618. getLinearVelocity(): Nullable<Vector3>;
  77619. /**
  77620. * Sets the linear velocity
  77621. * @param velocity linear velocity or null
  77622. */
  77623. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77624. /**
  77625. * Gets the angular velocity
  77626. * @returns angular velocity or null
  77627. */
  77628. getAngularVelocity(): Nullable<Vector3>;
  77629. /**
  77630. * Sets the angular velocity
  77631. * @param velocity The velocity or null
  77632. */
  77633. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77634. /**
  77635. * Execute a function with the physics plugin native code
  77636. * Provide a function the will have two variables - the world object and the physics body object
  77637. * @param func The function to execute with the physics plugin native code
  77638. */
  77639. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77640. /**
  77641. * Register a function that will be executed before the physics world is stepping forward
  77642. * @param func The function to execute before the physics world is stepped forward
  77643. */
  77644. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77645. /**
  77646. * Unregister a function that will be executed before the physics world is stepping forward
  77647. * @param func The function to execute before the physics world is stepped forward
  77648. */
  77649. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77650. /**
  77651. * Register a function that will be executed after the physics step
  77652. * @param func The function to execute after physics step
  77653. */
  77654. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77655. /**
  77656. * Unregisters a function that will be executed after the physics step
  77657. * @param func The function to execute after physics step
  77658. */
  77659. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77660. /**
  77661. * register a function that will be executed when this impostor collides against a different body
  77662. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77663. * @param func Callback that is executed on collision
  77664. */
  77665. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77666. /**
  77667. * Unregisters the physics imposter on contact
  77668. * @param collideAgainst The physics object to collide against
  77669. * @param func Callback to execute on collision
  77670. */
  77671. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77672. private _tmpQuat;
  77673. private _tmpQuat2;
  77674. /**
  77675. * Get the parent rotation
  77676. * @returns The parent rotation
  77677. */
  77678. getParentsRotation(): Quaternion;
  77679. /**
  77680. * this function is executed by the physics engine.
  77681. */
  77682. beforeStep: () => void;
  77683. /**
  77684. * this function is executed by the physics engine
  77685. */
  77686. afterStep: () => void;
  77687. /**
  77688. * Legacy collision detection event support
  77689. */
  77690. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77691. /**
  77692. * event and body object due to cannon's event-based architecture.
  77693. */
  77694. onCollide: (e: {
  77695. body: any;
  77696. }) => void;
  77697. /**
  77698. * Apply a force
  77699. * @param force The force to apply
  77700. * @param contactPoint The contact point for the force
  77701. * @returns The physics imposter
  77702. */
  77703. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77704. /**
  77705. * Apply an impulse
  77706. * @param force The impulse force
  77707. * @param contactPoint The contact point for the impulse force
  77708. * @returns The physics imposter
  77709. */
  77710. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77711. /**
  77712. * A help function to create a joint
  77713. * @param otherImpostor A physics imposter used to create a joint
  77714. * @param jointType The type of joint
  77715. * @param jointData The data for the joint
  77716. * @returns The physics imposter
  77717. */
  77718. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77719. /**
  77720. * Add a joint to this impostor with a different impostor
  77721. * @param otherImpostor A physics imposter used to add a joint
  77722. * @param joint The joint to add
  77723. * @returns The physics imposter
  77724. */
  77725. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77726. /**
  77727. * Will keep this body still, in a sleep mode.
  77728. * @returns the physics imposter
  77729. */
  77730. sleep(): PhysicsImpostor;
  77731. /**
  77732. * Wake the body up.
  77733. * @returns The physics imposter
  77734. */
  77735. wakeUp(): PhysicsImpostor;
  77736. /**
  77737. * Clones the physics imposter
  77738. * @param newObject The physics imposter clones to this physics-enabled object
  77739. * @returns A nullable physics imposter
  77740. */
  77741. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77742. /**
  77743. * Disposes the physics imposter
  77744. */
  77745. dispose(): void;
  77746. /**
  77747. * Sets the delta position
  77748. * @param position The delta position amount
  77749. */
  77750. setDeltaPosition(position: Vector3): void;
  77751. /**
  77752. * Sets the delta rotation
  77753. * @param rotation The delta rotation amount
  77754. */
  77755. setDeltaRotation(rotation: Quaternion): void;
  77756. /**
  77757. * Gets the box size of the physics imposter and stores the result in the input parameter
  77758. * @param result Stores the box size
  77759. * @returns The physics imposter
  77760. */
  77761. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77762. /**
  77763. * Gets the radius of the physics imposter
  77764. * @returns Radius of the physics imposter
  77765. */
  77766. getRadius(): number;
  77767. /**
  77768. * Sync a bone with this impostor
  77769. * @param bone The bone to sync to the impostor.
  77770. * @param boneMesh The mesh that the bone is influencing.
  77771. * @param jointPivot The pivot of the joint / bone in local space.
  77772. * @param distToJoint Optional distance from the impostor to the joint.
  77773. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77774. */
  77775. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77776. /**
  77777. * Sync impostor to a bone
  77778. * @param bone The bone that the impostor will be synced to.
  77779. * @param boneMesh The mesh that the bone is influencing.
  77780. * @param jointPivot The pivot of the joint / bone in local space.
  77781. * @param distToJoint Optional distance from the impostor to the joint.
  77782. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77783. * @param boneAxis Optional vector3 axis the bone is aligned with
  77784. */
  77785. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77786. /**
  77787. * No-Imposter type
  77788. */
  77789. static NoImpostor: number;
  77790. /**
  77791. * Sphere-Imposter type
  77792. */
  77793. static SphereImpostor: number;
  77794. /**
  77795. * Box-Imposter type
  77796. */
  77797. static BoxImpostor: number;
  77798. /**
  77799. * Plane-Imposter type
  77800. */
  77801. static PlaneImpostor: number;
  77802. /**
  77803. * Mesh-imposter type
  77804. */
  77805. static MeshImpostor: number;
  77806. /**
  77807. * Cylinder-Imposter type
  77808. */
  77809. static CylinderImpostor: number;
  77810. /**
  77811. * Particle-Imposter type
  77812. */
  77813. static ParticleImpostor: number;
  77814. /**
  77815. * Heightmap-Imposter type
  77816. */
  77817. static HeightmapImpostor: number;
  77818. }
  77819. }
  77820. declare module BABYLON {
  77821. /**
  77822. * Class used to represent a specific level of detail of a mesh
  77823. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77824. */
  77825. export class MeshLODLevel {
  77826. /** Defines the distance where this level should star being displayed */
  77827. distance: number;
  77828. /** Defines the mesh to use to render this level */
  77829. mesh: Nullable<Mesh>;
  77830. /**
  77831. * Creates a new LOD level
  77832. * @param distance defines the distance where this level should star being displayed
  77833. * @param mesh defines the mesh to use to render this level
  77834. */
  77835. constructor(
  77836. /** Defines the distance where this level should star being displayed */
  77837. distance: number,
  77838. /** Defines the mesh to use to render this level */
  77839. mesh: Nullable<Mesh>);
  77840. }
  77841. /**
  77842. * @hidden
  77843. **/
  77844. export class _CreationDataStorage {
  77845. closePath?: boolean;
  77846. closeArray?: boolean;
  77847. idx: number[];
  77848. dashSize: number;
  77849. gapSize: number;
  77850. path3D: Path3D;
  77851. pathArray: Vector3[][];
  77852. arc: number;
  77853. radius: number;
  77854. cap: number;
  77855. tessellation: number;
  77856. }
  77857. /**
  77858. * @hidden
  77859. **/
  77860. class _InstanceDataStorage {
  77861. visibleInstances: any;
  77862. renderIdForInstances: number[];
  77863. batchCache: _InstancesBatch;
  77864. instancesBufferSize: number;
  77865. instancesBuffer: Nullable<Buffer>;
  77866. instancesData: Float32Array;
  77867. overridenInstanceCount: number;
  77868. }
  77869. /**
  77870. * @hidden
  77871. **/
  77872. export class _InstancesBatch {
  77873. mustReturn: boolean;
  77874. visibleInstances: Nullable<InstancedMesh[]>[];
  77875. renderSelf: boolean[];
  77876. }
  77877. /**
  77878. * Class used to represent renderable models
  77879. */
  77880. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77881. /**
  77882. * Mesh side orientation : usually the external or front surface
  77883. */
  77884. static readonly FRONTSIDE: number;
  77885. /**
  77886. * Mesh side orientation : usually the internal or back surface
  77887. */
  77888. static readonly BACKSIDE: number;
  77889. /**
  77890. * Mesh side orientation : both internal and external or front and back surfaces
  77891. */
  77892. static readonly DOUBLESIDE: number;
  77893. /**
  77894. * Mesh side orientation : by default, `FRONTSIDE`
  77895. */
  77896. static readonly DEFAULTSIDE: number;
  77897. /**
  77898. * Mesh cap setting : no cap
  77899. */
  77900. static readonly NO_CAP: number;
  77901. /**
  77902. * Mesh cap setting : one cap at the beginning of the mesh
  77903. */
  77904. static readonly CAP_START: number;
  77905. /**
  77906. * Mesh cap setting : one cap at the end of the mesh
  77907. */
  77908. static readonly CAP_END: number;
  77909. /**
  77910. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77911. */
  77912. static readonly CAP_ALL: number;
  77913. /**
  77914. * Gets the default side orientation.
  77915. * @param orientation the orientation to value to attempt to get
  77916. * @returns the default orientation
  77917. * @hidden
  77918. */
  77919. static _GetDefaultSideOrientation(orientation?: number): number;
  77920. private _onBeforeRenderObservable;
  77921. private _onBeforeBindObservable;
  77922. private _onAfterRenderObservable;
  77923. private _onBeforeDrawObservable;
  77924. /**
  77925. * An event triggered before rendering the mesh
  77926. */
  77927. readonly onBeforeRenderObservable: Observable<Mesh>;
  77928. /**
  77929. * An event triggered before binding the mesh
  77930. */
  77931. readonly onBeforeBindObservable: Observable<Mesh>;
  77932. /**
  77933. * An event triggered after rendering the mesh
  77934. */
  77935. readonly onAfterRenderObservable: Observable<Mesh>;
  77936. /**
  77937. * An event triggered before drawing the mesh
  77938. */
  77939. readonly onBeforeDrawObservable: Observable<Mesh>;
  77940. private _onBeforeDrawObserver;
  77941. /**
  77942. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77943. */
  77944. onBeforeDraw: () => void;
  77945. /**
  77946. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77947. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77948. */
  77949. delayLoadState: number;
  77950. /**
  77951. * Gets the list of instances created from this mesh
  77952. * it is not supposed to be modified manually.
  77953. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77954. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77955. */
  77956. instances: InstancedMesh[];
  77957. /**
  77958. * Gets the file containing delay loading data for this mesh
  77959. */
  77960. delayLoadingFile: string;
  77961. /** @hidden */
  77962. _binaryInfo: any;
  77963. private _LODLevels;
  77964. /**
  77965. * User defined function used to change how LOD level selection is done
  77966. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77967. */
  77968. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77969. private _morphTargetManager;
  77970. /**
  77971. * Gets or sets the morph target manager
  77972. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77973. */
  77974. morphTargetManager: Nullable<MorphTargetManager>;
  77975. /** @hidden */
  77976. _creationDataStorage: Nullable<_CreationDataStorage>;
  77977. /** @hidden */
  77978. _geometry: Nullable<Geometry>;
  77979. /** @hidden */
  77980. _delayInfo: Array<string>;
  77981. /** @hidden */
  77982. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77983. /** @hidden */
  77984. _instanceDataStorage: _InstanceDataStorage;
  77985. private _effectiveMaterial;
  77986. /** @hidden */
  77987. _shouldGenerateFlatShading: boolean;
  77988. private _preActivateId;
  77989. /** @hidden */
  77990. _originalBuilderSideOrientation: number;
  77991. /**
  77992. * Use this property to change the original side orientation defined at construction time
  77993. */
  77994. overrideMaterialSideOrientation: Nullable<number>;
  77995. private _areNormalsFrozen;
  77996. private _sourcePositions;
  77997. private _sourceNormals;
  77998. private _source;
  77999. private meshMap;
  78000. /**
  78001. * Gets the source mesh (the one used to clone this one from)
  78002. */
  78003. readonly source: Nullable<Mesh>;
  78004. /**
  78005. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78006. */
  78007. isUnIndexed: boolean;
  78008. /**
  78009. * @constructor
  78010. * @param name The value used by scene.getMeshByName() to do a lookup.
  78011. * @param scene The scene to add this mesh to.
  78012. * @param parent The parent of this mesh, if it has one
  78013. * @param source An optional Mesh from which geometry is shared, cloned.
  78014. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78015. * When false, achieved by calling a clone(), also passing False.
  78016. * This will make creation of children, recursive.
  78017. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78018. */
  78019. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78020. /**
  78021. * Gets the class name
  78022. * @returns the string "Mesh".
  78023. */
  78024. getClassName(): string;
  78025. /** @hidden */
  78026. readonly _isMesh: boolean;
  78027. /**
  78028. * Returns a description of this mesh
  78029. * @param fullDetails define if full details about this mesh must be used
  78030. * @returns a descriptive string representing this mesh
  78031. */
  78032. toString(fullDetails?: boolean): string;
  78033. /** @hidden */
  78034. _unBindEffect(): void;
  78035. /**
  78036. * Gets a boolean indicating if this mesh has LOD
  78037. */
  78038. readonly hasLODLevels: boolean;
  78039. /**
  78040. * Gets the list of MeshLODLevel associated with the current mesh
  78041. * @returns an array of MeshLODLevel
  78042. */
  78043. getLODLevels(): MeshLODLevel[];
  78044. private _sortLODLevels;
  78045. /**
  78046. * Add a mesh as LOD level triggered at the given distance.
  78047. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78048. * @param distance The distance from the center of the object to show this level
  78049. * @param mesh The mesh to be added as LOD level (can be null)
  78050. * @return This mesh (for chaining)
  78051. */
  78052. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78053. /**
  78054. * Returns the LOD level mesh at the passed distance or null if not found.
  78055. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78056. * @param distance The distance from the center of the object to show this level
  78057. * @returns a Mesh or `null`
  78058. */
  78059. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78060. /**
  78061. * Remove a mesh from the LOD array
  78062. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78063. * @param mesh defines the mesh to be removed
  78064. * @return This mesh (for chaining)
  78065. */
  78066. removeLODLevel(mesh: Mesh): Mesh;
  78067. /**
  78068. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78069. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78070. * @param camera defines the camera to use to compute distance
  78071. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78072. * @return This mesh (for chaining)
  78073. */
  78074. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78075. /**
  78076. * Gets the mesh internal Geometry object
  78077. */
  78078. readonly geometry: Nullable<Geometry>;
  78079. /**
  78080. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78081. * @returns the total number of vertices
  78082. */
  78083. getTotalVertices(): number;
  78084. /**
  78085. * Returns the content of an associated vertex buffer
  78086. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78087. * - VertexBuffer.PositionKind
  78088. * - VertexBuffer.UVKind
  78089. * - VertexBuffer.UV2Kind
  78090. * - VertexBuffer.UV3Kind
  78091. * - VertexBuffer.UV4Kind
  78092. * - VertexBuffer.UV5Kind
  78093. * - VertexBuffer.UV6Kind
  78094. * - VertexBuffer.ColorKind
  78095. * - VertexBuffer.MatricesIndicesKind
  78096. * - VertexBuffer.MatricesIndicesExtraKind
  78097. * - VertexBuffer.MatricesWeightsKind
  78098. * - VertexBuffer.MatricesWeightsExtraKind
  78099. * @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
  78100. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  78101. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  78102. */
  78103. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78104. /**
  78105. * Returns the mesh VertexBuffer object from the requested `kind`
  78106. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78107. * - VertexBuffer.PositionKind
  78108. * - VertexBuffer.UVKind
  78109. * - VertexBuffer.UV2Kind
  78110. * - VertexBuffer.UV3Kind
  78111. * - VertexBuffer.UV4Kind
  78112. * - VertexBuffer.UV5Kind
  78113. * - VertexBuffer.UV6Kind
  78114. * - VertexBuffer.ColorKind
  78115. * - VertexBuffer.MatricesIndicesKind
  78116. * - VertexBuffer.MatricesIndicesExtraKind
  78117. * - VertexBuffer.MatricesWeightsKind
  78118. * - VertexBuffer.MatricesWeightsExtraKind
  78119. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78120. */
  78121. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78122. /**
  78123. * Tests if a specific vertex buffer is associated with this mesh
  78124. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78125. * - VertexBuffer.PositionKind
  78126. * - VertexBuffer.UVKind
  78127. * - VertexBuffer.UV2Kind
  78128. * - VertexBuffer.UV3Kind
  78129. * - VertexBuffer.UV4Kind
  78130. * - VertexBuffer.UV5Kind
  78131. * - VertexBuffer.UV6Kind
  78132. * - VertexBuffer.ColorKind
  78133. * - VertexBuffer.MatricesIndicesKind
  78134. * - VertexBuffer.MatricesIndicesExtraKind
  78135. * - VertexBuffer.MatricesWeightsKind
  78136. * - VertexBuffer.MatricesWeightsExtraKind
  78137. * @returns a boolean
  78138. */
  78139. isVerticesDataPresent(kind: string): boolean;
  78140. /**
  78141. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78142. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78143. * - VertexBuffer.PositionKind
  78144. * - VertexBuffer.UVKind
  78145. * - VertexBuffer.UV2Kind
  78146. * - VertexBuffer.UV3Kind
  78147. * - VertexBuffer.UV4Kind
  78148. * - VertexBuffer.UV5Kind
  78149. * - VertexBuffer.UV6Kind
  78150. * - VertexBuffer.ColorKind
  78151. * - VertexBuffer.MatricesIndicesKind
  78152. * - VertexBuffer.MatricesIndicesExtraKind
  78153. * - VertexBuffer.MatricesWeightsKind
  78154. * - VertexBuffer.MatricesWeightsExtraKind
  78155. * @returns a boolean
  78156. */
  78157. isVertexBufferUpdatable(kind: string): boolean;
  78158. /**
  78159. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78160. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78161. * - VertexBuffer.PositionKind
  78162. * - VertexBuffer.UVKind
  78163. * - VertexBuffer.UV2Kind
  78164. * - VertexBuffer.UV3Kind
  78165. * - VertexBuffer.UV4Kind
  78166. * - VertexBuffer.UV5Kind
  78167. * - VertexBuffer.UV6Kind
  78168. * - VertexBuffer.ColorKind
  78169. * - VertexBuffer.MatricesIndicesKind
  78170. * - VertexBuffer.MatricesIndicesExtraKind
  78171. * - VertexBuffer.MatricesWeightsKind
  78172. * - VertexBuffer.MatricesWeightsExtraKind
  78173. * @returns an array of strings
  78174. */
  78175. getVerticesDataKinds(): string[];
  78176. /**
  78177. * Returns a positive integer : the total number of indices in this mesh geometry.
  78178. * @returns the numner of indices or zero if the mesh has no geometry.
  78179. */
  78180. getTotalIndices(): number;
  78181. /**
  78182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78183. * @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.
  78184. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78185. * @returns the indices array or an empty array if the mesh has no geometry
  78186. */
  78187. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78188. readonly isBlocked: boolean;
  78189. /**
  78190. * Determine if the current mesh is ready to be rendered
  78191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78192. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78193. * @returns true if all associated assets are ready (material, textures, shaders)
  78194. */
  78195. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78196. /**
  78197. * 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.
  78198. */
  78199. readonly areNormalsFrozen: boolean;
  78200. /**
  78201. * 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.
  78202. * @returns the current mesh
  78203. */
  78204. freezeNormals(): Mesh;
  78205. /**
  78206. * 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
  78207. * @returns the current mesh
  78208. */
  78209. unfreezeNormals(): Mesh;
  78210. /**
  78211. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78212. */
  78213. overridenInstanceCount: number;
  78214. /** @hidden */
  78215. _preActivate(): Mesh;
  78216. /** @hidden */
  78217. _preActivateForIntermediateRendering(renderId: number): Mesh;
  78218. /** @hidden */
  78219. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  78220. /**
  78221. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78222. * This means the mesh underlying bounding box and sphere are recomputed.
  78223. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78224. * @returns the current mesh
  78225. */
  78226. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  78227. /** @hidden */
  78228. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  78229. /**
  78230. * This function will subdivide the mesh into multiple submeshes
  78231. * @param count defines the expected number of submeshes
  78232. */
  78233. subdivide(count: number): void;
  78234. /**
  78235. * Copy a FloatArray into a specific associated vertex buffer
  78236. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78237. * - VertexBuffer.PositionKind
  78238. * - VertexBuffer.UVKind
  78239. * - VertexBuffer.UV2Kind
  78240. * - VertexBuffer.UV3Kind
  78241. * - VertexBuffer.UV4Kind
  78242. * - VertexBuffer.UV5Kind
  78243. * - VertexBuffer.UV6Kind
  78244. * - VertexBuffer.ColorKind
  78245. * - VertexBuffer.MatricesIndicesKind
  78246. * - VertexBuffer.MatricesIndicesExtraKind
  78247. * - VertexBuffer.MatricesWeightsKind
  78248. * - VertexBuffer.MatricesWeightsExtraKind
  78249. * @param data defines the data source
  78250. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78251. * @param stride defines the data stride size (can be null)
  78252. * @returns the current mesh
  78253. */
  78254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78255. /**
  78256. * Flags an associated vertex buffer as updatable
  78257. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  78258. * - VertexBuffer.PositionKind
  78259. * - VertexBuffer.UVKind
  78260. * - VertexBuffer.UV2Kind
  78261. * - VertexBuffer.UV3Kind
  78262. * - VertexBuffer.UV4Kind
  78263. * - VertexBuffer.UV5Kind
  78264. * - VertexBuffer.UV6Kind
  78265. * - VertexBuffer.ColorKind
  78266. * - VertexBuffer.MatricesIndicesKind
  78267. * - VertexBuffer.MatricesIndicesExtraKind
  78268. * - VertexBuffer.MatricesWeightsKind
  78269. * - VertexBuffer.MatricesWeightsExtraKind
  78270. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78271. */
  78272. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  78273. /**
  78274. * Sets the mesh global Vertex Buffer
  78275. * @param buffer defines the buffer to use
  78276. * @returns the current mesh
  78277. */
  78278. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  78279. /**
  78280. * Update a specific associated vertex buffer
  78281. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78282. * - VertexBuffer.PositionKind
  78283. * - VertexBuffer.UVKind
  78284. * - VertexBuffer.UV2Kind
  78285. * - VertexBuffer.UV3Kind
  78286. * - VertexBuffer.UV4Kind
  78287. * - VertexBuffer.UV5Kind
  78288. * - VertexBuffer.UV6Kind
  78289. * - VertexBuffer.ColorKind
  78290. * - VertexBuffer.MatricesIndicesKind
  78291. * - VertexBuffer.MatricesIndicesExtraKind
  78292. * - VertexBuffer.MatricesWeightsKind
  78293. * - VertexBuffer.MatricesWeightsExtraKind
  78294. * @param data defines the data source
  78295. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78296. * @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)
  78297. * @returns the current mesh
  78298. */
  78299. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78300. /**
  78301. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  78302. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  78303. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  78304. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  78305. * @returns the current mesh
  78306. */
  78307. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  78308. /**
  78309. * Creates a un-shared specific occurence of the geometry for the mesh.
  78310. * @returns the current mesh
  78311. */
  78312. makeGeometryUnique(): Mesh;
  78313. /**
  78314. * Set the index buffer of this mesh
  78315. * @param indices defines the source data
  78316. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  78317. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  78318. * @returns the current mesh
  78319. */
  78320. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  78321. /**
  78322. * Update the current index buffer
  78323. * @param indices defines the source data
  78324. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  78325. * @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)
  78326. * @returns the current mesh
  78327. */
  78328. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  78329. /**
  78330. * Invert the geometry to move from a right handed system to a left handed one.
  78331. * @returns the current mesh
  78332. */
  78333. toLeftHanded(): Mesh;
  78334. /** @hidden */
  78335. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  78336. /** @hidden */
  78337. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  78338. /**
  78339. * Registers for this mesh a javascript function called just before the rendering process
  78340. * @param func defines the function to call before rendering this mesh
  78341. * @returns the current mesh
  78342. */
  78343. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78344. /**
  78345. * Disposes a previously registered javascript function called before the rendering
  78346. * @param func defines the function to remove
  78347. * @returns the current mesh
  78348. */
  78349. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78350. /**
  78351. * Registers for this mesh a javascript function called just after the rendering is complete
  78352. * @param func defines the function to call after rendering this mesh
  78353. * @returns the current mesh
  78354. */
  78355. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78356. /**
  78357. * Disposes a previously registered javascript function called after the rendering.
  78358. * @param func defines the function to remove
  78359. * @returns the current mesh
  78360. */
  78361. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78362. /** @hidden */
  78363. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78364. /** @hidden */
  78365. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78366. /** @hidden */
  78367. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78368. /**
  78369. * 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
  78370. * @param subMesh defines the subMesh to render
  78371. * @param enableAlphaMode defines if alpha mode can be changed
  78372. * @returns the current mesh
  78373. */
  78374. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78375. private _onBeforeDraw;
  78376. /**
  78377. * Renormalize the mesh and patch it up if there are no weights
  78378. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78379. * However in the case of zero weights then we set just a single influence to 1.
  78380. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78381. */
  78382. cleanMatrixWeights(): void;
  78383. private normalizeSkinFourWeights;
  78384. private normalizeSkinWeightsAndExtra;
  78385. /**
  78386. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78387. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78388. * the user know there was an issue with importing the mesh
  78389. * @returns a validation object with skinned, valid and report string
  78390. */
  78391. validateSkinning(): {
  78392. skinned: boolean;
  78393. valid: boolean;
  78394. report: string;
  78395. };
  78396. /** @hidden */
  78397. _checkDelayState(): Mesh;
  78398. private _queueLoad;
  78399. /**
  78400. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78401. * A mesh is in the frustum if its bounding box intersects the frustum
  78402. * @param frustumPlanes defines the frustum to test
  78403. * @returns true if the mesh is in the frustum planes
  78404. */
  78405. isInFrustum(frustumPlanes: Plane[]): boolean;
  78406. /**
  78407. * Sets the mesh material by the material or multiMaterial `id` property
  78408. * @param id is a string identifying the material or the multiMaterial
  78409. * @returns the current mesh
  78410. */
  78411. setMaterialByID(id: string): Mesh;
  78412. /**
  78413. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78414. * @returns an array of IAnimatable
  78415. */
  78416. getAnimatables(): IAnimatable[];
  78417. /**
  78418. * Modifies the mesh geometry according to the passed transformation matrix.
  78419. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78420. * The mesh normals are modified using the same transformation.
  78421. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78422. * @param transform defines the transform matrix to use
  78423. * @see http://doc.babylonjs.com/resources/baking_transformations
  78424. * @returns the current mesh
  78425. */
  78426. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78427. /**
  78428. * Modifies the mesh geometry according to its own current World Matrix.
  78429. * The mesh World Matrix is then reset.
  78430. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78431. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78432. * @see http://doc.babylonjs.com/resources/baking_transformations
  78433. * @returns the current mesh
  78434. */
  78435. bakeCurrentTransformIntoVertices(): Mesh;
  78436. /** @hidden */
  78437. readonly _positions: Nullable<Vector3[]>;
  78438. /** @hidden */
  78439. _resetPointsArrayCache(): Mesh;
  78440. /** @hidden */
  78441. _generatePointsArray(): boolean;
  78442. /**
  78443. * Returns a new Mesh object generated from the current mesh properties.
  78444. * This method must not get confused with createInstance()
  78445. * @param name is a string, the name given to the new mesh
  78446. * @param newParent can be any Node object (default `null`)
  78447. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78448. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78449. * @returns a new mesh
  78450. */
  78451. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78452. /**
  78453. * Releases resources associated with this mesh.
  78454. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78455. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78456. */
  78457. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78458. /**
  78459. * Modifies the mesh geometry according to a displacement map.
  78460. * 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.
  78461. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78462. * @param url is a string, the URL from the image file is to be downloaded.
  78463. * @param minHeight is the lower limit of the displacement.
  78464. * @param maxHeight is the upper limit of the displacement.
  78465. * @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.
  78466. * @param uvOffset is an optional vector2 used to offset UV.
  78467. * @param uvScale is an optional vector2 used to scale UV.
  78468. * @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.
  78469. * @returns the Mesh.
  78470. */
  78471. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78472. /**
  78473. * Modifies the mesh geometry according to a displacementMap buffer.
  78474. * 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.
  78475. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78476. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78477. * @param heightMapWidth is the width of the buffer image.
  78478. * @param heightMapHeight is the height of the buffer image.
  78479. * @param minHeight is the lower limit of the displacement.
  78480. * @param maxHeight is the upper limit of the displacement.
  78481. * @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.
  78482. * @param uvOffset is an optional vector2 used to offset UV.
  78483. * @param uvScale is an optional vector2 used to scale UV.
  78484. * @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.
  78485. * @returns the Mesh.
  78486. */
  78487. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78488. /**
  78489. * Modify the mesh to get a flat shading rendering.
  78490. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78491. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78492. * @returns current mesh
  78493. */
  78494. convertToFlatShadedMesh(): Mesh;
  78495. /**
  78496. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78497. * In other words, more vertices, no more indices and a single bigger VBO.
  78498. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78499. * @returns current mesh
  78500. */
  78501. convertToUnIndexedMesh(): Mesh;
  78502. /**
  78503. * Inverses facet orientations.
  78504. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78505. * @param flipNormals will also inverts the normals
  78506. * @returns current mesh
  78507. */
  78508. flipFaces(flipNormals?: boolean): Mesh;
  78509. /** @hidden */
  78510. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78511. /** @hidden */
  78512. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78513. /**
  78514. * Creates a new InstancedMesh object from the mesh model.
  78515. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78516. * @param name defines the name of the new instance
  78517. * @returns a new InstancedMesh
  78518. */
  78519. createInstance(name: string): InstancedMesh;
  78520. /**
  78521. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78522. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78523. * @returns the current mesh
  78524. */
  78525. synchronizeInstances(): Mesh;
  78526. /**
  78527. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78528. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78529. * This should be used together with the simplification to avoid disappearing triangles.
  78530. * @param successCallback an optional success callback to be called after the optimization finished.
  78531. * @returns the current mesh
  78532. */
  78533. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78534. /**
  78535. * Serialize current mesh
  78536. * @param serializationObject defines the object which will receive the serialization data
  78537. */
  78538. serialize(serializationObject: any): void;
  78539. /** @hidden */
  78540. _syncGeometryWithMorphTargetManager(): void;
  78541. /** @hidden */
  78542. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78543. /**
  78544. * Returns a new Mesh object parsed from the source provided.
  78545. * @param parsedMesh is the source
  78546. * @param scene defines the hosting scene
  78547. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78548. * @returns a new Mesh
  78549. */
  78550. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78551. /**
  78552. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78553. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78554. * @param name defines the name of the mesh to create
  78555. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78556. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78557. * @param closePath creates a seam between the first and the last points of each path of the path array
  78558. * @param offset is taken in account only if the `pathArray` is containing a single path
  78559. * @param scene defines the hosting scene
  78560. * @param updatable defines if the mesh must be flagged as updatable
  78561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78562. * @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)
  78563. * @returns a new Mesh
  78564. */
  78565. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78566. /**
  78567. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78568. * @param name defines the name of the mesh to create
  78569. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78570. * @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
  78571. * @param scene defines the hosting scene
  78572. * @param updatable defines if the mesh must be flagged as updatable
  78573. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78574. * @returns a new Mesh
  78575. */
  78576. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78577. /**
  78578. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78579. * @param name defines the name of the mesh to create
  78580. * @param size sets the size (float) of each box side (default 1)
  78581. * @param scene defines the hosting scene
  78582. * @param updatable defines if the mesh must be flagged as updatable
  78583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78584. * @returns a new Mesh
  78585. */
  78586. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78587. /**
  78588. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78589. * @param name defines the name of the mesh to create
  78590. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78591. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78592. * @param scene defines the hosting scene
  78593. * @param updatable defines if the mesh must be flagged as updatable
  78594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78595. * @returns a new Mesh
  78596. */
  78597. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78598. /**
  78599. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78600. * @param name defines the name of the mesh to create
  78601. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78602. * @param diameterTop set the top cap diameter (floats, default 1)
  78603. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78604. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78605. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78606. * @param scene defines the hosting scene
  78607. * @param updatable defines if the mesh must be flagged as updatable
  78608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78609. * @returns a new Mesh
  78610. */
  78611. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78612. /**
  78613. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78614. * @param name defines the name of the mesh to create
  78615. * @param diameter sets the diameter size (float) of the torus (default 1)
  78616. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78617. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78618. * @param scene defines the hosting scene
  78619. * @param updatable defines if the mesh must be flagged as updatable
  78620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78621. * @returns a new Mesh
  78622. */
  78623. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78624. /**
  78625. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78626. * @param name defines the name of the mesh to create
  78627. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78628. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78629. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78630. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78631. * @param p the number of windings on X axis (positive integers, default 2)
  78632. * @param q the number of windings on Y axis (positive integers, default 3)
  78633. * @param scene defines the hosting scene
  78634. * @param updatable defines if the mesh must be flagged as updatable
  78635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78636. * @returns a new Mesh
  78637. */
  78638. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78639. /**
  78640. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78641. * @param name defines the name of the mesh to create
  78642. * @param points is an array successive Vector3
  78643. * @param scene defines the hosting scene
  78644. * @param updatable defines if the mesh must be flagged as updatable
  78645. * @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).
  78646. * @returns a new Mesh
  78647. */
  78648. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78649. /**
  78650. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78651. * @param name defines the name of the mesh to create
  78652. * @param points is an array successive Vector3
  78653. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78654. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78655. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78656. * @param scene defines the hosting scene
  78657. * @param updatable defines if the mesh must be flagged as updatable
  78658. * @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)
  78659. * @returns a new Mesh
  78660. */
  78661. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78662. /**
  78663. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78664. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78665. * 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.
  78666. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78667. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78668. * Remember you can only change the shape positions, not their number when updating a polygon.
  78669. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78670. * @param name defines the name of the mesh to create
  78671. * @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
  78672. * @param scene defines the hosting scene
  78673. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78674. * @param updatable defines if the mesh must be flagged as updatable
  78675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78676. * @param earcutInjection can be used to inject your own earcut reference
  78677. * @returns a new Mesh
  78678. */
  78679. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78680. /**
  78681. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78682. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78683. * @param name defines the name of the mesh to create
  78684. * @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
  78685. * @param depth defines the height of extrusion
  78686. * @param scene defines the hosting scene
  78687. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78688. * @param updatable defines if the mesh must be flagged as updatable
  78689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78690. * @param earcutInjection can be used to inject your own earcut reference
  78691. * @returns a new Mesh
  78692. */
  78693. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78694. /**
  78695. * Creates an extruded shape mesh.
  78696. * 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
  78697. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78698. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78699. * @param name defines the name of the mesh to create
  78700. * @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
  78701. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78702. * @param scale is the value to scale the shape
  78703. * @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
  78704. * @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
  78705. * @param scene defines the hosting scene
  78706. * @param updatable defines if the mesh must be flagged as updatable
  78707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78708. * @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)
  78709. * @returns a new Mesh
  78710. */
  78711. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78712. /**
  78713. * Creates an custom extruded shape mesh.
  78714. * The custom extrusion is a parametric shape.
  78715. * It has no predefined shape. Its final shape will depend on the input parameters.
  78716. * Please consider using the same method from the MeshBuilder class instead
  78717. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78718. * @param name defines the name of the mesh to create
  78719. * @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
  78720. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78721. * @param scaleFunction is a custom Javascript function called on each path point
  78722. * @param rotationFunction is a custom Javascript function called on each path point
  78723. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78724. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78725. * @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
  78726. * @param scene defines the hosting scene
  78727. * @param updatable defines if the mesh must be flagged as updatable
  78728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78729. * @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)
  78730. * @returns a new Mesh
  78731. */
  78732. 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;
  78733. /**
  78734. * Creates lathe mesh.
  78735. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78736. * Please consider using the same method from the MeshBuilder class instead
  78737. * @param name defines the name of the mesh to create
  78738. * @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
  78739. * @param radius is the radius value of the lathe
  78740. * @param tessellation is the side number of the lathe.
  78741. * @param scene defines the hosting scene
  78742. * @param updatable defines if the mesh must be flagged as updatable
  78743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78744. * @returns a new Mesh
  78745. */
  78746. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78747. /**
  78748. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78749. * @param name defines the name of the mesh to create
  78750. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78751. * @param scene defines the hosting scene
  78752. * @param updatable defines if the mesh must be flagged as updatable
  78753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78754. * @returns a new Mesh
  78755. */
  78756. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78757. /**
  78758. * Creates a ground mesh.
  78759. * Please consider using the same method from the MeshBuilder class instead
  78760. * @param name defines the name of the mesh to create
  78761. * @param width set the width of the ground
  78762. * @param height set the height of the ground
  78763. * @param subdivisions sets the number of subdivisions per side
  78764. * @param scene defines the hosting scene
  78765. * @param updatable defines if the mesh must be flagged as updatable
  78766. * @returns a new Mesh
  78767. */
  78768. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78769. /**
  78770. * Creates a tiled ground mesh.
  78771. * Please consider using the same method from the MeshBuilder class instead
  78772. * @param name defines the name of the mesh to create
  78773. * @param xmin set the ground minimum X coordinate
  78774. * @param zmin set the ground minimum Y coordinate
  78775. * @param xmax set the ground maximum X coordinate
  78776. * @param zmax set the ground maximum Z coordinate
  78777. * @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
  78778. * @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
  78779. * @param scene defines the hosting scene
  78780. * @param updatable defines if the mesh must be flagged as updatable
  78781. * @returns a new Mesh
  78782. */
  78783. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78784. w: number;
  78785. h: number;
  78786. }, precision: {
  78787. w: number;
  78788. h: number;
  78789. }, scene: Scene, updatable?: boolean): Mesh;
  78790. /**
  78791. * Creates a ground mesh from a height map.
  78792. * Please consider using the same method from the MeshBuilder class instead
  78793. * @see http://doc.babylonjs.com/babylon101/height_map
  78794. * @param name defines the name of the mesh to create
  78795. * @param url sets the URL of the height map image resource
  78796. * @param width set the ground width size
  78797. * @param height set the ground height size
  78798. * @param subdivisions sets the number of subdivision per side
  78799. * @param minHeight is the minimum altitude on the ground
  78800. * @param maxHeight is the maximum altitude on the ground
  78801. * @param scene defines the hosting scene
  78802. * @param updatable defines if the mesh must be flagged as updatable
  78803. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78804. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78805. * @returns a new Mesh
  78806. */
  78807. 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;
  78808. /**
  78809. * Creates a tube mesh.
  78810. * The tube is a parametric shape.
  78811. * It has no predefined shape. Its final shape will depend on the input parameters.
  78812. * Please consider using the same method from the MeshBuilder class instead
  78813. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78814. * @param name defines the name of the mesh to create
  78815. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78816. * @param radius sets the tube radius size
  78817. * @param tessellation is the number of sides on the tubular surface
  78818. * @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
  78819. * @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
  78820. * @param scene defines the hosting scene
  78821. * @param updatable defines if the mesh must be flagged as updatable
  78822. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78823. * @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)
  78824. * @returns a new Mesh
  78825. */
  78826. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78827. (i: number, distance: number): number;
  78828. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78829. /**
  78830. * Creates a polyhedron mesh.
  78831. * Please consider using the same method from the MeshBuilder class instead.
  78832. * * 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
  78833. * * The parameter `size` (positive float, default 1) sets the polygon size
  78834. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78835. * * 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`
  78836. * * 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
  78837. * * 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)`)
  78838. * * 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
  78839. * * 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
  78840. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78841. * * If you create a double-sided mesh, you can choose what parts of 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
  78842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78843. * @param name defines the name of the mesh to create
  78844. * @param options defines the options used to create the mesh
  78845. * @param scene defines the hosting scene
  78846. * @returns a new Mesh
  78847. */
  78848. static CreatePolyhedron(name: string, options: {
  78849. type?: number;
  78850. size?: number;
  78851. sizeX?: number;
  78852. sizeY?: number;
  78853. sizeZ?: number;
  78854. custom?: any;
  78855. faceUV?: Vector4[];
  78856. faceColors?: Color4[];
  78857. updatable?: boolean;
  78858. sideOrientation?: number;
  78859. }, scene: Scene): Mesh;
  78860. /**
  78861. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78862. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78863. * * 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`)
  78864. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78865. * * 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
  78866. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78867. * * If you create a double-sided mesh, you can choose what parts of 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
  78868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78869. * @param name defines the name of the mesh
  78870. * @param options defines the options used to create the mesh
  78871. * @param scene defines the hosting scene
  78872. * @returns a new Mesh
  78873. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78874. */
  78875. static CreateIcoSphere(name: string, options: {
  78876. radius?: number;
  78877. flat?: boolean;
  78878. subdivisions?: number;
  78879. sideOrientation?: number;
  78880. updatable?: boolean;
  78881. }, scene: Scene): Mesh;
  78882. /**
  78883. * Creates a decal mesh.
  78884. * Please consider using the same method from the MeshBuilder class instead.
  78885. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78886. * @param name defines the name of the mesh
  78887. * @param sourceMesh defines the mesh receiving the decal
  78888. * @param position sets the position of the decal in world coordinates
  78889. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78890. * @param size sets the decal scaling
  78891. * @param angle sets the angle to rotate the decal
  78892. * @returns a new Mesh
  78893. */
  78894. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78895. /**
  78896. * Prepare internal position array for software CPU skinning
  78897. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78898. */
  78899. setPositionsForCPUSkinning(): Float32Array;
  78900. /**
  78901. * Prepare internal normal array for software CPU skinning
  78902. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78903. */
  78904. setNormalsForCPUSkinning(): Float32Array;
  78905. /**
  78906. * Updates the vertex buffer by applying transformation from the bones
  78907. * @param skeleton defines the skeleton to apply to current mesh
  78908. * @returns the current mesh
  78909. */
  78910. applySkeleton(skeleton: Skeleton): Mesh;
  78911. /**
  78912. * 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
  78913. * @param meshes defines the list of meshes to scan
  78914. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78915. */
  78916. static MinMax(meshes: AbstractMesh[]): {
  78917. min: Vector3;
  78918. max: Vector3;
  78919. };
  78920. /**
  78921. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78922. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78923. * @returns a vector3
  78924. */
  78925. static Center(meshesOrMinMaxVector: {
  78926. min: Vector3;
  78927. max: Vector3;
  78928. } | AbstractMesh[]): Vector3;
  78929. /**
  78930. * Merge the array of meshes into a single mesh for performance reasons.
  78931. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78932. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78933. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78934. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78935. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78936. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78937. * @returns a new mesh
  78938. */
  78939. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78940. /** @hidden */
  78941. addInstance(instance: InstancedMesh): void;
  78942. /** @hidden */
  78943. removeInstance(instance: InstancedMesh): void;
  78944. }
  78945. }
  78946. declare module BABYLON {
  78947. /**
  78948. * Base class for the main features of a material in Babylon.js
  78949. */
  78950. export class Material implements IAnimatable {
  78951. /**
  78952. * Returns the triangle fill mode
  78953. */
  78954. static readonly TriangleFillMode: number;
  78955. /**
  78956. * Returns the wireframe mode
  78957. */
  78958. static readonly WireFrameFillMode: number;
  78959. /**
  78960. * Returns the point fill mode
  78961. */
  78962. static readonly PointFillMode: number;
  78963. /**
  78964. * Returns the point list draw mode
  78965. */
  78966. static readonly PointListDrawMode: number;
  78967. /**
  78968. * Returns the line list draw mode
  78969. */
  78970. static readonly LineListDrawMode: number;
  78971. /**
  78972. * Returns the line loop draw mode
  78973. */
  78974. static readonly LineLoopDrawMode: number;
  78975. /**
  78976. * Returns the line strip draw mode
  78977. */
  78978. static readonly LineStripDrawMode: number;
  78979. /**
  78980. * Returns the triangle strip draw mode
  78981. */
  78982. static readonly TriangleStripDrawMode: number;
  78983. /**
  78984. * Returns the triangle fan draw mode
  78985. */
  78986. static readonly TriangleFanDrawMode: number;
  78987. /**
  78988. * Stores the clock-wise side orientation
  78989. */
  78990. static readonly ClockWiseSideOrientation: number;
  78991. /**
  78992. * Stores the counter clock-wise side orientation
  78993. */
  78994. static readonly CounterClockWiseSideOrientation: number;
  78995. /**
  78996. * The dirty texture flag value
  78997. */
  78998. static readonly TextureDirtyFlag: number;
  78999. /**
  79000. * The dirty light flag value
  79001. */
  79002. static readonly LightDirtyFlag: number;
  79003. /**
  79004. * The dirty fresnel flag value
  79005. */
  79006. static readonly FresnelDirtyFlag: number;
  79007. /**
  79008. * The dirty attribute flag value
  79009. */
  79010. static readonly AttributesDirtyFlag: number;
  79011. /**
  79012. * The dirty misc flag value
  79013. */
  79014. static readonly MiscDirtyFlag: number;
  79015. /**
  79016. * The all dirty flag value
  79017. */
  79018. static readonly AllDirtyFlag: number;
  79019. /**
  79020. * The ID of the material
  79021. */
  79022. id: string;
  79023. /**
  79024. * Gets or sets the unique id of the material
  79025. */
  79026. uniqueId: number;
  79027. /**
  79028. * The name of the material
  79029. */
  79030. name: string;
  79031. /**
  79032. * Gets or sets user defined metadata
  79033. */
  79034. metadata: any;
  79035. /**
  79036. * For internal use only. Please do not use.
  79037. */
  79038. reservedDataStore: any;
  79039. /**
  79040. * Specifies if the ready state should be checked on each call
  79041. */
  79042. checkReadyOnEveryCall: boolean;
  79043. /**
  79044. * Specifies if the ready state should be checked once
  79045. */
  79046. checkReadyOnlyOnce: boolean;
  79047. /**
  79048. * The state of the material
  79049. */
  79050. state: string;
  79051. /**
  79052. * The alpha value of the material
  79053. */
  79054. protected _alpha: number;
  79055. /**
  79056. * Sets the alpha value of the material
  79057. */
  79058. /**
  79059. * Gets the alpha value of the material
  79060. */
  79061. alpha: number;
  79062. /**
  79063. * Specifies if back face culling is enabled
  79064. */
  79065. protected _backFaceCulling: boolean;
  79066. /**
  79067. * Sets the back-face culling state
  79068. */
  79069. /**
  79070. * Gets the back-face culling state
  79071. */
  79072. backFaceCulling: boolean;
  79073. /**
  79074. * Stores the value for side orientation
  79075. */
  79076. sideOrientation: number;
  79077. /**
  79078. * Callback triggered when the material is compiled
  79079. */
  79080. onCompiled: (effect: Effect) => void;
  79081. /**
  79082. * Callback triggered when an error occurs
  79083. */
  79084. onError: (effect: Effect, errors: string) => void;
  79085. /**
  79086. * Callback triggered to get the render target textures
  79087. */
  79088. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  79089. /**
  79090. * Gets a boolean indicating that current material needs to register RTT
  79091. */
  79092. readonly hasRenderTargetTextures: boolean;
  79093. /**
  79094. * Specifies if the material should be serialized
  79095. */
  79096. doNotSerialize: boolean;
  79097. /**
  79098. * @hidden
  79099. */
  79100. _storeEffectOnSubMeshes: boolean;
  79101. /**
  79102. * Stores the animations for the material
  79103. */
  79104. animations: Array<Animation>;
  79105. /**
  79106. * An event triggered when the material is disposed
  79107. */
  79108. onDisposeObservable: Observable<Material>;
  79109. /**
  79110. * An observer which watches for dispose events
  79111. */
  79112. private _onDisposeObserver;
  79113. private _onUnBindObservable;
  79114. /**
  79115. * Called during a dispose event
  79116. */
  79117. onDispose: () => void;
  79118. private _onBindObservable;
  79119. /**
  79120. * An event triggered when the material is bound
  79121. */
  79122. readonly onBindObservable: Observable<AbstractMesh>;
  79123. /**
  79124. * An observer which watches for bind events
  79125. */
  79126. private _onBindObserver;
  79127. /**
  79128. * Called during a bind event
  79129. */
  79130. onBind: (Mesh: AbstractMesh) => void;
  79131. /**
  79132. * An event triggered when the material is unbound
  79133. */
  79134. readonly onUnBindObservable: Observable<Material>;
  79135. /**
  79136. * Stores the value of the alpha mode
  79137. */
  79138. private _alphaMode;
  79139. /**
  79140. * Sets the value of the alpha mode.
  79141. *
  79142. * | Value | Type | Description |
  79143. * | --- | --- | --- |
  79144. * | 0 | ALPHA_DISABLE | |
  79145. * | 1 | ALPHA_ADD | |
  79146. * | 2 | ALPHA_COMBINE | |
  79147. * | 3 | ALPHA_SUBTRACT | |
  79148. * | 4 | ALPHA_MULTIPLY | |
  79149. * | 5 | ALPHA_MAXIMIZED | |
  79150. * | 6 | ALPHA_ONEONE | |
  79151. * | 7 | ALPHA_PREMULTIPLIED | |
  79152. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79153. * | 9 | ALPHA_INTERPOLATE | |
  79154. * | 10 | ALPHA_SCREENMODE | |
  79155. *
  79156. */
  79157. /**
  79158. * Gets the value of the alpha mode
  79159. */
  79160. alphaMode: number;
  79161. /**
  79162. * Stores the state of the need depth pre-pass value
  79163. */
  79164. private _needDepthPrePass;
  79165. /**
  79166. * Sets the need depth pre-pass value
  79167. */
  79168. /**
  79169. * Gets the depth pre-pass value
  79170. */
  79171. needDepthPrePass: boolean;
  79172. /**
  79173. * Specifies if depth writing should be disabled
  79174. */
  79175. disableDepthWrite: boolean;
  79176. /**
  79177. * Specifies if depth writing should be forced
  79178. */
  79179. forceDepthWrite: boolean;
  79180. /**
  79181. * Specifies if there should be a separate pass for culling
  79182. */
  79183. separateCullingPass: boolean;
  79184. /**
  79185. * Stores the state specifing if fog should be enabled
  79186. */
  79187. private _fogEnabled;
  79188. /**
  79189. * Sets the state for enabling fog
  79190. */
  79191. /**
  79192. * Gets the value of the fog enabled state
  79193. */
  79194. fogEnabled: boolean;
  79195. /**
  79196. * Stores the size of points
  79197. */
  79198. pointSize: number;
  79199. /**
  79200. * Stores the z offset value
  79201. */
  79202. zOffset: number;
  79203. /**
  79204. * Gets a value specifying if wireframe mode is enabled
  79205. */
  79206. /**
  79207. * Sets the state of wireframe mode
  79208. */
  79209. wireframe: boolean;
  79210. /**
  79211. * Gets the value specifying if point clouds are enabled
  79212. */
  79213. /**
  79214. * Sets the state of point cloud mode
  79215. */
  79216. pointsCloud: boolean;
  79217. /**
  79218. * Gets the material fill mode
  79219. */
  79220. /**
  79221. * Sets the material fill mode
  79222. */
  79223. fillMode: number;
  79224. /**
  79225. * @hidden
  79226. * Stores the effects for the material
  79227. */
  79228. _effect: Nullable<Effect>;
  79229. /**
  79230. * @hidden
  79231. * Specifies if the material was previously ready
  79232. */
  79233. _wasPreviouslyReady: boolean;
  79234. /**
  79235. * Specifies if uniform buffers should be used
  79236. */
  79237. private _useUBO;
  79238. /**
  79239. * Stores a reference to the scene
  79240. */
  79241. private _scene;
  79242. /**
  79243. * Stores the fill mode state
  79244. */
  79245. private _fillMode;
  79246. /**
  79247. * Specifies if the depth write state should be cached
  79248. */
  79249. private _cachedDepthWriteState;
  79250. /**
  79251. * Stores the uniform buffer
  79252. */
  79253. protected _uniformBuffer: UniformBuffer;
  79254. /** @hidden */
  79255. _indexInSceneMaterialArray: number;
  79256. /** @hidden */
  79257. meshMap: Nullable<{
  79258. [id: string]: AbstractMesh | undefined;
  79259. }>;
  79260. /**
  79261. * Creates a material instance
  79262. * @param name defines the name of the material
  79263. * @param scene defines the scene to reference
  79264. * @param doNotAdd specifies if the material should be added to the scene
  79265. */
  79266. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  79267. /**
  79268. * Returns a string representation of the current material
  79269. * @param fullDetails defines a boolean indicating which levels of logging is desired
  79270. * @returns a string with material information
  79271. */
  79272. toString(fullDetails?: boolean): string;
  79273. /**
  79274. * Gets the class name of the material
  79275. * @returns a string with the class name of the material
  79276. */
  79277. getClassName(): string;
  79278. /**
  79279. * Specifies if updates for the material been locked
  79280. */
  79281. readonly isFrozen: boolean;
  79282. /**
  79283. * Locks updates for the material
  79284. */
  79285. freeze(): void;
  79286. /**
  79287. * Unlocks updates for the material
  79288. */
  79289. unfreeze(): void;
  79290. /**
  79291. * Specifies if the material is ready to be used
  79292. * @param mesh defines the mesh to check
  79293. * @param useInstances specifies if instances should be used
  79294. * @returns a boolean indicating if the material is ready to be used
  79295. */
  79296. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79297. /**
  79298. * Specifies that the submesh is ready to be used
  79299. * @param mesh defines the mesh to check
  79300. * @param subMesh defines which submesh to check
  79301. * @param useInstances specifies that instances should be used
  79302. * @returns a boolean indicating that the submesh is ready or not
  79303. */
  79304. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79305. /**
  79306. * Returns the material effect
  79307. * @returns the effect associated with the material
  79308. */
  79309. getEffect(): Nullable<Effect>;
  79310. /**
  79311. * Returns the current scene
  79312. * @returns a Scene
  79313. */
  79314. getScene(): Scene;
  79315. /**
  79316. * Specifies if the material will require alpha blending
  79317. * @returns a boolean specifying if alpha blending is needed
  79318. */
  79319. needAlphaBlending(): boolean;
  79320. /**
  79321. * Specifies if the mesh will require alpha blending
  79322. * @param mesh defines the mesh to check
  79323. * @returns a boolean specifying if alpha blending is needed for the mesh
  79324. */
  79325. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  79326. /**
  79327. * Specifies if this material should be rendered in alpha test mode
  79328. * @returns a boolean specifying if an alpha test is needed.
  79329. */
  79330. needAlphaTesting(): boolean;
  79331. /**
  79332. * Gets the texture used for the alpha test
  79333. * @returns the texture to use for alpha testing
  79334. */
  79335. getAlphaTestTexture(): Nullable<BaseTexture>;
  79336. /**
  79337. * Marks the material to indicate that it needs to be re-calculated
  79338. */
  79339. markDirty(): void;
  79340. /** @hidden */
  79341. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  79342. /**
  79343. * Binds the material to the mesh
  79344. * @param world defines the world transformation matrix
  79345. * @param mesh defines the mesh to bind the material to
  79346. */
  79347. bind(world: Matrix, mesh?: Mesh): void;
  79348. /**
  79349. * Binds the submesh to the material
  79350. * @param world defines the world transformation matrix
  79351. * @param mesh defines the mesh containing the submesh
  79352. * @param subMesh defines the submesh to bind the material to
  79353. */
  79354. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79355. /**
  79356. * Binds the world matrix to the material
  79357. * @param world defines the world transformation matrix
  79358. */
  79359. bindOnlyWorldMatrix(world: Matrix): void;
  79360. /**
  79361. * Binds the scene's uniform buffer to the effect.
  79362. * @param effect defines the effect to bind to the scene uniform buffer
  79363. * @param sceneUbo defines the uniform buffer storing scene data
  79364. */
  79365. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79366. /**
  79367. * Binds the view matrix to the effect
  79368. * @param effect defines the effect to bind the view matrix to
  79369. */
  79370. bindView(effect: Effect): void;
  79371. /**
  79372. * Binds the view projection matrix to the effect
  79373. * @param effect defines the effect to bind the view projection matrix to
  79374. */
  79375. bindViewProjection(effect: Effect): void;
  79376. /**
  79377. * Specifies if material alpha testing should be turned on for the mesh
  79378. * @param mesh defines the mesh to check
  79379. */
  79380. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79381. /**
  79382. * Processes to execute after binding the material to a mesh
  79383. * @param mesh defines the rendered mesh
  79384. */
  79385. protected _afterBind(mesh?: Mesh): void;
  79386. /**
  79387. * Unbinds the material from the mesh
  79388. */
  79389. unbind(): void;
  79390. /**
  79391. * Gets the active textures from the material
  79392. * @returns an array of textures
  79393. */
  79394. getActiveTextures(): BaseTexture[];
  79395. /**
  79396. * Specifies if the material uses a texture
  79397. * @param texture defines the texture to check against the material
  79398. * @returns a boolean specifying if the material uses the texture
  79399. */
  79400. hasTexture(texture: BaseTexture): boolean;
  79401. /**
  79402. * Makes a duplicate of the material, and gives it a new name
  79403. * @param name defines the new name for the duplicated material
  79404. * @returns the cloned material
  79405. */
  79406. clone(name: string): Nullable<Material>;
  79407. /**
  79408. * Gets the meshes bound to the material
  79409. * @returns an array of meshes bound to the material
  79410. */
  79411. getBindedMeshes(): AbstractMesh[];
  79412. /**
  79413. * Force shader compilation
  79414. * @param mesh defines the mesh associated with this material
  79415. * @param onCompiled defines a function to execute once the material is compiled
  79416. * @param options defines the options to configure the compilation
  79417. */
  79418. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79419. clipPlane: boolean;
  79420. }>): void;
  79421. /**
  79422. * Force shader compilation
  79423. * @param mesh defines the mesh that will use this material
  79424. * @param options defines additional options for compiling the shaders
  79425. * @returns a promise that resolves when the compilation completes
  79426. */
  79427. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79428. clipPlane: boolean;
  79429. }>): Promise<void>;
  79430. private static readonly _ImageProcessingDirtyCallBack;
  79431. private static readonly _TextureDirtyCallBack;
  79432. private static readonly _FresnelDirtyCallBack;
  79433. private static readonly _MiscDirtyCallBack;
  79434. private static readonly _LightsDirtyCallBack;
  79435. private static readonly _AttributeDirtyCallBack;
  79436. private static _FresnelAndMiscDirtyCallBack;
  79437. private static _TextureAndMiscDirtyCallBack;
  79438. private static readonly _DirtyCallbackArray;
  79439. private static readonly _RunDirtyCallBacks;
  79440. /**
  79441. * Marks a define in the material to indicate that it needs to be re-computed
  79442. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79443. */
  79444. markAsDirty(flag: number): void;
  79445. /**
  79446. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79447. * @param func defines a function which checks material defines against the submeshes
  79448. */
  79449. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79450. /**
  79451. * Indicates that image processing needs to be re-calculated for all submeshes
  79452. */
  79453. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79454. /**
  79455. * Indicates that textures need to be re-calculated for all submeshes
  79456. */
  79457. protected _markAllSubMeshesAsTexturesDirty(): void;
  79458. /**
  79459. * Indicates that fresnel needs to be re-calculated for all submeshes
  79460. */
  79461. protected _markAllSubMeshesAsFresnelDirty(): void;
  79462. /**
  79463. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79464. */
  79465. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79466. /**
  79467. * Indicates that lights need to be re-calculated for all submeshes
  79468. */
  79469. protected _markAllSubMeshesAsLightsDirty(): void;
  79470. /**
  79471. * Indicates that attributes need to be re-calculated for all submeshes
  79472. */
  79473. protected _markAllSubMeshesAsAttributesDirty(): void;
  79474. /**
  79475. * Indicates that misc needs to be re-calculated for all submeshes
  79476. */
  79477. protected _markAllSubMeshesAsMiscDirty(): void;
  79478. /**
  79479. * Indicates that textures and misc need to be re-calculated for all submeshes
  79480. */
  79481. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79482. /**
  79483. * Disposes the material
  79484. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79485. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79486. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79487. */
  79488. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79489. /** @hidden */
  79490. private releaseVertexArrayObject;
  79491. /**
  79492. * Serializes this material
  79493. * @returns the serialized material object
  79494. */
  79495. serialize(): any;
  79496. /**
  79497. * Creates a material from parsed material data
  79498. * @param parsedMaterial defines parsed material data
  79499. * @param scene defines the hosting scene
  79500. * @param rootUrl defines the root URL to use to load textures
  79501. * @returns a new material
  79502. */
  79503. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79504. }
  79505. }
  79506. declare module BABYLON {
  79507. /**
  79508. * Base class for submeshes
  79509. */
  79510. export class BaseSubMesh {
  79511. /** @hidden */
  79512. _materialDefines: Nullable<MaterialDefines>;
  79513. /** @hidden */
  79514. _materialEffect: Nullable<Effect>;
  79515. /**
  79516. * Gets associated effect
  79517. */
  79518. readonly effect: Nullable<Effect>;
  79519. /**
  79520. * Sets associated effect (effect used to render this submesh)
  79521. * @param effect defines the effect to associate with
  79522. * @param defines defines the set of defines used to compile this effect
  79523. */
  79524. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79525. }
  79526. /**
  79527. * Defines a subdivision inside a mesh
  79528. */
  79529. export class SubMesh extends BaseSubMesh implements ICullable {
  79530. /** the material index to use */
  79531. materialIndex: number;
  79532. /** vertex index start */
  79533. verticesStart: number;
  79534. /** vertices count */
  79535. verticesCount: number;
  79536. /** index start */
  79537. indexStart: number;
  79538. /** indices count */
  79539. indexCount: number;
  79540. /** @hidden */
  79541. _linesIndexCount: number;
  79542. private _mesh;
  79543. private _renderingMesh;
  79544. private _boundingInfo;
  79545. private _linesIndexBuffer;
  79546. /** @hidden */
  79547. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79548. /** @hidden */
  79549. _trianglePlanes: Plane[];
  79550. /** @hidden */
  79551. _lastColliderTransformMatrix: Matrix;
  79552. /** @hidden */
  79553. _renderId: number;
  79554. /** @hidden */
  79555. _alphaIndex: number;
  79556. /** @hidden */
  79557. _distanceToCamera: number;
  79558. /** @hidden */
  79559. _id: number;
  79560. private _currentMaterial;
  79561. /**
  79562. * Add a new submesh to a mesh
  79563. * @param materialIndex defines the material index to use
  79564. * @param verticesStart defines vertex index start
  79565. * @param verticesCount defines vertices count
  79566. * @param indexStart defines index start
  79567. * @param indexCount defines indices count
  79568. * @param mesh defines the parent mesh
  79569. * @param renderingMesh defines an optional rendering mesh
  79570. * @param createBoundingBox defines if bounding box should be created for this submesh
  79571. * @returns the new submesh
  79572. */
  79573. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79574. /**
  79575. * Creates a new submesh
  79576. * @param materialIndex defines the material index to use
  79577. * @param verticesStart defines vertex index start
  79578. * @param verticesCount defines vertices count
  79579. * @param indexStart defines index start
  79580. * @param indexCount defines indices count
  79581. * @param mesh defines the parent mesh
  79582. * @param renderingMesh defines an optional rendering mesh
  79583. * @param createBoundingBox defines if bounding box should be created for this submesh
  79584. */
  79585. constructor(
  79586. /** the material index to use */
  79587. materialIndex: number,
  79588. /** vertex index start */
  79589. verticesStart: number,
  79590. /** vertices count */
  79591. verticesCount: number,
  79592. /** index start */
  79593. indexStart: number,
  79594. /** indices count */
  79595. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79596. /**
  79597. * Returns true if this submesh covers the entire parent mesh
  79598. * @ignorenaming
  79599. */
  79600. readonly IsGlobal: boolean;
  79601. /**
  79602. * Returns the submesh BoudingInfo object
  79603. * @returns current bounding info (or mesh's one if the submesh is global)
  79604. */
  79605. getBoundingInfo(): BoundingInfo;
  79606. /**
  79607. * Sets the submesh BoundingInfo
  79608. * @param boundingInfo defines the new bounding info to use
  79609. * @returns the SubMesh
  79610. */
  79611. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79612. /**
  79613. * Returns the mesh of the current submesh
  79614. * @return the parent mesh
  79615. */
  79616. getMesh(): AbstractMesh;
  79617. /**
  79618. * Returns the rendering mesh of the submesh
  79619. * @returns the rendering mesh (could be different from parent mesh)
  79620. */
  79621. getRenderingMesh(): Mesh;
  79622. /**
  79623. * Returns the submesh material
  79624. * @returns null or the current material
  79625. */
  79626. getMaterial(): Nullable<Material>;
  79627. /**
  79628. * Sets a new updated BoundingInfo object to the submesh
  79629. * @returns the SubMesh
  79630. */
  79631. refreshBoundingInfo(): SubMesh;
  79632. /** @hidden */
  79633. _checkCollision(collider: Collider): boolean;
  79634. /**
  79635. * Updates the submesh BoundingInfo
  79636. * @param world defines the world matrix to use to update the bounding info
  79637. * @returns the submesh
  79638. */
  79639. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79640. /**
  79641. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79642. * @param frustumPlanes defines the frustum planes
  79643. * @returns true if the submesh is intersecting with the frustum
  79644. */
  79645. isInFrustum(frustumPlanes: Plane[]): boolean;
  79646. /**
  79647. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79648. * @param frustumPlanes defines the frustum planes
  79649. * @returns true if the submesh is inside the frustum
  79650. */
  79651. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79652. /**
  79653. * Renders the submesh
  79654. * @param enableAlphaMode defines if alpha needs to be used
  79655. * @returns the submesh
  79656. */
  79657. render(enableAlphaMode: boolean): SubMesh;
  79658. /**
  79659. * @hidden
  79660. */
  79661. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79662. /**
  79663. * Checks if the submesh intersects with a ray
  79664. * @param ray defines the ray to test
  79665. * @returns true is the passed ray intersects the submesh bounding box
  79666. */
  79667. canIntersects(ray: Ray): boolean;
  79668. /**
  79669. * Intersects current submesh with a ray
  79670. * @param ray defines the ray to test
  79671. * @param positions defines mesh's positions array
  79672. * @param indices defines mesh's indices array
  79673. * @param fastCheck defines if only bounding info should be used
  79674. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79675. * @returns intersection info or null if no intersection
  79676. */
  79677. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79678. /** @hidden */
  79679. private _intersectLines;
  79680. /** @hidden */
  79681. private _intersectTriangles;
  79682. /** @hidden */
  79683. _rebuild(): void;
  79684. /**
  79685. * Creates a new submesh from the passed mesh
  79686. * @param newMesh defines the new hosting mesh
  79687. * @param newRenderingMesh defines an optional rendering mesh
  79688. * @returns the new submesh
  79689. */
  79690. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79691. /**
  79692. * Release associated resources
  79693. */
  79694. dispose(): void;
  79695. /**
  79696. * Gets the class name
  79697. * @returns the string "SubMesh".
  79698. */
  79699. getClassName(): string;
  79700. /**
  79701. * Creates a new submesh from indices data
  79702. * @param materialIndex the index of the main mesh material
  79703. * @param startIndex the index where to start the copy in the mesh indices array
  79704. * @param indexCount the number of indices to copy then from the startIndex
  79705. * @param mesh the main mesh to create the submesh from
  79706. * @param renderingMesh the optional rendering mesh
  79707. * @returns a new submesh
  79708. */
  79709. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79710. }
  79711. }
  79712. declare module BABYLON {
  79713. /**
  79714. * Class used to store geometry data (vertex buffers + index buffer)
  79715. */
  79716. export class Geometry implements IGetSetVerticesData {
  79717. /**
  79718. * Gets or sets the ID of the geometry
  79719. */
  79720. id: string;
  79721. /**
  79722. * Gets or sets the unique ID of the geometry
  79723. */
  79724. uniqueId: number;
  79725. /**
  79726. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79727. */
  79728. delayLoadState: number;
  79729. /**
  79730. * Gets the file containing the data to load when running in delay load state
  79731. */
  79732. delayLoadingFile: Nullable<string>;
  79733. /**
  79734. * Callback called when the geometry is updated
  79735. */
  79736. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79737. private _scene;
  79738. private _engine;
  79739. private _meshes;
  79740. private _totalVertices;
  79741. /** @hidden */
  79742. _indices: IndicesArray;
  79743. /** @hidden */
  79744. _vertexBuffers: {
  79745. [key: string]: VertexBuffer;
  79746. };
  79747. private _isDisposed;
  79748. private _extend;
  79749. private _boundingBias;
  79750. /** @hidden */
  79751. _delayInfo: Array<string>;
  79752. private _indexBuffer;
  79753. private _indexBufferIsUpdatable;
  79754. /** @hidden */
  79755. _boundingInfo: Nullable<BoundingInfo>;
  79756. /** @hidden */
  79757. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79758. /** @hidden */
  79759. _softwareSkinningFrameId: number;
  79760. private _vertexArrayObjects;
  79761. private _updatable;
  79762. /** @hidden */
  79763. _positions: Nullable<Vector3[]>;
  79764. /**
  79765. * 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
  79766. */
  79767. /**
  79768. * 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
  79769. */
  79770. boundingBias: Vector2;
  79771. /**
  79772. * Static function used to attach a new empty geometry to a mesh
  79773. * @param mesh defines the mesh to attach the geometry to
  79774. * @returns the new Geometry
  79775. */
  79776. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79777. /**
  79778. * Creates a new geometry
  79779. * @param id defines the unique ID
  79780. * @param scene defines the hosting scene
  79781. * @param vertexData defines the VertexData used to get geometry data
  79782. * @param updatable defines if geometry must be updatable (false by default)
  79783. * @param mesh defines the mesh that will be associated with the geometry
  79784. */
  79785. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79786. /**
  79787. * Gets the current extend of the geometry
  79788. */
  79789. readonly extend: {
  79790. minimum: Vector3;
  79791. maximum: Vector3;
  79792. };
  79793. /**
  79794. * Gets the hosting scene
  79795. * @returns the hosting Scene
  79796. */
  79797. getScene(): Scene;
  79798. /**
  79799. * Gets the hosting engine
  79800. * @returns the hosting Engine
  79801. */
  79802. getEngine(): Engine;
  79803. /**
  79804. * Defines if the geometry is ready to use
  79805. * @returns true if the geometry is ready to be used
  79806. */
  79807. isReady(): boolean;
  79808. /**
  79809. * Gets a value indicating that the geometry should not be serialized
  79810. */
  79811. readonly doNotSerialize: boolean;
  79812. /** @hidden */
  79813. _rebuild(): void;
  79814. /**
  79815. * Affects all geometry data in one call
  79816. * @param vertexData defines the geometry data
  79817. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79818. */
  79819. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79820. /**
  79821. * Set specific vertex data
  79822. * @param kind defines the data kind (Position, normal, etc...)
  79823. * @param data defines the vertex data to use
  79824. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79825. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79826. */
  79827. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79828. /**
  79829. * Removes a specific vertex data
  79830. * @param kind defines the data kind (Position, normal, etc...)
  79831. */
  79832. removeVerticesData(kind: string): void;
  79833. /**
  79834. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79835. * @param buffer defines the vertex buffer to use
  79836. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79837. */
  79838. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79839. /**
  79840. * Update a specific vertex buffer
  79841. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79842. * It will do nothing if the buffer is not updatable
  79843. * @param kind defines the data kind (Position, normal, etc...)
  79844. * @param data defines the data to use
  79845. * @param offset defines the offset in the target buffer where to store the data
  79846. * @param useBytes set to true if the offset is in bytes
  79847. */
  79848. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79849. /**
  79850. * Update a specific vertex buffer
  79851. * This function will create a new buffer if the current one is not updatable
  79852. * @param kind defines the data kind (Position, normal, etc...)
  79853. * @param data defines the data to use
  79854. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79855. */
  79856. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79857. private _updateBoundingInfo;
  79858. /** @hidden */
  79859. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79860. /**
  79861. * Gets total number of vertices
  79862. * @returns the total number of vertices
  79863. */
  79864. getTotalVertices(): number;
  79865. /**
  79866. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79867. * @param kind defines the data kind (Position, normal, etc...)
  79868. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79869. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79870. * @returns a float array containing vertex data
  79871. */
  79872. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79873. /**
  79874. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79875. * @param kind defines the data kind (Position, normal, etc...)
  79876. * @returns true if the vertex buffer with the specified kind is updatable
  79877. */
  79878. isVertexBufferUpdatable(kind: string): boolean;
  79879. /**
  79880. * Gets a specific vertex buffer
  79881. * @param kind defines the data kind (Position, normal, etc...)
  79882. * @returns a VertexBuffer
  79883. */
  79884. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79885. /**
  79886. * Returns all vertex buffers
  79887. * @return an object holding all vertex buffers indexed by kind
  79888. */
  79889. getVertexBuffers(): Nullable<{
  79890. [key: string]: VertexBuffer;
  79891. }>;
  79892. /**
  79893. * Gets a boolean indicating if specific vertex buffer is present
  79894. * @param kind defines the data kind (Position, normal, etc...)
  79895. * @returns true if data is present
  79896. */
  79897. isVerticesDataPresent(kind: string): boolean;
  79898. /**
  79899. * Gets a list of all attached data kinds (Position, normal, etc...)
  79900. * @returns a list of string containing all kinds
  79901. */
  79902. getVerticesDataKinds(): string[];
  79903. /**
  79904. * Update index buffer
  79905. * @param indices defines the indices to store in the index buffer
  79906. * @param offset defines the offset in the target buffer where to store the data
  79907. * @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)
  79908. */
  79909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79910. /**
  79911. * Creates a new index buffer
  79912. * @param indices defines the indices to store in the index buffer
  79913. * @param totalVertices defines the total number of vertices (could be null)
  79914. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79915. */
  79916. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79917. /**
  79918. * Return the total number of indices
  79919. * @returns the total number of indices
  79920. */
  79921. getTotalIndices(): number;
  79922. /**
  79923. * Gets the index buffer array
  79924. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79925. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79926. * @returns the index buffer array
  79927. */
  79928. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79929. /**
  79930. * Gets the index buffer
  79931. * @return the index buffer
  79932. */
  79933. getIndexBuffer(): Nullable<WebGLBuffer>;
  79934. /** @hidden */
  79935. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79936. /**
  79937. * Release the associated resources for a specific mesh
  79938. * @param mesh defines the source mesh
  79939. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79940. */
  79941. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79942. /**
  79943. * Apply current geometry to a given mesh
  79944. * @param mesh defines the mesh to apply geometry to
  79945. */
  79946. applyToMesh(mesh: Mesh): void;
  79947. private _updateExtend;
  79948. private _applyToMesh;
  79949. private notifyUpdate;
  79950. /**
  79951. * Load the geometry if it was flagged as delay loaded
  79952. * @param scene defines the hosting scene
  79953. * @param onLoaded defines a callback called when the geometry is loaded
  79954. */
  79955. load(scene: Scene, onLoaded?: () => void): void;
  79956. private _queueLoad;
  79957. /**
  79958. * Invert the geometry to move from a right handed system to a left handed one.
  79959. */
  79960. toLeftHanded(): void;
  79961. /** @hidden */
  79962. _resetPointsArrayCache(): void;
  79963. /** @hidden */
  79964. _generatePointsArray(): boolean;
  79965. /**
  79966. * Gets a value indicating if the geometry is disposed
  79967. * @returns true if the geometry was disposed
  79968. */
  79969. isDisposed(): boolean;
  79970. private _disposeVertexArrayObjects;
  79971. /**
  79972. * Free all associated resources
  79973. */
  79974. dispose(): void;
  79975. /**
  79976. * Clone the current geometry into a new geometry
  79977. * @param id defines the unique ID of the new geometry
  79978. * @returns a new geometry object
  79979. */
  79980. copy(id: string): Geometry;
  79981. /**
  79982. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79983. * @return a JSON representation of the current geometry data (without the vertices data)
  79984. */
  79985. serialize(): any;
  79986. private toNumberArray;
  79987. /**
  79988. * Serialize all vertices data into a JSON oject
  79989. * @returns a JSON representation of the current geometry data
  79990. */
  79991. serializeVerticeData(): any;
  79992. /**
  79993. * Extracts a clone of a mesh geometry
  79994. * @param mesh defines the source mesh
  79995. * @param id defines the unique ID of the new geometry object
  79996. * @returns the new geometry object
  79997. */
  79998. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79999. /**
  80000. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80001. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80002. * Be aware Math.random() could cause collisions, but:
  80003. * "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"
  80004. * @returns a string containing a new GUID
  80005. */
  80006. static RandomId(): string;
  80007. /** @hidden */
  80008. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80009. private static _CleanMatricesWeights;
  80010. /**
  80011. * Create a new geometry from persisted data (Using .babylon file format)
  80012. * @param parsedVertexData defines the persisted data
  80013. * @param scene defines the hosting scene
  80014. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80015. * @returns the new geometry object
  80016. */
  80017. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80018. }
  80019. }
  80020. declare module BABYLON {
  80021. /**
  80022. * Define an interface for all classes that will get and set the data on vertices
  80023. */
  80024. export interface IGetSetVerticesData {
  80025. /**
  80026. * Gets a boolean indicating if specific vertex data is present
  80027. * @param kind defines the vertex data kind to use
  80028. * @returns true is data kind is present
  80029. */
  80030. isVerticesDataPresent(kind: string): boolean;
  80031. /**
  80032. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80033. * @param kind defines the data kind (Position, normal, etc...)
  80034. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80035. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80036. * @returns a float array containing vertex data
  80037. */
  80038. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80039. /**
  80040. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80041. * @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.
  80042. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80043. * @returns the indices array or an empty array if the mesh has no geometry
  80044. */
  80045. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80046. /**
  80047. * Set specific vertex data
  80048. * @param kind defines the data kind (Position, normal, etc...)
  80049. * @param data defines the vertex data to use
  80050. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80051. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80052. */
  80053. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80054. /**
  80055. * Update a specific associated vertex buffer
  80056. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80057. * - VertexBuffer.PositionKind
  80058. * - VertexBuffer.UVKind
  80059. * - VertexBuffer.UV2Kind
  80060. * - VertexBuffer.UV3Kind
  80061. * - VertexBuffer.UV4Kind
  80062. * - VertexBuffer.UV5Kind
  80063. * - VertexBuffer.UV6Kind
  80064. * - VertexBuffer.ColorKind
  80065. * - VertexBuffer.MatricesIndicesKind
  80066. * - VertexBuffer.MatricesIndicesExtraKind
  80067. * - VertexBuffer.MatricesWeightsKind
  80068. * - VertexBuffer.MatricesWeightsExtraKind
  80069. * @param data defines the data source
  80070. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80071. * @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)
  80072. */
  80073. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80074. /**
  80075. * Creates a new index buffer
  80076. * @param indices defines the indices to store in the index buffer
  80077. * @param totalVertices defines the total number of vertices (could be null)
  80078. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80079. */
  80080. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80081. }
  80082. /**
  80083. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  80084. */
  80085. export class VertexData {
  80086. /**
  80087. * Mesh side orientation : usually the external or front surface
  80088. */
  80089. static readonly FRONTSIDE: number;
  80090. /**
  80091. * Mesh side orientation : usually the internal or back surface
  80092. */
  80093. static readonly BACKSIDE: number;
  80094. /**
  80095. * Mesh side orientation : both internal and external or front and back surfaces
  80096. */
  80097. static readonly DOUBLESIDE: number;
  80098. /**
  80099. * Mesh side orientation : by default, `FRONTSIDE`
  80100. */
  80101. static readonly DEFAULTSIDE: number;
  80102. /**
  80103. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  80104. */
  80105. positions: Nullable<FloatArray>;
  80106. /**
  80107. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  80108. */
  80109. normals: Nullable<FloatArray>;
  80110. /**
  80111. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  80112. */
  80113. tangents: Nullable<FloatArray>;
  80114. /**
  80115. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80116. */
  80117. uvs: Nullable<FloatArray>;
  80118. /**
  80119. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80120. */
  80121. uvs2: Nullable<FloatArray>;
  80122. /**
  80123. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80124. */
  80125. uvs3: Nullable<FloatArray>;
  80126. /**
  80127. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80128. */
  80129. uvs4: Nullable<FloatArray>;
  80130. /**
  80131. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80132. */
  80133. uvs5: Nullable<FloatArray>;
  80134. /**
  80135. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80136. */
  80137. uvs6: Nullable<FloatArray>;
  80138. /**
  80139. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80140. */
  80141. colors: Nullable<FloatArray>;
  80142. /**
  80143. * 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).
  80144. */
  80145. matricesIndices: Nullable<FloatArray>;
  80146. /**
  80147. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80148. */
  80149. matricesWeights: Nullable<FloatArray>;
  80150. /**
  80151. * An array extending the number of possible indices
  80152. */
  80153. matricesIndicesExtra: Nullable<FloatArray>;
  80154. /**
  80155. * An array extending the number of possible weights when the number of indices is extended
  80156. */
  80157. matricesWeightsExtra: Nullable<FloatArray>;
  80158. /**
  80159. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80160. */
  80161. indices: Nullable<IndicesArray>;
  80162. /**
  80163. * Uses the passed data array to set the set the values for the specified kind of data
  80164. * @param data a linear array of floating numbers
  80165. * @param kind the type of data that is being set, eg positions, colors etc
  80166. */
  80167. set(data: FloatArray, kind: string): void;
  80168. /**
  80169. * Associates the vertexData to the passed Mesh.
  80170. * Sets it as updatable or not (default `false`)
  80171. * @param mesh the mesh the vertexData is applied to
  80172. * @param updatable when used and having the value true allows new data to update the vertexData
  80173. * @returns the VertexData
  80174. */
  80175. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80176. /**
  80177. * Associates the vertexData to the passed Geometry.
  80178. * Sets it as updatable or not (default `false`)
  80179. * @param geometry the geometry the vertexData is applied to
  80180. * @param updatable when used and having the value true allows new data to update the vertexData
  80181. * @returns VertexData
  80182. */
  80183. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80184. /**
  80185. * Updates the associated mesh
  80186. * @param mesh the mesh to be updated
  80187. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80188. * @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
  80189. * @returns VertexData
  80190. */
  80191. updateMesh(mesh: Mesh): VertexData;
  80192. /**
  80193. * Updates the associated geometry
  80194. * @param geometry the geometry to be updated
  80195. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80196. * @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
  80197. * @returns VertexData.
  80198. */
  80199. updateGeometry(geometry: Geometry): VertexData;
  80200. private _applyTo;
  80201. private _update;
  80202. /**
  80203. * Transforms each position and each normal of the vertexData according to the passed Matrix
  80204. * @param matrix the transforming matrix
  80205. * @returns the VertexData
  80206. */
  80207. transform(matrix: Matrix): VertexData;
  80208. /**
  80209. * Merges the passed VertexData into the current one
  80210. * @param other the VertexData to be merged into the current one
  80211. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  80212. * @returns the modified VertexData
  80213. */
  80214. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  80215. private _mergeElement;
  80216. private _validate;
  80217. /**
  80218. * Serializes the VertexData
  80219. * @returns a serialized object
  80220. */
  80221. serialize(): any;
  80222. /**
  80223. * Extracts the vertexData from a mesh
  80224. * @param mesh the mesh from which to extract the VertexData
  80225. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  80226. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80227. * @returns the object VertexData associated to the passed mesh
  80228. */
  80229. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80230. /**
  80231. * Extracts the vertexData from the geometry
  80232. * @param geometry the geometry from which to extract the VertexData
  80233. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  80234. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80235. * @returns the object VertexData associated to the passed mesh
  80236. */
  80237. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80238. private static _ExtractFrom;
  80239. /**
  80240. * Creates the VertexData for a Ribbon
  80241. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  80242. * * pathArray array of paths, each of which an array of successive Vector3
  80243. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  80244. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  80245. * * 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
  80246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80247. * * 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)
  80248. * * 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)
  80249. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  80250. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  80251. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  80252. * @returns the VertexData of the ribbon
  80253. */
  80254. static CreateRibbon(options: {
  80255. pathArray: Vector3[][];
  80256. closeArray?: boolean;
  80257. closePath?: boolean;
  80258. offset?: number;
  80259. sideOrientation?: number;
  80260. frontUVs?: Vector4;
  80261. backUVs?: Vector4;
  80262. invertUV?: boolean;
  80263. uvs?: Vector2[];
  80264. colors?: Color4[];
  80265. }): VertexData;
  80266. /**
  80267. * Creates the VertexData for a box
  80268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80269. * * size sets the width, height and depth of the box to the value of size, optional default 1
  80270. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  80271. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  80272. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  80273. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  80274. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  80275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80276. * * 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)
  80277. * * 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)
  80278. * @returns the VertexData of the box
  80279. */
  80280. static CreateBox(options: {
  80281. size?: number;
  80282. width?: number;
  80283. height?: number;
  80284. depth?: number;
  80285. faceUV?: Vector4[];
  80286. faceColors?: Color4[];
  80287. sideOrientation?: number;
  80288. frontUVs?: Vector4;
  80289. backUVs?: Vector4;
  80290. }): VertexData;
  80291. /**
  80292. * Creates the VertexData for an ellipsoid, defaults to a sphere
  80293. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80294. * * segments sets the number of horizontal strips optional, default 32
  80295. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  80296. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  80297. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  80298. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  80299. * * 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
  80300. * * 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
  80301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80302. * * 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)
  80303. * * 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)
  80304. * @returns the VertexData of the ellipsoid
  80305. */
  80306. static CreateSphere(options: {
  80307. segments?: number;
  80308. diameter?: number;
  80309. diameterX?: number;
  80310. diameterY?: number;
  80311. diameterZ?: number;
  80312. arc?: number;
  80313. slice?: number;
  80314. sideOrientation?: number;
  80315. frontUVs?: Vector4;
  80316. backUVs?: Vector4;
  80317. }): VertexData;
  80318. /**
  80319. * Creates the VertexData for a cylinder, cone or prism
  80320. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80321. * * height sets the height (y direction) of the cylinder, optional, default 2
  80322. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  80323. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  80324. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  80325. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80326. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  80327. * * 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
  80328. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80329. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80330. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  80331. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  80332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80333. * * 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)
  80334. * * 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)
  80335. * @returns the VertexData of the cylinder, cone or prism
  80336. */
  80337. static CreateCylinder(options: {
  80338. height?: number;
  80339. diameterTop?: number;
  80340. diameterBottom?: number;
  80341. diameter?: number;
  80342. tessellation?: number;
  80343. subdivisions?: number;
  80344. arc?: number;
  80345. faceColors?: Color4[];
  80346. faceUV?: Vector4[];
  80347. hasRings?: boolean;
  80348. enclose?: boolean;
  80349. sideOrientation?: number;
  80350. frontUVs?: Vector4;
  80351. backUVs?: Vector4;
  80352. }): VertexData;
  80353. /**
  80354. * Creates the VertexData for a torus
  80355. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80356. * * diameter the diameter of the torus, optional default 1
  80357. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80358. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80360. * * 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)
  80361. * * 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)
  80362. * @returns the VertexData of the torus
  80363. */
  80364. static CreateTorus(options: {
  80365. diameter?: number;
  80366. thickness?: number;
  80367. tessellation?: number;
  80368. sideOrientation?: number;
  80369. frontUVs?: Vector4;
  80370. backUVs?: Vector4;
  80371. }): VertexData;
  80372. /**
  80373. * Creates the VertexData of the LineSystem
  80374. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80375. * - lines an array of lines, each line being an array of successive Vector3
  80376. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80377. * @returns the VertexData of the LineSystem
  80378. */
  80379. static CreateLineSystem(options: {
  80380. lines: Vector3[][];
  80381. colors?: Nullable<Color4[][]>;
  80382. }): VertexData;
  80383. /**
  80384. * Create the VertexData for a DashedLines
  80385. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80386. * - points an array successive Vector3
  80387. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80388. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80389. * - dashNb the intended total number of dashes, optional, default 200
  80390. * @returns the VertexData for the DashedLines
  80391. */
  80392. static CreateDashedLines(options: {
  80393. points: Vector3[];
  80394. dashSize?: number;
  80395. gapSize?: number;
  80396. dashNb?: number;
  80397. }): VertexData;
  80398. /**
  80399. * Creates the VertexData for a Ground
  80400. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80401. * - width the width (x direction) of the ground, optional, default 1
  80402. * - height the height (z direction) of the ground, optional, default 1
  80403. * - subdivisions the number of subdivisions per side, optional, default 1
  80404. * @returns the VertexData of the Ground
  80405. */
  80406. static CreateGround(options: {
  80407. width?: number;
  80408. height?: number;
  80409. subdivisions?: number;
  80410. subdivisionsX?: number;
  80411. subdivisionsY?: number;
  80412. }): VertexData;
  80413. /**
  80414. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80415. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80416. * * xmin the ground minimum X coordinate, optional, default -1
  80417. * * zmin the ground minimum Z coordinate, optional, default -1
  80418. * * xmax the ground maximum X coordinate, optional, default 1
  80419. * * zmax the ground maximum Z coordinate, optional, default 1
  80420. * * 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}
  80421. * * 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}
  80422. * @returns the VertexData of the TiledGround
  80423. */
  80424. static CreateTiledGround(options: {
  80425. xmin: number;
  80426. zmin: number;
  80427. xmax: number;
  80428. zmax: number;
  80429. subdivisions?: {
  80430. w: number;
  80431. h: number;
  80432. };
  80433. precision?: {
  80434. w: number;
  80435. h: number;
  80436. };
  80437. }): VertexData;
  80438. /**
  80439. * Creates the VertexData of the Ground designed from a heightmap
  80440. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80441. * * width the width (x direction) of the ground
  80442. * * height the height (z direction) of the ground
  80443. * * subdivisions the number of subdivisions per side
  80444. * * minHeight the minimum altitude on the ground, optional, default 0
  80445. * * maxHeight the maximum altitude on the ground, optional default 1
  80446. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80447. * * buffer the array holding the image color data
  80448. * * bufferWidth the width of image
  80449. * * bufferHeight the height of image
  80450. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80451. * @returns the VertexData of the Ground designed from a heightmap
  80452. */
  80453. static CreateGroundFromHeightMap(options: {
  80454. width: number;
  80455. height: number;
  80456. subdivisions: number;
  80457. minHeight: number;
  80458. maxHeight: number;
  80459. colorFilter: Color3;
  80460. buffer: Uint8Array;
  80461. bufferWidth: number;
  80462. bufferHeight: number;
  80463. alphaFilter: number;
  80464. }): VertexData;
  80465. /**
  80466. * Creates the VertexData for a Plane
  80467. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80468. * * size sets the width and height of the plane to the value of size, optional default 1
  80469. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80470. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80472. * * 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)
  80473. * * 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)
  80474. * @returns the VertexData of the box
  80475. */
  80476. static CreatePlane(options: {
  80477. size?: number;
  80478. width?: number;
  80479. height?: number;
  80480. sideOrientation?: number;
  80481. frontUVs?: Vector4;
  80482. backUVs?: Vector4;
  80483. }): VertexData;
  80484. /**
  80485. * Creates the VertexData of the Disc or regular Polygon
  80486. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80487. * * radius the radius of the disc, optional default 0.5
  80488. * * tessellation the number of polygon sides, optional, default 64
  80489. * * 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
  80490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80491. * * 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)
  80492. * * 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)
  80493. * @returns the VertexData of the box
  80494. */
  80495. static CreateDisc(options: {
  80496. radius?: number;
  80497. tessellation?: number;
  80498. arc?: number;
  80499. sideOrientation?: number;
  80500. frontUVs?: Vector4;
  80501. backUVs?: Vector4;
  80502. }): VertexData;
  80503. /**
  80504. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80505. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80506. * @param polygon a mesh built from polygonTriangulation.build()
  80507. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80508. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80509. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80510. * @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)
  80511. * @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)
  80512. * @returns the VertexData of the Polygon
  80513. */
  80514. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80515. /**
  80516. * Creates the VertexData of the IcoSphere
  80517. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80518. * * radius the radius of the IcoSphere, optional default 1
  80519. * * radiusX allows stretching in the x direction, optional, default radius
  80520. * * radiusY allows stretching in the y direction, optional, default radius
  80521. * * radiusZ allows stretching in the z direction, optional, default radius
  80522. * * flat when true creates a flat shaded mesh, optional, default true
  80523. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80525. * * 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)
  80526. * * 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)
  80527. * @returns the VertexData of the IcoSphere
  80528. */
  80529. static CreateIcoSphere(options: {
  80530. radius?: number;
  80531. radiusX?: number;
  80532. radiusY?: number;
  80533. radiusZ?: number;
  80534. flat?: boolean;
  80535. subdivisions?: number;
  80536. sideOrientation?: number;
  80537. frontUVs?: Vector4;
  80538. backUVs?: Vector4;
  80539. }): VertexData;
  80540. /**
  80541. * Creates the VertexData for a Polyhedron
  80542. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80543. * * type provided types are:
  80544. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80545. * * 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)
  80546. * * size the size of the IcoSphere, optional default 1
  80547. * * sizeX allows stretching in the x direction, optional, default size
  80548. * * sizeY allows stretching in the y direction, optional, default size
  80549. * * sizeZ allows stretching in the z direction, optional, default size
  80550. * * 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
  80551. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80552. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80553. * * flat when true creates a flat shaded mesh, optional, default true
  80554. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80556. * * 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)
  80557. * * 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)
  80558. * @returns the VertexData of the Polyhedron
  80559. */
  80560. static CreatePolyhedron(options: {
  80561. type?: number;
  80562. size?: number;
  80563. sizeX?: number;
  80564. sizeY?: number;
  80565. sizeZ?: number;
  80566. custom?: any;
  80567. faceUV?: Vector4[];
  80568. faceColors?: Color4[];
  80569. flat?: boolean;
  80570. sideOrientation?: number;
  80571. frontUVs?: Vector4;
  80572. backUVs?: Vector4;
  80573. }): VertexData;
  80574. /**
  80575. * Creates the VertexData for a TorusKnot
  80576. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80577. * * radius the radius of the torus knot, optional, default 2
  80578. * * tube the thickness of the tube, optional, default 0.5
  80579. * * radialSegments the number of sides on each tube segments, optional, default 32
  80580. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80581. * * p the number of windings around the z axis, optional, default 2
  80582. * * q the number of windings around the x axis, optional, default 3
  80583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80584. * * 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)
  80585. * * 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)
  80586. * @returns the VertexData of the Torus Knot
  80587. */
  80588. static CreateTorusKnot(options: {
  80589. radius?: number;
  80590. tube?: number;
  80591. radialSegments?: number;
  80592. tubularSegments?: number;
  80593. p?: number;
  80594. q?: number;
  80595. sideOrientation?: number;
  80596. frontUVs?: Vector4;
  80597. backUVs?: Vector4;
  80598. }): VertexData;
  80599. /**
  80600. * Compute normals for given positions and indices
  80601. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80602. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80603. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80604. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80605. * * facetNormals : optional array of facet normals (vector3)
  80606. * * facetPositions : optional array of facet positions (vector3)
  80607. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80608. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80609. * * bInfo : optional bounding info, required for facetPartitioning computation
  80610. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80611. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80612. * * useRightHandedSystem: optional boolean to for right handed system computation
  80613. * * depthSort : optional boolean to enable the facet depth sort computation
  80614. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80615. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80616. */
  80617. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80618. facetNormals?: any;
  80619. facetPositions?: any;
  80620. facetPartitioning?: any;
  80621. ratio?: number;
  80622. bInfo?: any;
  80623. bbSize?: Vector3;
  80624. subDiv?: any;
  80625. useRightHandedSystem?: boolean;
  80626. depthSort?: boolean;
  80627. distanceTo?: Vector3;
  80628. depthSortedFacets?: any;
  80629. }): void;
  80630. /** @hidden */
  80631. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80632. /**
  80633. * Applies VertexData created from the imported parameters to the geometry
  80634. * @param parsedVertexData the parsed data from an imported file
  80635. * @param geometry the geometry to apply the VertexData to
  80636. */
  80637. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80638. }
  80639. }
  80640. declare module BABYLON {
  80641. /**
  80642. * Class containing static functions to help procedurally build meshes
  80643. */
  80644. export class DiscBuilder {
  80645. /**
  80646. * Creates a plane polygonal mesh. By default, this is a disc
  80647. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80648. * * 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
  80649. * * 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
  80650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80653. * @param name defines the name of the mesh
  80654. * @param options defines the options used to create the mesh
  80655. * @param scene defines the hosting scene
  80656. * @returns the plane polygonal mesh
  80657. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80658. */
  80659. static CreateDisc(name: string, options: {
  80660. radius?: number;
  80661. tessellation?: number;
  80662. arc?: number;
  80663. updatable?: boolean;
  80664. sideOrientation?: number;
  80665. frontUVs?: Vector4;
  80666. backUVs?: Vector4;
  80667. }, scene?: Nullable<Scene>): Mesh;
  80668. }
  80669. }
  80670. declare module BABYLON {
  80671. /**
  80672. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80673. *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.
  80674. * The SPS is also a particle system. It provides some methods to manage the particles.
  80675. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80676. *
  80677. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80678. */
  80679. export class SolidParticleSystem implements IDisposable {
  80680. /**
  80681. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80682. * Example : var p = SPS.particles[i];
  80683. */
  80684. particles: SolidParticle[];
  80685. /**
  80686. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80687. */
  80688. nbParticles: number;
  80689. /**
  80690. * If the particles must ever face the camera (default false). Useful for planar particles.
  80691. */
  80692. billboard: boolean;
  80693. /**
  80694. * Recompute normals when adding a shape
  80695. */
  80696. recomputeNormals: boolean;
  80697. /**
  80698. * This a counter ofr your own usage. It's not set by any SPS functions.
  80699. */
  80700. counter: number;
  80701. /**
  80702. * The SPS name. This name is also given to the underlying mesh.
  80703. */
  80704. name: string;
  80705. /**
  80706. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80707. */
  80708. mesh: Mesh;
  80709. /**
  80710. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80711. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80712. */
  80713. vars: any;
  80714. /**
  80715. * This array is populated when the SPS is set as 'pickable'.
  80716. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80717. * Each element of this array is an object `{idx: int, faceId: int}`.
  80718. * `idx` is the picked particle index in the `SPS.particles` array
  80719. * `faceId` is the picked face index counted within this particle.
  80720. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80721. */
  80722. pickedParticles: {
  80723. idx: number;
  80724. faceId: number;
  80725. }[];
  80726. /**
  80727. * This array is populated when `enableDepthSort` is set to true.
  80728. * Each element of this array is an instance of the class DepthSortedParticle.
  80729. */
  80730. depthSortedParticles: DepthSortedParticle[];
  80731. /**
  80732. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80733. * @hidden
  80734. */
  80735. _bSphereOnly: boolean;
  80736. /**
  80737. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80738. * @hidden
  80739. */
  80740. _bSphereRadiusFactor: number;
  80741. private _scene;
  80742. private _positions;
  80743. private _indices;
  80744. private _normals;
  80745. private _colors;
  80746. private _uvs;
  80747. private _indices32;
  80748. private _positions32;
  80749. private _normals32;
  80750. private _fixedNormal32;
  80751. private _colors32;
  80752. private _uvs32;
  80753. private _index;
  80754. private _updatable;
  80755. private _pickable;
  80756. private _isVisibilityBoxLocked;
  80757. private _alwaysVisible;
  80758. private _depthSort;
  80759. private _shapeCounter;
  80760. private _copy;
  80761. private _color;
  80762. private _computeParticleColor;
  80763. private _computeParticleTexture;
  80764. private _computeParticleRotation;
  80765. private _computeParticleVertex;
  80766. private _computeBoundingBox;
  80767. private _depthSortParticles;
  80768. private _camera;
  80769. private _mustUnrotateFixedNormals;
  80770. private _particlesIntersect;
  80771. private _needs32Bits;
  80772. /**
  80773. * Creates a SPS (Solid Particle System) object.
  80774. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80775. * @param scene (Scene) is the scene in which the SPS is added.
  80776. * @param options defines the options of the sps e.g.
  80777. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80778. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80779. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80780. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80781. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80782. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80783. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80784. */
  80785. constructor(name: string, scene: Scene, options?: {
  80786. updatable?: boolean;
  80787. isPickable?: boolean;
  80788. enableDepthSort?: boolean;
  80789. particleIntersection?: boolean;
  80790. boundingSphereOnly?: boolean;
  80791. bSphereRadiusFactor?: number;
  80792. });
  80793. /**
  80794. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80795. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80796. * @returns the created mesh
  80797. */
  80798. buildMesh(): Mesh;
  80799. /**
  80800. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80801. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80802. * Thus the particles generated from `digest()` have their property `position` set yet.
  80803. * @param mesh ( Mesh ) is the mesh to be digested
  80804. * @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
  80805. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80806. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80807. * @returns the current SPS
  80808. */
  80809. digest(mesh: Mesh, options?: {
  80810. facetNb?: number;
  80811. number?: number;
  80812. delta?: number;
  80813. }): SolidParticleSystem;
  80814. private _unrotateFixedNormals;
  80815. private _resetCopy;
  80816. private _meshBuilder;
  80817. private _posToShape;
  80818. private _uvsToShapeUV;
  80819. private _addParticle;
  80820. /**
  80821. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80822. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80823. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80824. * @param nb (positive integer) the number of particles to be created from this model
  80825. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80826. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80827. * @returns the number of shapes in the system
  80828. */
  80829. addShape(mesh: Mesh, nb: number, options?: {
  80830. positionFunction?: any;
  80831. vertexFunction?: any;
  80832. }): number;
  80833. private _rebuildParticle;
  80834. /**
  80835. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80836. * @returns the SPS.
  80837. */
  80838. rebuildMesh(): SolidParticleSystem;
  80839. /**
  80840. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80841. * This method calls `updateParticle()` for each particle of the SPS.
  80842. * For an animated SPS, it is usually called within the render loop.
  80843. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80844. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80845. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80846. * @returns the SPS.
  80847. */
  80848. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80849. /**
  80850. * Disposes the SPS.
  80851. */
  80852. dispose(): void;
  80853. /**
  80854. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80856. * @returns the SPS.
  80857. */
  80858. refreshVisibleSize(): SolidParticleSystem;
  80859. /**
  80860. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80861. * @param size the size (float) of the visibility box
  80862. * note : this doesn't lock the SPS mesh bounding box.
  80863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80864. */
  80865. setVisibilityBox(size: number): void;
  80866. /**
  80867. * Gets whether the SPS as always visible or not
  80868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80869. */
  80870. /**
  80871. * Sets the SPS as always visible or not
  80872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80873. */
  80874. isAlwaysVisible: boolean;
  80875. /**
  80876. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80877. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80878. */
  80879. /**
  80880. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80882. */
  80883. isVisibilityBoxLocked: boolean;
  80884. /**
  80885. * Tells to `setParticles()` to compute the particle rotations or not.
  80886. * Default value : true. The SPS is faster when it's set to false.
  80887. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80888. */
  80889. /**
  80890. * Gets if `setParticles()` computes the particle rotations or not.
  80891. * Default value : true. The SPS is faster when it's set to false.
  80892. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80893. */
  80894. computeParticleRotation: boolean;
  80895. /**
  80896. * Tells to `setParticles()` to compute the particle colors or not.
  80897. * Default value : true. The SPS is faster when it's set to false.
  80898. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80899. */
  80900. /**
  80901. * Gets if `setParticles()` computes the particle colors or not.
  80902. * Default value : true. The SPS is faster when it's set to false.
  80903. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80904. */
  80905. computeParticleColor: boolean;
  80906. /**
  80907. * Gets if `setParticles()` computes the particle textures or not.
  80908. * Default value : true. The SPS is faster when it's set to false.
  80909. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80910. */
  80911. computeParticleTexture: boolean;
  80912. /**
  80913. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80914. * Default value : false. The SPS is faster when it's set to false.
  80915. * Note : the particle custom vertex positions aren't stored values.
  80916. */
  80917. /**
  80918. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80919. * Default value : false. The SPS is faster when it's set to false.
  80920. * Note : the particle custom vertex positions aren't stored values.
  80921. */
  80922. computeParticleVertex: boolean;
  80923. /**
  80924. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80925. */
  80926. /**
  80927. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80928. */
  80929. computeBoundingBox: boolean;
  80930. /**
  80931. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80932. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80933. * Default : `true`
  80934. */
  80935. /**
  80936. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80937. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80938. * Default : `true`
  80939. */
  80940. depthSortParticles: boolean;
  80941. /**
  80942. * This function does nothing. It may be overwritten to set all the particle first values.
  80943. * The SPS doesn't call this function, you may have to call it by your own.
  80944. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80945. */
  80946. initParticles(): void;
  80947. /**
  80948. * This function does nothing. It may be overwritten to recycle a particle.
  80949. * The SPS doesn't call this function, you may have to call it by your own.
  80950. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80951. * @param particle The particle to recycle
  80952. * @returns the recycled particle
  80953. */
  80954. recycleParticle(particle: SolidParticle): SolidParticle;
  80955. /**
  80956. * Updates a particle : this function should be overwritten by the user.
  80957. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80958. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80959. * @example : just set a particle position or velocity and recycle conditions
  80960. * @param particle The particle to update
  80961. * @returns the updated particle
  80962. */
  80963. updateParticle(particle: SolidParticle): SolidParticle;
  80964. /**
  80965. * Updates a vertex of a particle : it can be overwritten by the user.
  80966. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80967. * @param particle the current particle
  80968. * @param vertex the current index of the current particle
  80969. * @param pt the index of the current vertex in the particle shape
  80970. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80971. * @example : just set a vertex particle position
  80972. * @returns the updated vertex
  80973. */
  80974. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80975. /**
  80976. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80977. * This does nothing and may be overwritten by the user.
  80978. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80979. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80980. * @param update the boolean update value actually passed to setParticles()
  80981. */
  80982. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80983. /**
  80984. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80985. * This will be passed three parameters.
  80986. * This does nothing and may be overwritten by the user.
  80987. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80988. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80989. * @param update the boolean update value actually passed to setParticles()
  80990. */
  80991. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80992. }
  80993. }
  80994. declare module BABYLON {
  80995. /**
  80996. * Represents one particle of a solid particle system.
  80997. */
  80998. export class SolidParticle {
  80999. /**
  81000. * particle global index
  81001. */
  81002. idx: number;
  81003. /**
  81004. * The color of the particle
  81005. */
  81006. color: Nullable<Color4>;
  81007. /**
  81008. * The world space position of the particle.
  81009. */
  81010. position: Vector3;
  81011. /**
  81012. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81013. */
  81014. rotation: Vector3;
  81015. /**
  81016. * The world space rotation quaternion of the particle.
  81017. */
  81018. rotationQuaternion: Nullable<Quaternion>;
  81019. /**
  81020. * The scaling of the particle.
  81021. */
  81022. scaling: Vector3;
  81023. /**
  81024. * The uvs of the particle.
  81025. */
  81026. uvs: Vector4;
  81027. /**
  81028. * The current speed of the particle.
  81029. */
  81030. velocity: Vector3;
  81031. /**
  81032. * The pivot point in the particle local space.
  81033. */
  81034. pivot: Vector3;
  81035. /**
  81036. * Must the particle be translated from its pivot point in its local space ?
  81037. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81038. * Default : false
  81039. */
  81040. translateFromPivot: boolean;
  81041. /**
  81042. * Is the particle active or not ?
  81043. */
  81044. alive: boolean;
  81045. /**
  81046. * Is the particle visible or not ?
  81047. */
  81048. isVisible: boolean;
  81049. /**
  81050. * Index of this particle in the global "positions" array (Internal use)
  81051. * @hidden
  81052. */
  81053. _pos: number;
  81054. /**
  81055. * @hidden Index of this particle in the global "indices" array (Internal use)
  81056. */
  81057. _ind: number;
  81058. /**
  81059. * @hidden ModelShape of this particle (Internal use)
  81060. */
  81061. _model: ModelShape;
  81062. /**
  81063. * ModelShape id of this particle
  81064. */
  81065. shapeId: number;
  81066. /**
  81067. * Index of the particle in its shape id (Internal use)
  81068. */
  81069. idxInShape: number;
  81070. /**
  81071. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81072. */
  81073. _modelBoundingInfo: BoundingInfo;
  81074. /**
  81075. * @hidden Particle BoundingInfo object (Internal use)
  81076. */
  81077. _boundingInfo: BoundingInfo;
  81078. /**
  81079. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81080. */
  81081. _sps: SolidParticleSystem;
  81082. /**
  81083. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  81084. */
  81085. _stillInvisible: boolean;
  81086. /**
  81087. * @hidden Last computed particle rotation matrix
  81088. */
  81089. _rotationMatrix: number[];
  81090. /**
  81091. * Parent particle Id, if any.
  81092. * Default null.
  81093. */
  81094. parentId: Nullable<number>;
  81095. /**
  81096. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  81097. * The possible values are :
  81098. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81099. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81100. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81101. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81102. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81103. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  81104. * */
  81105. cullingStrategy: number;
  81106. /**
  81107. * @hidden Internal global position in the SPS.
  81108. */
  81109. _globalPosition: Vector3;
  81110. /**
  81111. * Creates a Solid Particle object.
  81112. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  81113. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  81114. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  81115. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  81116. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  81117. * @param shapeId (integer) is the model shape identifier in the SPS.
  81118. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  81119. * @param sps defines the sps it is associated to
  81120. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81121. */
  81122. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81123. /**
  81124. * Legacy support, changed scale to scaling
  81125. */
  81126. /**
  81127. * Legacy support, changed scale to scaling
  81128. */
  81129. scale: Vector3;
  81130. /**
  81131. * Legacy support, changed quaternion to rotationQuaternion
  81132. */
  81133. /**
  81134. * Legacy support, changed quaternion to rotationQuaternion
  81135. */
  81136. quaternion: Nullable<Quaternion>;
  81137. /**
  81138. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81139. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81140. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81141. * @returns true if it intersects
  81142. */
  81143. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81144. /**
  81145. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81146. * A particle is in the frustum if its bounding box intersects the frustum
  81147. * @param frustumPlanes defines the frustum to test
  81148. * @returns true if the particle is in the frustum planes
  81149. */
  81150. isInFrustum(frustumPlanes: Plane[]): boolean;
  81151. /**
  81152. * get the rotation matrix of the particle
  81153. * @hidden
  81154. */
  81155. getRotationMatrix(m: Matrix): void;
  81156. }
  81157. /**
  81158. * Represents the shape of the model used by one particle of a solid particle system.
  81159. * SPS internal tool, don't use it manually.
  81160. */
  81161. export class ModelShape {
  81162. /**
  81163. * The shape id
  81164. * @hidden
  81165. */
  81166. shapeID: number;
  81167. /**
  81168. * flat array of model positions (internal use)
  81169. * @hidden
  81170. */
  81171. _shape: Vector3[];
  81172. /**
  81173. * flat array of model UVs (internal use)
  81174. * @hidden
  81175. */
  81176. _shapeUV: number[];
  81177. /**
  81178. * length of the shape in the model indices array (internal use)
  81179. * @hidden
  81180. */
  81181. _indicesLength: number;
  81182. /**
  81183. * Custom position function (internal use)
  81184. * @hidden
  81185. */
  81186. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81187. /**
  81188. * Custom vertex function (internal use)
  81189. * @hidden
  81190. */
  81191. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81192. /**
  81193. * 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.
  81194. * SPS internal tool, don't use it manually.
  81195. * @hidden
  81196. */
  81197. 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>);
  81198. }
  81199. /**
  81200. * Represents a Depth Sorted Particle in the solid particle system.
  81201. */
  81202. export class DepthSortedParticle {
  81203. /**
  81204. * Index of the particle in the "indices" array
  81205. */
  81206. ind: number;
  81207. /**
  81208. * Length of the particle shape in the "indices" array
  81209. */
  81210. indicesLength: number;
  81211. /**
  81212. * Squared distance from the particle to the camera
  81213. */
  81214. sqDistance: number;
  81215. }
  81216. }
  81217. declare module BABYLON {
  81218. /**
  81219. * Class used to store all common mesh properties
  81220. */
  81221. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  81222. /** No occlusion */
  81223. static OCCLUSION_TYPE_NONE: number;
  81224. /** Occlusion set to optimisitic */
  81225. static OCCLUSION_TYPE_OPTIMISTIC: number;
  81226. /** Occlusion set to strict */
  81227. static OCCLUSION_TYPE_STRICT: number;
  81228. /** Use an accurante occlusion algorithm */
  81229. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  81230. /** Use a conservative occlusion algorithm */
  81231. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  81232. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81233. * Test order :
  81234. * Is the bounding sphere outside the frustum ?
  81235. * If not, are the bounding box vertices outside the frustum ?
  81236. * It not, then the cullable object is in the frustum.
  81237. */
  81238. static readonly CULLINGSTRATEGY_STANDARD: number;
  81239. /** Culling strategy : Bounding Sphere Only.
  81240. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81241. * It's also less accurate than the standard because some not visible objects can still be selected.
  81242. * Test : is the bounding sphere outside the frustum ?
  81243. * If not, then the cullable object is in the frustum.
  81244. */
  81245. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81246. /** Culling strategy : Optimistic Inclusion.
  81247. * This in an inclusion test first, then the standard exclusion test.
  81248. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81249. * 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.
  81250. * Anyway, it's as accurate as the standard strategy.
  81251. * Test :
  81252. * Is the cullable object bounding sphere center in the frustum ?
  81253. * If not, apply the default culling strategy.
  81254. */
  81255. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81256. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81257. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81258. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81259. * 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.
  81260. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81261. * Test :
  81262. * Is the cullable object bounding sphere center in the frustum ?
  81263. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81264. */
  81265. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81266. /**
  81267. * No billboard
  81268. */
  81269. static readonly BILLBOARDMODE_NONE: number;
  81270. /** Billboard on X axis */
  81271. static readonly BILLBOARDMODE_X: number;
  81272. /** Billboard on Y axis */
  81273. static readonly BILLBOARDMODE_Y: number;
  81274. /** Billboard on Z axis */
  81275. static readonly BILLBOARDMODE_Z: number;
  81276. /** Billboard on all axes */
  81277. static readonly BILLBOARDMODE_ALL: number;
  81278. private _facetData;
  81279. /**
  81280. * The culling strategy to use to check whether the mesh must be rendered or not.
  81281. * This value can be changed at any time and will be used on the next render mesh selection.
  81282. * The possible values are :
  81283. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81284. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81285. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81286. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81287. * Please read each static variable documentation to get details about the culling process.
  81288. * */
  81289. cullingStrategy: number;
  81290. /**
  81291. * Gets the number of facets in the mesh
  81292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81293. */
  81294. readonly facetNb: number;
  81295. /**
  81296. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81298. */
  81299. partitioningSubdivisions: number;
  81300. /**
  81301. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81302. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81304. */
  81305. partitioningBBoxRatio: number;
  81306. /**
  81307. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81308. * Works only for updatable meshes.
  81309. * Doesn't work with multi-materials
  81310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81311. */
  81312. mustDepthSortFacets: boolean;
  81313. /**
  81314. * The location (Vector3) where the facet depth sort must be computed from.
  81315. * By default, the active camera position.
  81316. * Used only when facet depth sort is enabled
  81317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81318. */
  81319. facetDepthSortFrom: Vector3;
  81320. /**
  81321. * gets a boolean indicating if facetData is enabled
  81322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81323. */
  81324. readonly isFacetDataEnabled: boolean;
  81325. /** @hidden */
  81326. _updateNonUniformScalingState(value: boolean): boolean;
  81327. /**
  81328. * An event triggered when this mesh collides with another one
  81329. */
  81330. onCollideObservable: Observable<AbstractMesh>;
  81331. private _onCollideObserver;
  81332. /** Set a function to call when this mesh collides with another one */
  81333. onCollide: () => void;
  81334. /**
  81335. * An event triggered when the collision's position changes
  81336. */
  81337. onCollisionPositionChangeObservable: Observable<Vector3>;
  81338. private _onCollisionPositionChangeObserver;
  81339. /** Set a function to call when the collision's position changes */
  81340. onCollisionPositionChange: () => void;
  81341. /**
  81342. * An event triggered when material is changed
  81343. */
  81344. onMaterialChangedObservable: Observable<AbstractMesh>;
  81345. /**
  81346. * Gets or sets the orientation for POV movement & rotation
  81347. */
  81348. definedFacingForward: boolean;
  81349. /** @hidden */
  81350. _occlusionQuery: Nullable<WebGLQuery>;
  81351. private _visibility;
  81352. /**
  81353. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81354. */
  81355. /**
  81356. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81357. */
  81358. visibility: number;
  81359. /** Gets or sets the alpha index used to sort transparent meshes
  81360. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81361. */
  81362. alphaIndex: number;
  81363. /**
  81364. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81365. */
  81366. isVisible: boolean;
  81367. /**
  81368. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81369. */
  81370. isPickable: boolean;
  81371. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81372. showSubMeshesBoundingBox: boolean;
  81373. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81374. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81375. */
  81376. isBlocker: boolean;
  81377. /**
  81378. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81379. */
  81380. enablePointerMoveEvents: boolean;
  81381. /**
  81382. * Specifies the rendering group id for this mesh (0 by default)
  81383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81384. */
  81385. renderingGroupId: number;
  81386. private _material;
  81387. /** Gets or sets current material */
  81388. material: Nullable<Material>;
  81389. private _receiveShadows;
  81390. /**
  81391. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81392. * @see http://doc.babylonjs.com/babylon101/shadows
  81393. */
  81394. receiveShadows: boolean;
  81395. /** Defines color to use when rendering outline */
  81396. outlineColor: Color3;
  81397. /** Define width to use when rendering outline */
  81398. outlineWidth: number;
  81399. /** Defines color to use when rendering overlay */
  81400. overlayColor: Color3;
  81401. /** Defines alpha to use when rendering overlay */
  81402. overlayAlpha: number;
  81403. private _hasVertexAlpha;
  81404. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81405. hasVertexAlpha: boolean;
  81406. private _useVertexColors;
  81407. /** 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) */
  81408. useVertexColors: boolean;
  81409. private _computeBonesUsingShaders;
  81410. /**
  81411. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81412. */
  81413. computeBonesUsingShaders: boolean;
  81414. private _numBoneInfluencers;
  81415. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81416. numBoneInfluencers: number;
  81417. private _applyFog;
  81418. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81419. applyFog: boolean;
  81420. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81421. useOctreeForRenderingSelection: boolean;
  81422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81423. useOctreeForPicking: boolean;
  81424. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81425. useOctreeForCollisions: boolean;
  81426. private _layerMask;
  81427. /**
  81428. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81429. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81430. */
  81431. layerMask: number;
  81432. /**
  81433. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81434. */
  81435. alwaysSelectAsActiveMesh: boolean;
  81436. /**
  81437. * Gets or sets the current action manager
  81438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81439. */
  81440. actionManager: Nullable<AbstractActionManager>;
  81441. private _checkCollisions;
  81442. private _collisionMask;
  81443. private _collisionGroup;
  81444. /**
  81445. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81447. */
  81448. ellipsoid: Vector3;
  81449. /**
  81450. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81452. */
  81453. ellipsoidOffset: Vector3;
  81454. private _collider;
  81455. private _oldPositionForCollisions;
  81456. private _diffPositionForCollisions;
  81457. /**
  81458. * Gets or sets a collision mask used to mask collisions (default is -1).
  81459. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81460. */
  81461. collisionMask: number;
  81462. /**
  81463. * Gets or sets the current collision group mask (-1 by default).
  81464. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81465. */
  81466. collisionGroup: number;
  81467. /**
  81468. * Defines edge width used when edgesRenderer is enabled
  81469. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81470. */
  81471. edgesWidth: number;
  81472. /**
  81473. * Defines edge color used when edgesRenderer is enabled
  81474. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81475. */
  81476. edgesColor: Color4;
  81477. /** @hidden */
  81478. _edgesRenderer: Nullable<IEdgesRenderer>;
  81479. /** @hidden */
  81480. _masterMesh: Nullable<AbstractMesh>;
  81481. /** @hidden */
  81482. _boundingInfo: Nullable<BoundingInfo>;
  81483. /** @hidden */
  81484. _renderId: number;
  81485. /**
  81486. * Gets or sets the list of subMeshes
  81487. * @see http://doc.babylonjs.com/how_to/multi_materials
  81488. */
  81489. subMeshes: SubMesh[];
  81490. /** @hidden */
  81491. _intersectionsInProgress: AbstractMesh[];
  81492. /** @hidden */
  81493. _unIndexed: boolean;
  81494. /** @hidden */
  81495. _lightSources: Light[];
  81496. /** @hidden */
  81497. readonly _positions: Nullable<Vector3[]>;
  81498. /** @hidden */
  81499. _waitingActions: any;
  81500. /** @hidden */
  81501. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81502. private _skeleton;
  81503. /** @hidden */
  81504. _bonesTransformMatrices: Nullable<Float32Array>;
  81505. /**
  81506. * Gets or sets a skeleton to apply skining transformations
  81507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81508. */
  81509. skeleton: Nullable<Skeleton>;
  81510. /**
  81511. * An event triggered when the mesh is rebuilt.
  81512. */
  81513. onRebuildObservable: Observable<AbstractMesh>;
  81514. /**
  81515. * Creates a new AbstractMesh
  81516. * @param name defines the name of the mesh
  81517. * @param scene defines the hosting scene
  81518. */
  81519. constructor(name: string, scene?: Nullable<Scene>);
  81520. /**
  81521. * Returns the string "AbstractMesh"
  81522. * @returns "AbstractMesh"
  81523. */
  81524. getClassName(): string;
  81525. /**
  81526. * Gets a string representation of the current mesh
  81527. * @param fullDetails defines a boolean indicating if full details must be included
  81528. * @returns a string representation of the current mesh
  81529. */
  81530. toString(fullDetails?: boolean): string;
  81531. /** @hidden */
  81532. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81533. /** @hidden */
  81534. _rebuild(): void;
  81535. /** @hidden */
  81536. _resyncLightSources(): void;
  81537. /** @hidden */
  81538. _resyncLighSource(light: Light): void;
  81539. /** @hidden */
  81540. _unBindEffect(): void;
  81541. /** @hidden */
  81542. _removeLightSource(light: Light): void;
  81543. private _markSubMeshesAsDirty;
  81544. /** @hidden */
  81545. _markSubMeshesAsLightDirty(): void;
  81546. /** @hidden */
  81547. _markSubMeshesAsAttributesDirty(): void;
  81548. /** @hidden */
  81549. _markSubMeshesAsMiscDirty(): void;
  81550. /**
  81551. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81552. */
  81553. scaling: Vector3;
  81554. /**
  81555. * Returns true if the mesh is blocked. Implemented by child classes
  81556. */
  81557. readonly isBlocked: boolean;
  81558. /**
  81559. * Returns the mesh itself by default. Implemented by child classes
  81560. * @param camera defines the camera to use to pick the right LOD level
  81561. * @returns the currentAbstractMesh
  81562. */
  81563. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81564. /**
  81565. * Returns 0 by default. Implemented by child classes
  81566. * @returns an integer
  81567. */
  81568. getTotalVertices(): number;
  81569. /**
  81570. * Returns a positive integer : the total number of indices in this mesh geometry.
  81571. * @returns the numner of indices or zero if the mesh has no geometry.
  81572. */
  81573. getTotalIndices(): number;
  81574. /**
  81575. * Returns null by default. Implemented by child classes
  81576. * @returns null
  81577. */
  81578. getIndices(): Nullable<IndicesArray>;
  81579. /**
  81580. * Returns the array of the requested vertex data kind. Implemented by child classes
  81581. * @param kind defines the vertex data kind to use
  81582. * @returns null
  81583. */
  81584. getVerticesData(kind: string): Nullable<FloatArray>;
  81585. /**
  81586. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81587. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81588. * Note that a new underlying VertexBuffer object is created each call.
  81589. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81590. * @param kind defines vertex data kind:
  81591. * * VertexBuffer.PositionKind
  81592. * * VertexBuffer.UVKind
  81593. * * VertexBuffer.UV2Kind
  81594. * * VertexBuffer.UV3Kind
  81595. * * VertexBuffer.UV4Kind
  81596. * * VertexBuffer.UV5Kind
  81597. * * VertexBuffer.UV6Kind
  81598. * * VertexBuffer.ColorKind
  81599. * * VertexBuffer.MatricesIndicesKind
  81600. * * VertexBuffer.MatricesIndicesExtraKind
  81601. * * VertexBuffer.MatricesWeightsKind
  81602. * * VertexBuffer.MatricesWeightsExtraKind
  81603. * @param data defines the data source
  81604. * @param updatable defines if the data must be flagged as updatable (or static)
  81605. * @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
  81606. * @returns the current mesh
  81607. */
  81608. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81609. /**
  81610. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81611. * If the mesh has no geometry, it is simply returned as it is.
  81612. * @param kind defines vertex data kind:
  81613. * * VertexBuffer.PositionKind
  81614. * * VertexBuffer.UVKind
  81615. * * VertexBuffer.UV2Kind
  81616. * * VertexBuffer.UV3Kind
  81617. * * VertexBuffer.UV4Kind
  81618. * * VertexBuffer.UV5Kind
  81619. * * VertexBuffer.UV6Kind
  81620. * * VertexBuffer.ColorKind
  81621. * * VertexBuffer.MatricesIndicesKind
  81622. * * VertexBuffer.MatricesIndicesExtraKind
  81623. * * VertexBuffer.MatricesWeightsKind
  81624. * * VertexBuffer.MatricesWeightsExtraKind
  81625. * @param data defines the data source
  81626. * @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
  81627. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81628. * @returns the current mesh
  81629. */
  81630. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81631. /**
  81632. * Sets the mesh indices,
  81633. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81634. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81635. * @param totalVertices Defines the total number of vertices
  81636. * @returns the current mesh
  81637. */
  81638. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81639. /**
  81640. * Gets a boolean indicating if specific vertex data is present
  81641. * @param kind defines the vertex data kind to use
  81642. * @returns true is data kind is present
  81643. */
  81644. isVerticesDataPresent(kind: string): boolean;
  81645. /**
  81646. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81647. * @returns a BoundingInfo
  81648. */
  81649. getBoundingInfo(): BoundingInfo;
  81650. /**
  81651. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81652. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81653. * @returns the current mesh
  81654. */
  81655. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81656. /**
  81657. * Overwrite the current bounding info
  81658. * @param boundingInfo defines the new bounding info
  81659. * @returns the current mesh
  81660. */
  81661. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81662. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81663. readonly useBones: boolean;
  81664. /** @hidden */
  81665. _preActivate(): void;
  81666. /** @hidden */
  81667. _preActivateForIntermediateRendering(renderId: number): void;
  81668. /** @hidden */
  81669. _activate(renderId: number): void;
  81670. /**
  81671. * Gets the current world matrix
  81672. * @returns a Matrix
  81673. */
  81674. getWorldMatrix(): Matrix;
  81675. /** @hidden */
  81676. _getWorldMatrixDeterminant(): number;
  81677. /**
  81678. * Perform relative position change from the point of view of behind the front of the mesh.
  81679. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81680. * Supports definition of mesh facing forward or backward
  81681. * @param amountRight defines the distance on the right axis
  81682. * @param amountUp defines the distance on the up axis
  81683. * @param amountForward defines the distance on the forward axis
  81684. * @returns the current mesh
  81685. */
  81686. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81687. /**
  81688. * Calculate relative position change from the point of view of behind the front of the mesh.
  81689. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81690. * Supports definition of mesh facing forward or backward
  81691. * @param amountRight defines the distance on the right axis
  81692. * @param amountUp defines the distance on the up axis
  81693. * @param amountForward defines the distance on the forward axis
  81694. * @returns the new displacement vector
  81695. */
  81696. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81697. /**
  81698. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81699. * Supports definition of mesh facing forward or backward
  81700. * @param flipBack defines the flip
  81701. * @param twirlClockwise defines the twirl
  81702. * @param tiltRight defines the tilt
  81703. * @returns the current mesh
  81704. */
  81705. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81706. /**
  81707. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81708. * Supports definition of mesh facing forward or backward.
  81709. * @param flipBack defines the flip
  81710. * @param twirlClockwise defines the twirl
  81711. * @param tiltRight defines the tilt
  81712. * @returns the new rotation vector
  81713. */
  81714. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81715. /**
  81716. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81717. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81718. * @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
  81719. * @returns the new bounding vectors
  81720. */
  81721. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81722. min: Vector3;
  81723. max: Vector3;
  81724. };
  81725. /**
  81726. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81727. * This means the mesh underlying bounding box and sphere are recomputed.
  81728. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81729. * @returns the current mesh
  81730. */
  81731. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81732. /** @hidden */
  81733. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81734. /** @hidden */
  81735. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81736. /** @hidden */
  81737. _updateBoundingInfo(): AbstractMesh;
  81738. /** @hidden */
  81739. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81740. /** @hidden */
  81741. protected _afterComputeWorldMatrix(): void;
  81742. /**
  81743. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81744. * A mesh is in the frustum if its bounding box intersects the frustum
  81745. * @param frustumPlanes defines the frustum to test
  81746. * @returns true if the mesh is in the frustum planes
  81747. */
  81748. isInFrustum(frustumPlanes: Plane[]): boolean;
  81749. /**
  81750. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81751. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81752. * @param frustumPlanes defines the frustum to test
  81753. * @returns true if the mesh is completely in the frustum planes
  81754. */
  81755. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81756. /**
  81757. * True if the mesh intersects another mesh or a SolidParticle object
  81758. * @param mesh defines a target mesh or SolidParticle to test
  81759. * @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)
  81760. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81761. * @returns true if there is an intersection
  81762. */
  81763. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81764. /**
  81765. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81766. * @param point defines the point to test
  81767. * @returns true if there is an intersection
  81768. */
  81769. intersectsPoint(point: Vector3): boolean;
  81770. /**
  81771. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81773. */
  81774. checkCollisions: boolean;
  81775. /**
  81776. * Gets Collider object used to compute collisions (not physics)
  81777. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81778. */
  81779. readonly collider: Collider;
  81780. /**
  81781. * Move the mesh using collision engine
  81782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81783. * @param displacement defines the requested displacement vector
  81784. * @returns the current mesh
  81785. */
  81786. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81787. private _onCollisionPositionChange;
  81788. /** @hidden */
  81789. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81790. /** @hidden */
  81791. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81792. /** @hidden */
  81793. _checkCollision(collider: Collider): AbstractMesh;
  81794. /** @hidden */
  81795. _generatePointsArray(): boolean;
  81796. /**
  81797. * Checks if the passed Ray intersects with the mesh
  81798. * @param ray defines the ray to use
  81799. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81800. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81801. * @returns the picking info
  81802. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81803. */
  81804. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81805. /**
  81806. * Clones the current mesh
  81807. * @param name defines the mesh name
  81808. * @param newParent defines the new mesh parent
  81809. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81810. * @returns the new mesh
  81811. */
  81812. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81813. /**
  81814. * Disposes all the submeshes of the current meshnp
  81815. * @returns the current mesh
  81816. */
  81817. releaseSubMeshes(): AbstractMesh;
  81818. /**
  81819. * Releases resources associated with this abstract mesh.
  81820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81822. */
  81823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81824. /**
  81825. * Adds the passed mesh as a child to the current mesh
  81826. * @param mesh defines the child mesh
  81827. * @returns the current mesh
  81828. */
  81829. addChild(mesh: AbstractMesh): AbstractMesh;
  81830. /**
  81831. * Removes the passed mesh from the current mesh children list
  81832. * @param mesh defines the child mesh
  81833. * @returns the current mesh
  81834. */
  81835. removeChild(mesh: AbstractMesh): AbstractMesh;
  81836. /** @hidden */
  81837. private _initFacetData;
  81838. /**
  81839. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81840. * This method can be called within the render loop.
  81841. * 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
  81842. * @returns the current mesh
  81843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81844. */
  81845. updateFacetData(): AbstractMesh;
  81846. /**
  81847. * Returns the facetLocalNormals array.
  81848. * The normals are expressed in the mesh local spac
  81849. * @returns an array of Vector3
  81850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81851. */
  81852. getFacetLocalNormals(): Vector3[];
  81853. /**
  81854. * Returns the facetLocalPositions array.
  81855. * The facet positions are expressed in the mesh local space
  81856. * @returns an array of Vector3
  81857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81858. */
  81859. getFacetLocalPositions(): Vector3[];
  81860. /**
  81861. * Returns the facetLocalPartioning array
  81862. * @returns an array of array of numbers
  81863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81864. */
  81865. getFacetLocalPartitioning(): number[][];
  81866. /**
  81867. * Returns the i-th facet position in the world system.
  81868. * This method allocates a new Vector3 per call
  81869. * @param i defines the facet index
  81870. * @returns a new Vector3
  81871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81872. */
  81873. getFacetPosition(i: number): Vector3;
  81874. /**
  81875. * Sets the reference Vector3 with the i-th facet position in the world system
  81876. * @param i defines the facet index
  81877. * @param ref defines the target vector
  81878. * @returns the current mesh
  81879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81880. */
  81881. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81882. /**
  81883. * Returns the i-th facet normal in the world system.
  81884. * This method allocates a new Vector3 per call
  81885. * @param i defines the facet index
  81886. * @returns a new Vector3
  81887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81888. */
  81889. getFacetNormal(i: number): Vector3;
  81890. /**
  81891. * Sets the reference Vector3 with the i-th facet normal in the world system
  81892. * @param i defines the facet index
  81893. * @param ref defines the target vector
  81894. * @returns the current mesh
  81895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81896. */
  81897. getFacetNormalToRef(i: number, ref: Vector3): this;
  81898. /**
  81899. * 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)
  81900. * @param x defines x coordinate
  81901. * @param y defines y coordinate
  81902. * @param z defines z coordinate
  81903. * @returns the array of facet indexes
  81904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81905. */
  81906. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81907. /**
  81908. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81909. * @param projected sets as the (x,y,z) world projection on the facet
  81910. * @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
  81911. * @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
  81912. * @param x defines x coordinate
  81913. * @param y defines y coordinate
  81914. * @param z defines z coordinate
  81915. * @returns the face index if found (or null instead)
  81916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81917. */
  81918. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81919. /**
  81920. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81921. * @param projected sets as the (x,y,z) local projection on the facet
  81922. * @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
  81923. * @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
  81924. * @param x defines x coordinate
  81925. * @param y defines y coordinate
  81926. * @param z defines z coordinate
  81927. * @returns the face index if found (or null instead)
  81928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81929. */
  81930. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81931. /**
  81932. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81933. * @returns the parameters
  81934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81935. */
  81936. getFacetDataParameters(): any;
  81937. /**
  81938. * Disables the feature FacetData and frees the related memory
  81939. * @returns the current mesh
  81940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81941. */
  81942. disableFacetData(): AbstractMesh;
  81943. /**
  81944. * Updates the AbstractMesh indices array
  81945. * @param indices defines the data source
  81946. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81947. * @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)
  81948. * @returns the current mesh
  81949. */
  81950. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81951. /**
  81952. * Creates new normals data for the mesh
  81953. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81954. * @returns the current mesh
  81955. */
  81956. createNormals(updatable: boolean): AbstractMesh;
  81957. /**
  81958. * Align the mesh with a normal
  81959. * @param normal defines the normal to use
  81960. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81961. * @returns the current mesh
  81962. */
  81963. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81964. /** @hidden */
  81965. _checkOcclusionQuery(): boolean;
  81966. }
  81967. }
  81968. declare module BABYLON {
  81969. /**
  81970. * Interface used to define ActionEvent
  81971. */
  81972. export interface IActionEvent {
  81973. /** The mesh or sprite that triggered the action */
  81974. source: any;
  81975. /** The X mouse cursor position at the time of the event */
  81976. pointerX: number;
  81977. /** The Y mouse cursor position at the time of the event */
  81978. pointerY: number;
  81979. /** The mesh that is currently pointed at (can be null) */
  81980. meshUnderPointer: Nullable<AbstractMesh>;
  81981. /** the original (browser) event that triggered the ActionEvent */
  81982. sourceEvent?: any;
  81983. /** additional data for the event */
  81984. additionalData?: any;
  81985. }
  81986. /**
  81987. * ActionEvent is the event being sent when an action is triggered.
  81988. */
  81989. export class ActionEvent implements IActionEvent {
  81990. /** The mesh or sprite that triggered the action */
  81991. source: any;
  81992. /** The X mouse cursor position at the time of the event */
  81993. pointerX: number;
  81994. /** The Y mouse cursor position at the time of the event */
  81995. pointerY: number;
  81996. /** The mesh that is currently pointed at (can be null) */
  81997. meshUnderPointer: Nullable<AbstractMesh>;
  81998. /** the original (browser) event that triggered the ActionEvent */
  81999. sourceEvent?: any;
  82000. /** additional data for the event */
  82001. additionalData?: any;
  82002. /**
  82003. * Creates a new ActionEvent
  82004. * @param source The mesh or sprite that triggered the action
  82005. * @param pointerX The X mouse cursor position at the time of the event
  82006. * @param pointerY The Y mouse cursor position at the time of the event
  82007. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82008. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82009. * @param additionalData additional data for the event
  82010. */
  82011. constructor(
  82012. /** The mesh or sprite that triggered the action */
  82013. source: any,
  82014. /** The X mouse cursor position at the time of the event */
  82015. pointerX: number,
  82016. /** The Y mouse cursor position at the time of the event */
  82017. pointerY: number,
  82018. /** The mesh that is currently pointed at (can be null) */
  82019. meshUnderPointer: Nullable<AbstractMesh>,
  82020. /** the original (browser) event that triggered the ActionEvent */
  82021. sourceEvent?: any,
  82022. /** additional data for the event */
  82023. additionalData?: any);
  82024. /**
  82025. * Helper function to auto-create an ActionEvent from a source mesh.
  82026. * @param source The source mesh that triggered the event
  82027. * @param evt The original (browser) event
  82028. * @param additionalData additional data for the event
  82029. * @returns the new ActionEvent
  82030. */
  82031. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82032. /**
  82033. * Helper function to auto-create an ActionEvent from a source sprite
  82034. * @param source The source sprite that triggered the event
  82035. * @param scene Scene associated with the sprite
  82036. * @param evt The original (browser) event
  82037. * @param additionalData additional data for the event
  82038. * @returns the new ActionEvent
  82039. */
  82040. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82041. /**
  82042. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82043. * @param scene the scene where the event occurred
  82044. * @param evt The original (browser) event
  82045. * @returns the new ActionEvent
  82046. */
  82047. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82048. /**
  82049. * Helper function to auto-create an ActionEvent from a primitive
  82050. * @param prim defines the target primitive
  82051. * @param pointerPos defines the pointer position
  82052. * @param evt The original (browser) event
  82053. * @param additionalData additional data for the event
  82054. * @returns the new ActionEvent
  82055. */
  82056. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82057. }
  82058. }
  82059. declare module BABYLON {
  82060. /**
  82061. * Abstract class used to decouple action Manager from scene and meshes.
  82062. * Do not instantiate.
  82063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82064. */
  82065. export abstract class AbstractActionManager implements IDisposable {
  82066. /** Gets the list of active triggers */
  82067. static Triggers: {
  82068. [key: string]: number;
  82069. };
  82070. /** Gets the cursor to use when hovering items */
  82071. hoverCursor: string;
  82072. /** Gets the list of actions */
  82073. actions: IAction[];
  82074. /**
  82075. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82076. */
  82077. isRecursive: boolean;
  82078. /**
  82079. * Releases all associated resources
  82080. */
  82081. abstract dispose(): void;
  82082. /**
  82083. * Does this action manager has pointer triggers
  82084. */
  82085. abstract readonly hasPointerTriggers: boolean;
  82086. /**
  82087. * Does this action manager has pick triggers
  82088. */
  82089. abstract readonly hasPickTriggers: boolean;
  82090. /**
  82091. * Process a specific trigger
  82092. * @param trigger defines the trigger to process
  82093. * @param evt defines the event details to be processed
  82094. */
  82095. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  82096. /**
  82097. * Does this action manager handles actions of any of the given triggers
  82098. * @param triggers defines the triggers to be tested
  82099. * @return a boolean indicating whether one (or more) of the triggers is handled
  82100. */
  82101. abstract hasSpecificTriggers(triggers: number[]): boolean;
  82102. /**
  82103. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82104. * speed.
  82105. * @param triggerA defines the trigger to be tested
  82106. * @param triggerB defines the trigger to be tested
  82107. * @return a boolean indicating whether one (or more) of the triggers is handled
  82108. */
  82109. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82110. /**
  82111. * Does this action manager handles actions of a given trigger
  82112. * @param trigger defines the trigger to be tested
  82113. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82114. * @return whether the trigger is handled
  82115. */
  82116. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82117. /**
  82118. * Serialize this manager to a JSON object
  82119. * @param name defines the property name to store this manager
  82120. * @returns a JSON representation of this manager
  82121. */
  82122. abstract serialize(name: string): any;
  82123. /**
  82124. * Registers an action to this action manager
  82125. * @param action defines the action to be registered
  82126. * @return the action amended (prepared) after registration
  82127. */
  82128. abstract registerAction(action: IAction): Nullable<IAction>;
  82129. /**
  82130. * Unregisters an action to this action manager
  82131. * @param action defines the action to be unregistered
  82132. * @return a boolean indicating whether the action has been unregistered
  82133. */
  82134. abstract unregisterAction(action: IAction): Boolean;
  82135. /**
  82136. * Does exist one action manager with at least one trigger
  82137. **/
  82138. static readonly HasTriggers: boolean;
  82139. /**
  82140. * Does exist one action manager with at least one pick trigger
  82141. **/
  82142. static readonly HasPickTriggers: boolean;
  82143. /**
  82144. * Does exist one action manager that handles actions of a given trigger
  82145. * @param trigger defines the trigger to be tested
  82146. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82147. **/
  82148. static HasSpecificTrigger(trigger: number): boolean;
  82149. }
  82150. }
  82151. declare module BABYLON {
  82152. /**
  82153. * Defines how a node can be built from a string name.
  82154. */
  82155. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82156. /**
  82157. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82158. */
  82159. export class Node implements IBehaviorAware<Node> {
  82160. /** @hidden */
  82161. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82162. private static _NodeConstructors;
  82163. /**
  82164. * Add a new node constructor
  82165. * @param type defines the type name of the node to construct
  82166. * @param constructorFunc defines the constructor function
  82167. */
  82168. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82169. /**
  82170. * Returns a node constructor based on type name
  82171. * @param type defines the type name
  82172. * @param name defines the new node name
  82173. * @param scene defines the hosting scene
  82174. * @param options defines optional options to transmit to constructors
  82175. * @returns the new constructor or null
  82176. */
  82177. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82178. /**
  82179. * Gets or sets the name of the node
  82180. */
  82181. name: string;
  82182. /**
  82183. * Gets or sets the id of the node
  82184. */
  82185. id: string;
  82186. /**
  82187. * Gets or sets the unique id of the node
  82188. */
  82189. uniqueId: number;
  82190. /**
  82191. * Gets or sets a string used to store user defined state for the node
  82192. */
  82193. state: string;
  82194. /**
  82195. * Gets or sets an object used to store user defined information for the node
  82196. */
  82197. metadata: any;
  82198. /**
  82199. * For internal use only. Please do not use.
  82200. */
  82201. reservedDataStore: any;
  82202. /**
  82203. * Gets or sets a boolean used to define if the node must be serialized
  82204. */
  82205. doNotSerialize: boolean;
  82206. /** @hidden */
  82207. _isDisposed: boolean;
  82208. /**
  82209. * Gets a list of Animations associated with the node
  82210. */
  82211. animations: Animation[];
  82212. protected _ranges: {
  82213. [name: string]: Nullable<AnimationRange>;
  82214. };
  82215. /**
  82216. * Callback raised when the node is ready to be used
  82217. */
  82218. onReady: (node: Node) => void;
  82219. private _isEnabled;
  82220. private _isParentEnabled;
  82221. private _isReady;
  82222. /** @hidden */
  82223. _currentRenderId: number;
  82224. private _parentRenderId;
  82225. protected _childRenderId: number;
  82226. /** @hidden */
  82227. _waitingParentId: Nullable<string>;
  82228. /** @hidden */
  82229. _scene: Scene;
  82230. /** @hidden */
  82231. _cache: any;
  82232. private _parentNode;
  82233. private _children;
  82234. /** @hidden */
  82235. _worldMatrix: Matrix;
  82236. /** @hidden */
  82237. _worldMatrixDeterminant: number;
  82238. /** @hidden */
  82239. private _sceneRootNodesIndex;
  82240. /**
  82241. * Gets a boolean indicating if the node has been disposed
  82242. * @returns true if the node was disposed
  82243. */
  82244. isDisposed(): boolean;
  82245. /**
  82246. * Gets or sets the parent of the node
  82247. */
  82248. parent: Nullable<Node>;
  82249. private addToSceneRootNodes;
  82250. private removeFromSceneRootNodes;
  82251. private _animationPropertiesOverride;
  82252. /**
  82253. * Gets or sets the animation properties override
  82254. */
  82255. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82256. /**
  82257. * Gets a string idenfifying the name of the class
  82258. * @returns "Node" string
  82259. */
  82260. getClassName(): string;
  82261. /** @hidden */
  82262. readonly _isNode: boolean;
  82263. /**
  82264. * An event triggered when the mesh is disposed
  82265. */
  82266. onDisposeObservable: Observable<Node>;
  82267. private _onDisposeObserver;
  82268. /**
  82269. * Sets a callback that will be raised when the node will be disposed
  82270. */
  82271. onDispose: () => void;
  82272. /**
  82273. * Creates a new Node
  82274. * @param name the name and id to be given to this node
  82275. * @param scene the scene this node will be added to
  82276. * @param addToRootNodes the node will be added to scene.rootNodes
  82277. */
  82278. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  82279. /**
  82280. * Gets the scene of the node
  82281. * @returns a scene
  82282. */
  82283. getScene(): Scene;
  82284. /**
  82285. * Gets the engine of the node
  82286. * @returns a Engine
  82287. */
  82288. getEngine(): Engine;
  82289. private _behaviors;
  82290. /**
  82291. * Attach a behavior to the node
  82292. * @see http://doc.babylonjs.com/features/behaviour
  82293. * @param behavior defines the behavior to attach
  82294. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  82295. * @returns the current Node
  82296. */
  82297. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  82298. /**
  82299. * Remove an attached behavior
  82300. * @see http://doc.babylonjs.com/features/behaviour
  82301. * @param behavior defines the behavior to attach
  82302. * @returns the current Node
  82303. */
  82304. removeBehavior(behavior: Behavior<Node>): Node;
  82305. /**
  82306. * Gets the list of attached behaviors
  82307. * @see http://doc.babylonjs.com/features/behaviour
  82308. */
  82309. readonly behaviors: Behavior<Node>[];
  82310. /**
  82311. * Gets an attached behavior by name
  82312. * @param name defines the name of the behavior to look for
  82313. * @see http://doc.babylonjs.com/features/behaviour
  82314. * @returns null if behavior was not found else the requested behavior
  82315. */
  82316. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  82317. /**
  82318. * Returns the latest update of the World matrix
  82319. * @returns a Matrix
  82320. */
  82321. getWorldMatrix(): Matrix;
  82322. /** @hidden */
  82323. _getWorldMatrixDeterminant(): number;
  82324. /**
  82325. * Returns directly the latest state of the mesh World matrix.
  82326. * A Matrix is returned.
  82327. */
  82328. readonly worldMatrixFromCache: Matrix;
  82329. /** @hidden */
  82330. _initCache(): void;
  82331. /** @hidden */
  82332. updateCache(force?: boolean): void;
  82333. /** @hidden */
  82334. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82335. /** @hidden */
  82336. _updateCache(ignoreParentClass?: boolean): void;
  82337. /** @hidden */
  82338. _isSynchronized(): boolean;
  82339. /** @hidden */
  82340. _markSyncedWithParent(): void;
  82341. /** @hidden */
  82342. isSynchronizedWithParent(): boolean;
  82343. /** @hidden */
  82344. isSynchronized(): boolean;
  82345. /**
  82346. * Is this node ready to be used/rendered
  82347. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82348. * @return true if the node is ready
  82349. */
  82350. isReady(completeCheck?: boolean): boolean;
  82351. /**
  82352. * Is this node enabled?
  82353. * 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
  82354. * @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
  82355. * @return whether this node (and its parent) is enabled
  82356. */
  82357. isEnabled(checkAncestors?: boolean): boolean;
  82358. /** @hidden */
  82359. protected _syncParentEnabledState(): void;
  82360. /**
  82361. * Set the enabled state of this node
  82362. * @param value defines the new enabled state
  82363. */
  82364. setEnabled(value: boolean): void;
  82365. /**
  82366. * Is this node a descendant of the given node?
  82367. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82368. * @param ancestor defines the parent node to inspect
  82369. * @returns a boolean indicating if this node is a descendant of the given node
  82370. */
  82371. isDescendantOf(ancestor: Node): boolean;
  82372. /** @hidden */
  82373. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82374. /**
  82375. * Will return all nodes that have this node as ascendant
  82376. * @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
  82377. * @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
  82378. * @return all children nodes of all types
  82379. */
  82380. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82381. /**
  82382. * Get all child-meshes of this node
  82383. * @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)
  82384. * @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
  82385. * @returns an array of AbstractMesh
  82386. */
  82387. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82388. /**
  82389. * Get all direct children of this node
  82390. * @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
  82391. * @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)
  82392. * @returns an array of Node
  82393. */
  82394. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82395. /** @hidden */
  82396. _setReady(state: boolean): void;
  82397. /**
  82398. * Get an animation by name
  82399. * @param name defines the name of the animation to look for
  82400. * @returns null if not found else the requested animation
  82401. */
  82402. getAnimationByName(name: string): Nullable<Animation>;
  82403. /**
  82404. * Creates an animation range for this node
  82405. * @param name defines the name of the range
  82406. * @param from defines the starting key
  82407. * @param to defines the end key
  82408. */
  82409. createAnimationRange(name: string, from: number, to: number): void;
  82410. /**
  82411. * Delete a specific animation range
  82412. * @param name defines the name of the range to delete
  82413. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82414. */
  82415. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82416. /**
  82417. * Get an animation range by name
  82418. * @param name defines the name of the animation range to look for
  82419. * @returns null if not found else the requested animation range
  82420. */
  82421. getAnimationRange(name: string): Nullable<AnimationRange>;
  82422. /**
  82423. * Gets the list of all animation ranges defined on this node
  82424. * @returns an array
  82425. */
  82426. getAnimationRanges(): Nullable<AnimationRange>[];
  82427. /**
  82428. * Will start the animation sequence
  82429. * @param name defines the range frames for animation sequence
  82430. * @param loop defines if the animation should loop (false by default)
  82431. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82432. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82433. * @returns the object created for this animation. If range does not exist, it will return null
  82434. */
  82435. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82436. /**
  82437. * Serialize animation ranges into a JSON compatible object
  82438. * @returns serialization object
  82439. */
  82440. serializeAnimationRanges(): any;
  82441. /**
  82442. * Computes the world matrix of the node
  82443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82444. * @returns the world matrix
  82445. */
  82446. computeWorldMatrix(force?: boolean): Matrix;
  82447. /**
  82448. * Releases resources associated with this node.
  82449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82451. */
  82452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82453. /**
  82454. * Parse animation range data from a serialization object and store them into a given node
  82455. * @param node defines where to store the animation ranges
  82456. * @param parsedNode defines the serialization object to read data from
  82457. * @param scene defines the hosting scene
  82458. */
  82459. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82460. }
  82461. }
  82462. declare module BABYLON {
  82463. /**
  82464. * Class used to store any kind of animation
  82465. */
  82466. export class Animation {
  82467. /**Name of the animation */
  82468. name: string;
  82469. /**Property to animate */
  82470. targetProperty: string;
  82471. /**The frames per second of the animation */
  82472. framePerSecond: number;
  82473. /**The data type of the animation */
  82474. dataType: number;
  82475. /**The loop mode of the animation */
  82476. loopMode?: number | undefined;
  82477. /**Specifies if blending should be enabled */
  82478. enableBlending?: boolean | undefined;
  82479. /**
  82480. * Use matrix interpolation instead of using direct key value when animating matrices
  82481. */
  82482. static AllowMatricesInterpolation: boolean;
  82483. /**
  82484. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82485. */
  82486. static AllowMatrixDecomposeForInterpolation: boolean;
  82487. /**
  82488. * Stores the key frames of the animation
  82489. */
  82490. private _keys;
  82491. /**
  82492. * Stores the easing function of the animation
  82493. */
  82494. private _easingFunction;
  82495. /**
  82496. * @hidden Internal use only
  82497. */
  82498. _runtimeAnimations: RuntimeAnimation[];
  82499. /**
  82500. * The set of event that will be linked to this animation
  82501. */
  82502. private _events;
  82503. /**
  82504. * Stores an array of target property paths
  82505. */
  82506. targetPropertyPath: string[];
  82507. /**
  82508. * Stores the blending speed of the animation
  82509. */
  82510. blendingSpeed: number;
  82511. /**
  82512. * Stores the animation ranges for the animation
  82513. */
  82514. private _ranges;
  82515. /**
  82516. * @hidden Internal use
  82517. */
  82518. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82519. /**
  82520. * Sets up an animation
  82521. * @param property The property to animate
  82522. * @param animationType The animation type to apply
  82523. * @param framePerSecond The frames per second of the animation
  82524. * @param easingFunction The easing function used in the animation
  82525. * @returns The created animation
  82526. */
  82527. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82528. /**
  82529. * Create and start an animation on a node
  82530. * @param name defines the name of the global animation that will be run on all nodes
  82531. * @param node defines the root node where the animation will take place
  82532. * @param targetProperty defines property to animate
  82533. * @param framePerSecond defines the number of frame per second yo use
  82534. * @param totalFrame defines the number of frames in total
  82535. * @param from defines the initial value
  82536. * @param to defines the final value
  82537. * @param loopMode defines which loop mode you want to use (off by default)
  82538. * @param easingFunction defines the easing function to use (linear by default)
  82539. * @param onAnimationEnd defines the callback to call when animation end
  82540. * @returns the animatable created for this animation
  82541. */
  82542. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82543. /**
  82544. * Create and start an animation on a node and its descendants
  82545. * @param name defines the name of the global animation that will be run on all nodes
  82546. * @param node defines the root node where the animation will take place
  82547. * @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
  82548. * @param targetProperty defines property to animate
  82549. * @param framePerSecond defines the number of frame per second to use
  82550. * @param totalFrame defines the number of frames in total
  82551. * @param from defines the initial value
  82552. * @param to defines the final value
  82553. * @param loopMode defines which loop mode you want to use (off by default)
  82554. * @param easingFunction defines the easing function to use (linear by default)
  82555. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82556. * @returns the list of animatables created for all nodes
  82557. * @example https://www.babylonjs-playground.com/#MH0VLI
  82558. */
  82559. 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[]>;
  82560. /**
  82561. * Creates a new animation, merges it with the existing animations and starts it
  82562. * @param name Name of the animation
  82563. * @param node Node which contains the scene that begins the animations
  82564. * @param targetProperty Specifies which property to animate
  82565. * @param framePerSecond The frames per second of the animation
  82566. * @param totalFrame The total number of frames
  82567. * @param from The frame at the beginning of the animation
  82568. * @param to The frame at the end of the animation
  82569. * @param loopMode Specifies the loop mode of the animation
  82570. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82571. * @param onAnimationEnd Callback to run once the animation is complete
  82572. * @returns Nullable animation
  82573. */
  82574. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82575. /**
  82576. * Transition property of an host to the target Value
  82577. * @param property The property to transition
  82578. * @param targetValue The target Value of the property
  82579. * @param host The object where the property to animate belongs
  82580. * @param scene Scene used to run the animation
  82581. * @param frameRate Framerate (in frame/s) to use
  82582. * @param transition The transition type we want to use
  82583. * @param duration The duration of the animation, in milliseconds
  82584. * @param onAnimationEnd Callback trigger at the end of the animation
  82585. * @returns Nullable animation
  82586. */
  82587. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82588. /**
  82589. * Return the array of runtime animations currently using this animation
  82590. */
  82591. readonly runtimeAnimations: RuntimeAnimation[];
  82592. /**
  82593. * Specifies if any of the runtime animations are currently running
  82594. */
  82595. readonly hasRunningRuntimeAnimations: boolean;
  82596. /**
  82597. * Initializes the animation
  82598. * @param name Name of the animation
  82599. * @param targetProperty Property to animate
  82600. * @param framePerSecond The frames per second of the animation
  82601. * @param dataType The data type of the animation
  82602. * @param loopMode The loop mode of the animation
  82603. * @param enableBlending Specifies if blending should be enabled
  82604. */
  82605. constructor(
  82606. /**Name of the animation */
  82607. name: string,
  82608. /**Property to animate */
  82609. targetProperty: string,
  82610. /**The frames per second of the animation */
  82611. framePerSecond: number,
  82612. /**The data type of the animation */
  82613. dataType: number,
  82614. /**The loop mode of the animation */
  82615. loopMode?: number | undefined,
  82616. /**Specifies if blending should be enabled */
  82617. enableBlending?: boolean | undefined);
  82618. /**
  82619. * Converts the animation to a string
  82620. * @param fullDetails support for multiple levels of logging within scene loading
  82621. * @returns String form of the animation
  82622. */
  82623. toString(fullDetails?: boolean): string;
  82624. /**
  82625. * Add an event to this animation
  82626. * @param event Event to add
  82627. */
  82628. addEvent(event: AnimationEvent): void;
  82629. /**
  82630. * Remove all events found at the given frame
  82631. * @param frame The frame to remove events from
  82632. */
  82633. removeEvents(frame: number): void;
  82634. /**
  82635. * Retrieves all the events from the animation
  82636. * @returns Events from the animation
  82637. */
  82638. getEvents(): AnimationEvent[];
  82639. /**
  82640. * Creates an animation range
  82641. * @param name Name of the animation range
  82642. * @param from Starting frame of the animation range
  82643. * @param to Ending frame of the animation
  82644. */
  82645. createRange(name: string, from: number, to: number): void;
  82646. /**
  82647. * Deletes an animation range by name
  82648. * @param name Name of the animation range to delete
  82649. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82650. */
  82651. deleteRange(name: string, deleteFrames?: boolean): void;
  82652. /**
  82653. * Gets the animation range by name, or null if not defined
  82654. * @param name Name of the animation range
  82655. * @returns Nullable animation range
  82656. */
  82657. getRange(name: string): Nullable<AnimationRange>;
  82658. /**
  82659. * Gets the key frames from the animation
  82660. * @returns The key frames of the animation
  82661. */
  82662. getKeys(): Array<IAnimationKey>;
  82663. /**
  82664. * Gets the highest frame rate of the animation
  82665. * @returns Highest frame rate of the animation
  82666. */
  82667. getHighestFrame(): number;
  82668. /**
  82669. * Gets the easing function of the animation
  82670. * @returns Easing function of the animation
  82671. */
  82672. getEasingFunction(): IEasingFunction;
  82673. /**
  82674. * Sets the easing function of the animation
  82675. * @param easingFunction A custom mathematical formula for animation
  82676. */
  82677. setEasingFunction(easingFunction: EasingFunction): void;
  82678. /**
  82679. * Interpolates a scalar linearly
  82680. * @param startValue Start value of the animation curve
  82681. * @param endValue End value of the animation curve
  82682. * @param gradient Scalar amount to interpolate
  82683. * @returns Interpolated scalar value
  82684. */
  82685. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82686. /**
  82687. * Interpolates a scalar cubically
  82688. * @param startValue Start value of the animation curve
  82689. * @param outTangent End tangent of the animation
  82690. * @param endValue End value of the animation curve
  82691. * @param inTangent Start tangent of the animation curve
  82692. * @param gradient Scalar amount to interpolate
  82693. * @returns Interpolated scalar value
  82694. */
  82695. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82696. /**
  82697. * Interpolates a quaternion using a spherical linear interpolation
  82698. * @param startValue Start value of the animation curve
  82699. * @param endValue End value of the animation curve
  82700. * @param gradient Scalar amount to interpolate
  82701. * @returns Interpolated quaternion value
  82702. */
  82703. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82704. /**
  82705. * Interpolates a quaternion cubically
  82706. * @param startValue Start value of the animation curve
  82707. * @param outTangent End tangent of the animation curve
  82708. * @param endValue End value of the animation curve
  82709. * @param inTangent Start tangent of the animation curve
  82710. * @param gradient Scalar amount to interpolate
  82711. * @returns Interpolated quaternion value
  82712. */
  82713. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82714. /**
  82715. * Interpolates a Vector3 linearl
  82716. * @param startValue Start value of the animation curve
  82717. * @param endValue End value of the animation curve
  82718. * @param gradient Scalar amount to interpolate
  82719. * @returns Interpolated scalar value
  82720. */
  82721. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82722. /**
  82723. * Interpolates a Vector3 cubically
  82724. * @param startValue Start value of the animation curve
  82725. * @param outTangent End tangent of the animation
  82726. * @param endValue End value of the animation curve
  82727. * @param inTangent Start tangent of the animation curve
  82728. * @param gradient Scalar amount to interpolate
  82729. * @returns InterpolatedVector3 value
  82730. */
  82731. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82732. /**
  82733. * Interpolates a Vector2 linearly
  82734. * @param startValue Start value of the animation curve
  82735. * @param endValue End value of the animation curve
  82736. * @param gradient Scalar amount to interpolate
  82737. * @returns Interpolated Vector2 value
  82738. */
  82739. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82740. /**
  82741. * Interpolates a Vector2 cubically
  82742. * @param startValue Start value of the animation curve
  82743. * @param outTangent End tangent of the animation
  82744. * @param endValue End value of the animation curve
  82745. * @param inTangent Start tangent of the animation curve
  82746. * @param gradient Scalar amount to interpolate
  82747. * @returns Interpolated Vector2 value
  82748. */
  82749. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82750. /**
  82751. * Interpolates a size linearly
  82752. * @param startValue Start value of the animation curve
  82753. * @param endValue End value of the animation curve
  82754. * @param gradient Scalar amount to interpolate
  82755. * @returns Interpolated Size value
  82756. */
  82757. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82758. /**
  82759. * Interpolates a Color3 linearly
  82760. * @param startValue Start value of the animation curve
  82761. * @param endValue End value of the animation curve
  82762. * @param gradient Scalar amount to interpolate
  82763. * @returns Interpolated Color3 value
  82764. */
  82765. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82766. /**
  82767. * @hidden Internal use only
  82768. */
  82769. _getKeyValue(value: any): any;
  82770. /**
  82771. * @hidden Internal use only
  82772. */
  82773. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82774. /**
  82775. * Defines the function to use to interpolate matrices
  82776. * @param startValue defines the start matrix
  82777. * @param endValue defines the end matrix
  82778. * @param gradient defines the gradient between both matrices
  82779. * @param result defines an optional target matrix where to store the interpolation
  82780. * @returns the interpolated matrix
  82781. */
  82782. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82783. /**
  82784. * Makes a copy of the animation
  82785. * @returns Cloned animation
  82786. */
  82787. clone(): Animation;
  82788. /**
  82789. * Sets the key frames of the animation
  82790. * @param values The animation key frames to set
  82791. */
  82792. setKeys(values: Array<IAnimationKey>): void;
  82793. /**
  82794. * Serializes the animation to an object
  82795. * @returns Serialized object
  82796. */
  82797. serialize(): any;
  82798. /**
  82799. * Float animation type
  82800. */
  82801. private static _ANIMATIONTYPE_FLOAT;
  82802. /**
  82803. * Vector3 animation type
  82804. */
  82805. private static _ANIMATIONTYPE_VECTOR3;
  82806. /**
  82807. * Quaternion animation type
  82808. */
  82809. private static _ANIMATIONTYPE_QUATERNION;
  82810. /**
  82811. * Matrix animation type
  82812. */
  82813. private static _ANIMATIONTYPE_MATRIX;
  82814. /**
  82815. * Color3 animation type
  82816. */
  82817. private static _ANIMATIONTYPE_COLOR3;
  82818. /**
  82819. * Vector2 animation type
  82820. */
  82821. private static _ANIMATIONTYPE_VECTOR2;
  82822. /**
  82823. * Size animation type
  82824. */
  82825. private static _ANIMATIONTYPE_SIZE;
  82826. /**
  82827. * Relative Loop Mode
  82828. */
  82829. private static _ANIMATIONLOOPMODE_RELATIVE;
  82830. /**
  82831. * Cycle Loop Mode
  82832. */
  82833. private static _ANIMATIONLOOPMODE_CYCLE;
  82834. /**
  82835. * Constant Loop Mode
  82836. */
  82837. private static _ANIMATIONLOOPMODE_CONSTANT;
  82838. /**
  82839. * Get the float animation type
  82840. */
  82841. static readonly ANIMATIONTYPE_FLOAT: number;
  82842. /**
  82843. * Get the Vector3 animation type
  82844. */
  82845. static readonly ANIMATIONTYPE_VECTOR3: number;
  82846. /**
  82847. * Get the Vector2 animation type
  82848. */
  82849. static readonly ANIMATIONTYPE_VECTOR2: number;
  82850. /**
  82851. * Get the Size animation type
  82852. */
  82853. static readonly ANIMATIONTYPE_SIZE: number;
  82854. /**
  82855. * Get the Quaternion animation type
  82856. */
  82857. static readonly ANIMATIONTYPE_QUATERNION: number;
  82858. /**
  82859. * Get the Matrix animation type
  82860. */
  82861. static readonly ANIMATIONTYPE_MATRIX: number;
  82862. /**
  82863. * Get the Color3 animation type
  82864. */
  82865. static readonly ANIMATIONTYPE_COLOR3: number;
  82866. /**
  82867. * Get the Relative Loop Mode
  82868. */
  82869. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82870. /**
  82871. * Get the Cycle Loop Mode
  82872. */
  82873. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82874. /**
  82875. * Get the Constant Loop Mode
  82876. */
  82877. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82878. /** @hidden */
  82879. static _UniversalLerp(left: any, right: any, amount: number): any;
  82880. /**
  82881. * Parses an animation object and creates an animation
  82882. * @param parsedAnimation Parsed animation object
  82883. * @returns Animation object
  82884. */
  82885. static Parse(parsedAnimation: any): Animation;
  82886. /**
  82887. * Appends the serialized animations from the source animations
  82888. * @param source Source containing the animations
  82889. * @param destination Target to store the animations
  82890. */
  82891. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82892. }
  82893. }
  82894. declare module BABYLON {
  82895. /**
  82896. * Base class of all the textures in babylon.
  82897. * It groups all the common properties the materials, post process, lights... might need
  82898. * in order to make a correct use of the texture.
  82899. */
  82900. export class BaseTexture implements IAnimatable {
  82901. /**
  82902. * Default anisotropic filtering level for the application.
  82903. * It is set to 4 as a good tradeoff between perf and quality.
  82904. */
  82905. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82906. /**
  82907. * Gets or sets the unique id of the texture
  82908. */
  82909. uniqueId: number;
  82910. /**
  82911. * Define the name of the texture.
  82912. */
  82913. name: string;
  82914. /**
  82915. * Gets or sets an object used to store user defined information.
  82916. */
  82917. metadata: any;
  82918. /**
  82919. * For internal use only. Please do not use.
  82920. */
  82921. reservedDataStore: any;
  82922. private _hasAlpha;
  82923. /**
  82924. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82925. */
  82926. hasAlpha: boolean;
  82927. /**
  82928. * Defines if the alpha value should be determined via the rgb values.
  82929. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82930. */
  82931. getAlphaFromRGB: boolean;
  82932. /**
  82933. * Intensity or strength of the texture.
  82934. * It is commonly used by materials to fine tune the intensity of the texture
  82935. */
  82936. level: number;
  82937. /**
  82938. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82939. * This is part of the texture as textures usually maps to one uv set.
  82940. */
  82941. coordinatesIndex: number;
  82942. private _coordinatesMode;
  82943. /**
  82944. * How a texture is mapped.
  82945. *
  82946. * | Value | Type | Description |
  82947. * | ----- | ----------------------------------- | ----------- |
  82948. * | 0 | EXPLICIT_MODE | |
  82949. * | 1 | SPHERICAL_MODE | |
  82950. * | 2 | PLANAR_MODE | |
  82951. * | 3 | CUBIC_MODE | |
  82952. * | 4 | PROJECTION_MODE | |
  82953. * | 5 | SKYBOX_MODE | |
  82954. * | 6 | INVCUBIC_MODE | |
  82955. * | 7 | EQUIRECTANGULAR_MODE | |
  82956. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82957. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82958. */
  82959. coordinatesMode: number;
  82960. /**
  82961. * | Value | Type | Description |
  82962. * | ----- | ------------------ | ----------- |
  82963. * | 0 | CLAMP_ADDRESSMODE | |
  82964. * | 1 | WRAP_ADDRESSMODE | |
  82965. * | 2 | MIRROR_ADDRESSMODE | |
  82966. */
  82967. wrapU: number;
  82968. /**
  82969. * | Value | Type | Description |
  82970. * | ----- | ------------------ | ----------- |
  82971. * | 0 | CLAMP_ADDRESSMODE | |
  82972. * | 1 | WRAP_ADDRESSMODE | |
  82973. * | 2 | MIRROR_ADDRESSMODE | |
  82974. */
  82975. wrapV: number;
  82976. /**
  82977. * | Value | Type | Description |
  82978. * | ----- | ------------------ | ----------- |
  82979. * | 0 | CLAMP_ADDRESSMODE | |
  82980. * | 1 | WRAP_ADDRESSMODE | |
  82981. * | 2 | MIRROR_ADDRESSMODE | |
  82982. */
  82983. wrapR: number;
  82984. /**
  82985. * With compliant hardware and browser (supporting anisotropic filtering)
  82986. * this defines the level of anisotropic filtering in the texture.
  82987. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82988. */
  82989. anisotropicFilteringLevel: number;
  82990. /**
  82991. * Define if the texture is a cube texture or if false a 2d texture.
  82992. */
  82993. isCube: boolean;
  82994. /**
  82995. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82996. */
  82997. is3D: boolean;
  82998. /**
  82999. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83000. * HDR texture are usually stored in linear space.
  83001. * This only impacts the PBR and Background materials
  83002. */
  83003. gammaSpace: boolean;
  83004. /**
  83005. * Gets whether or not the texture contains RGBD data.
  83006. */
  83007. readonly isRGBD: boolean;
  83008. /**
  83009. * Is Z inverted in the texture (useful in a cube texture).
  83010. */
  83011. invertZ: boolean;
  83012. /**
  83013. * Are mip maps generated for this texture or not.
  83014. */
  83015. readonly noMipmap: boolean;
  83016. /**
  83017. * @hidden
  83018. */
  83019. lodLevelInAlpha: boolean;
  83020. /**
  83021. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83022. */
  83023. lodGenerationOffset: number;
  83024. /**
  83025. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83026. */
  83027. lodGenerationScale: number;
  83028. /**
  83029. * Define if the texture is a render target.
  83030. */
  83031. isRenderTarget: boolean;
  83032. /**
  83033. * Define the unique id of the texture in the scene.
  83034. */
  83035. readonly uid: string;
  83036. /**
  83037. * Return a string representation of the texture.
  83038. * @returns the texture as a string
  83039. */
  83040. toString(): string;
  83041. /**
  83042. * Get the class name of the texture.
  83043. * @returns "BaseTexture"
  83044. */
  83045. getClassName(): string;
  83046. /**
  83047. * Define the list of animation attached to the texture.
  83048. */
  83049. animations: Animation[];
  83050. /**
  83051. * An event triggered when the texture is disposed.
  83052. */
  83053. onDisposeObservable: Observable<BaseTexture>;
  83054. private _onDisposeObserver;
  83055. /**
  83056. * Callback triggered when the texture has been disposed.
  83057. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83058. */
  83059. onDispose: () => void;
  83060. /**
  83061. * Define the current state of the loading sequence when in delayed load mode.
  83062. */
  83063. delayLoadState: number;
  83064. private _scene;
  83065. /** @hidden */
  83066. _texture: Nullable<InternalTexture>;
  83067. private _uid;
  83068. /**
  83069. * Define if the texture is preventinga material to render or not.
  83070. * If not and the texture is not ready, the engine will use a default black texture instead.
  83071. */
  83072. readonly isBlocking: boolean;
  83073. /**
  83074. * Instantiates a new BaseTexture.
  83075. * Base class of all the textures in babylon.
  83076. * It groups all the common properties the materials, post process, lights... might need
  83077. * in order to make a correct use of the texture.
  83078. * @param scene Define the scene the texture blongs to
  83079. */
  83080. constructor(scene: Nullable<Scene>);
  83081. /**
  83082. * Get the scene the texture belongs to.
  83083. * @returns the scene or null if undefined
  83084. */
  83085. getScene(): Nullable<Scene>;
  83086. /**
  83087. * Get the texture transform matrix used to offset tile the texture for istance.
  83088. * @returns the transformation matrix
  83089. */
  83090. getTextureMatrix(): Matrix;
  83091. /**
  83092. * Get the texture reflection matrix used to rotate/transform the reflection.
  83093. * @returns the reflection matrix
  83094. */
  83095. getReflectionTextureMatrix(): Matrix;
  83096. /**
  83097. * Get the underlying lower level texture from Babylon.
  83098. * @returns the insternal texture
  83099. */
  83100. getInternalTexture(): Nullable<InternalTexture>;
  83101. /**
  83102. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  83103. * @returns true if ready or not blocking
  83104. */
  83105. isReadyOrNotBlocking(): boolean;
  83106. /**
  83107. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83108. * @returns true if fully ready
  83109. */
  83110. isReady(): boolean;
  83111. private _cachedSize;
  83112. /**
  83113. * Get the size of the texture.
  83114. * @returns the texture size.
  83115. */
  83116. getSize(): ISize;
  83117. /**
  83118. * Get the base size of the texture.
  83119. * It can be different from the size if the texture has been resized for POT for instance
  83120. * @returns the base size
  83121. */
  83122. getBaseSize(): ISize;
  83123. /**
  83124. * Update the sampling mode of the texture.
  83125. * Default is Trilinear mode.
  83126. *
  83127. * | Value | Type | Description |
  83128. * | ----- | ------------------ | ----------- |
  83129. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83130. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83131. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83132. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83133. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83134. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83135. * | 7 | NEAREST_LINEAR | |
  83136. * | 8 | NEAREST_NEAREST | |
  83137. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83138. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83139. * | 11 | LINEAR_LINEAR | |
  83140. * | 12 | LINEAR_NEAREST | |
  83141. *
  83142. * > _mag_: magnification filter (close to the viewer)
  83143. * > _min_: minification filter (far from the viewer)
  83144. * > _mip_: filter used between mip map levels
  83145. *@param samplingMode Define the new sampling mode of the texture
  83146. */
  83147. updateSamplingMode(samplingMode: number): void;
  83148. /**
  83149. * Scales the texture if is `canRescale()`
  83150. * @param ratio the resize factor we want to use to rescale
  83151. */
  83152. scale(ratio: number): void;
  83153. /**
  83154. * Get if the texture can rescale.
  83155. */
  83156. readonly canRescale: boolean;
  83157. /** @hidden */
  83158. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83159. /** @hidden */
  83160. _rebuild(): void;
  83161. /**
  83162. * Triggers the load sequence in delayed load mode.
  83163. */
  83164. delayLoad(): void;
  83165. /**
  83166. * Clones the texture.
  83167. * @returns the cloned texture
  83168. */
  83169. clone(): Nullable<BaseTexture>;
  83170. /**
  83171. * Get the texture underlying type (INT, FLOAT...)
  83172. */
  83173. readonly textureType: number;
  83174. /**
  83175. * Get the texture underlying format (RGB, RGBA...)
  83176. */
  83177. readonly textureFormat: number;
  83178. /**
  83179. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83180. * This will returns an RGBA array buffer containing either in values (0-255) or
  83181. * float values (0-1) depending of the underlying buffer type.
  83182. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83183. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83184. * @param buffer defines a user defined buffer to fill with data (can be null)
  83185. * @returns The Array buffer containing the pixels data.
  83186. */
  83187. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83188. /**
  83189. * Release and destroy the underlying lower level texture aka internalTexture.
  83190. */
  83191. releaseInternalTexture(): void;
  83192. /**
  83193. * Get the polynomial representation of the texture data.
  83194. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  83195. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  83196. */
  83197. sphericalPolynomial: Nullable<SphericalPolynomial>;
  83198. /** @hidden */
  83199. readonly _lodTextureHigh: Nullable<BaseTexture>;
  83200. /** @hidden */
  83201. readonly _lodTextureMid: Nullable<BaseTexture>;
  83202. /** @hidden */
  83203. readonly _lodTextureLow: Nullable<BaseTexture>;
  83204. /**
  83205. * Dispose the texture and release its associated resources.
  83206. */
  83207. dispose(): void;
  83208. /**
  83209. * Serialize the texture into a JSON representation that can be parsed later on.
  83210. * @returns the JSON representation of the texture
  83211. */
  83212. serialize(): any;
  83213. /**
  83214. * Helper function to be called back once a list of texture contains only ready textures.
  83215. * @param textures Define the list of textures to wait for
  83216. * @param callback Define the callback triggered once the entire list will be ready
  83217. */
  83218. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  83219. }
  83220. }
  83221. declare module BABYLON {
  83222. /**
  83223. * Uniform buffer objects.
  83224. *
  83225. * Handles blocks of uniform on the GPU.
  83226. *
  83227. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83228. *
  83229. * For more information, please refer to :
  83230. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83231. */
  83232. export class UniformBuffer {
  83233. private _engine;
  83234. private _buffer;
  83235. private _data;
  83236. private _bufferData;
  83237. private _dynamic?;
  83238. private _uniformLocations;
  83239. private _uniformSizes;
  83240. private _uniformLocationPointer;
  83241. private _needSync;
  83242. private _noUBO;
  83243. private _currentEffect;
  83244. private static _MAX_UNIFORM_SIZE;
  83245. private static _tempBuffer;
  83246. /**
  83247. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83248. * This is dynamic to allow compat with webgl 1 and 2.
  83249. * You will need to pass the name of the uniform as well as the value.
  83250. */
  83251. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83252. /**
  83253. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83254. * This is dynamic to allow compat with webgl 1 and 2.
  83255. * You will need to pass the name of the uniform as well as the value.
  83256. */
  83257. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83258. /**
  83259. * Lambda to Update a single float in a uniform buffer.
  83260. * This is dynamic to allow compat with webgl 1 and 2.
  83261. * You will need to pass the name of the uniform as well as the value.
  83262. */
  83263. updateFloat: (name: string, x: number) => void;
  83264. /**
  83265. * Lambda to Update a vec2 of float in a uniform buffer.
  83266. * This is dynamic to allow compat with webgl 1 and 2.
  83267. * You will need to pass the name of the uniform as well as the value.
  83268. */
  83269. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83270. /**
  83271. * Lambda to Update a vec3 of float in a uniform buffer.
  83272. * This is dynamic to allow compat with webgl 1 and 2.
  83273. * You will need to pass the name of the uniform as well as the value.
  83274. */
  83275. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83276. /**
  83277. * Lambda to Update a vec4 of float in a uniform buffer.
  83278. * This is dynamic to allow compat with webgl 1 and 2.
  83279. * You will need to pass the name of the uniform as well as the value.
  83280. */
  83281. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83282. /**
  83283. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83284. * This is dynamic to allow compat with webgl 1 and 2.
  83285. * You will need to pass the name of the uniform as well as the value.
  83286. */
  83287. updateMatrix: (name: string, mat: Matrix) => void;
  83288. /**
  83289. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83290. * This is dynamic to allow compat with webgl 1 and 2.
  83291. * You will need to pass the name of the uniform as well as the value.
  83292. */
  83293. updateVector3: (name: string, vector: Vector3) => void;
  83294. /**
  83295. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83296. * This is dynamic to allow compat with webgl 1 and 2.
  83297. * You will need to pass the name of the uniform as well as the value.
  83298. */
  83299. updateVector4: (name: string, vector: Vector4) => void;
  83300. /**
  83301. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83302. * This is dynamic to allow compat with webgl 1 and 2.
  83303. * You will need to pass the name of the uniform as well as the value.
  83304. */
  83305. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83306. /**
  83307. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83308. * This is dynamic to allow compat with webgl 1 and 2.
  83309. * You will need to pass the name of the uniform as well as the value.
  83310. */
  83311. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83312. /**
  83313. * Instantiates a new Uniform buffer objects.
  83314. *
  83315. * Handles blocks of uniform on the GPU.
  83316. *
  83317. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83318. *
  83319. * For more information, please refer to :
  83320. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83321. * @param engine Define the engine the buffer is associated with
  83322. * @param data Define the data contained in the buffer
  83323. * @param dynamic Define if the buffer is updatable
  83324. */
  83325. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83326. /**
  83327. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83328. * or just falling back on setUniformXXX calls.
  83329. */
  83330. readonly useUbo: boolean;
  83331. /**
  83332. * Indicates if the WebGL underlying uniform buffer is in sync
  83333. * with the javascript cache data.
  83334. */
  83335. readonly isSync: boolean;
  83336. /**
  83337. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83338. * Also, a dynamic UniformBuffer will disable cache verification and always
  83339. * update the underlying WebGL uniform buffer to the GPU.
  83340. * @returns if Dynamic, otherwise false
  83341. */
  83342. isDynamic(): boolean;
  83343. /**
  83344. * The data cache on JS side.
  83345. * @returns the underlying data as a float array
  83346. */
  83347. getData(): Float32Array;
  83348. /**
  83349. * The underlying WebGL Uniform buffer.
  83350. * @returns the webgl buffer
  83351. */
  83352. getBuffer(): Nullable<WebGLBuffer>;
  83353. /**
  83354. * std140 layout specifies how to align data within an UBO structure.
  83355. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83356. * for specs.
  83357. */
  83358. private _fillAlignment;
  83359. /**
  83360. * Adds an uniform in the buffer.
  83361. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83362. * for the layout to be correct !
  83363. * @param name Name of the uniform, as used in the uniform block in the shader.
  83364. * @param size Data size, or data directly.
  83365. */
  83366. addUniform(name: string, size: number | number[]): void;
  83367. /**
  83368. * Adds a Matrix 4x4 to the uniform buffer.
  83369. * @param name Name of the uniform, as used in the uniform block in the shader.
  83370. * @param mat A 4x4 matrix.
  83371. */
  83372. addMatrix(name: string, mat: Matrix): void;
  83373. /**
  83374. * Adds a vec2 to the uniform buffer.
  83375. * @param name Name of the uniform, as used in the uniform block in the shader.
  83376. * @param x Define the x component value of the vec2
  83377. * @param y Define the y component value of the vec2
  83378. */
  83379. addFloat2(name: string, x: number, y: number): void;
  83380. /**
  83381. * Adds a vec3 to the uniform buffer.
  83382. * @param name Name of the uniform, as used in the uniform block in the shader.
  83383. * @param x Define the x component value of the vec3
  83384. * @param y Define the y component value of the vec3
  83385. * @param z Define the z component value of the vec3
  83386. */
  83387. addFloat3(name: string, x: number, y: number, z: number): void;
  83388. /**
  83389. * Adds a vec3 to the uniform buffer.
  83390. * @param name Name of the uniform, as used in the uniform block in the shader.
  83391. * @param color Define the vec3 from a Color
  83392. */
  83393. addColor3(name: string, color: Color3): void;
  83394. /**
  83395. * Adds a vec4 to the uniform buffer.
  83396. * @param name Name of the uniform, as used in the uniform block in the shader.
  83397. * @param color Define the rgb components from a Color
  83398. * @param alpha Define the a component of the vec4
  83399. */
  83400. addColor4(name: string, color: Color3, alpha: number): void;
  83401. /**
  83402. * Adds a vec3 to the uniform buffer.
  83403. * @param name Name of the uniform, as used in the uniform block in the shader.
  83404. * @param vector Define the vec3 components from a Vector
  83405. */
  83406. addVector3(name: string, vector: Vector3): void;
  83407. /**
  83408. * Adds a Matrix 3x3 to the uniform buffer.
  83409. * @param name Name of the uniform, as used in the uniform block in the shader.
  83410. */
  83411. addMatrix3x3(name: string): void;
  83412. /**
  83413. * Adds a Matrix 2x2 to the uniform buffer.
  83414. * @param name Name of the uniform, as used in the uniform block in the shader.
  83415. */
  83416. addMatrix2x2(name: string): void;
  83417. /**
  83418. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83419. */
  83420. create(): void;
  83421. /** @hidden */
  83422. _rebuild(): void;
  83423. /**
  83424. * Updates the WebGL Uniform Buffer on the GPU.
  83425. * If the `dynamic` flag is set to true, no cache comparison is done.
  83426. * Otherwise, the buffer will be updated only if the cache differs.
  83427. */
  83428. update(): void;
  83429. /**
  83430. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83431. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83432. * @param data Define the flattened data
  83433. * @param size Define the size of the data.
  83434. */
  83435. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83436. private _updateMatrix3x3ForUniform;
  83437. private _updateMatrix3x3ForEffect;
  83438. private _updateMatrix2x2ForEffect;
  83439. private _updateMatrix2x2ForUniform;
  83440. private _updateFloatForEffect;
  83441. private _updateFloatForUniform;
  83442. private _updateFloat2ForEffect;
  83443. private _updateFloat2ForUniform;
  83444. private _updateFloat3ForEffect;
  83445. private _updateFloat3ForUniform;
  83446. private _updateFloat4ForEffect;
  83447. private _updateFloat4ForUniform;
  83448. private _updateMatrixForEffect;
  83449. private _updateMatrixForUniform;
  83450. private _updateVector3ForEffect;
  83451. private _updateVector3ForUniform;
  83452. private _updateVector4ForEffect;
  83453. private _updateVector4ForUniform;
  83454. private _updateColor3ForEffect;
  83455. private _updateColor3ForUniform;
  83456. private _updateColor4ForEffect;
  83457. private _updateColor4ForUniform;
  83458. /**
  83459. * Sets a sampler uniform on the effect.
  83460. * @param name Define the name of the sampler.
  83461. * @param texture Define the texture to set in the sampler
  83462. */
  83463. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83464. /**
  83465. * Directly updates the value of the uniform in the cache AND on the GPU.
  83466. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83467. * @param data Define the flattened data
  83468. */
  83469. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83470. /**
  83471. * Binds this uniform buffer to an effect.
  83472. * @param effect Define the effect to bind the buffer to
  83473. * @param name Name of the uniform block in the shader.
  83474. */
  83475. bindToEffect(effect: Effect, name: string): void;
  83476. /**
  83477. * Disposes the uniform buffer.
  83478. */
  83479. dispose(): void;
  83480. }
  83481. }
  83482. declare module BABYLON {
  83483. /**
  83484. * This represents the required contract to create a new type of texture loader.
  83485. */
  83486. export interface IInternalTextureLoader {
  83487. /**
  83488. * Defines wether the loader supports cascade loading the different faces.
  83489. */
  83490. supportCascades: boolean;
  83491. /**
  83492. * This returns if the loader support the current file information.
  83493. * @param extension defines the file extension of the file being loaded
  83494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83495. * @param fallback defines the fallback internal texture if any
  83496. * @param isBase64 defines whether the texture is encoded as a base64
  83497. * @param isBuffer defines whether the texture data are stored as a buffer
  83498. * @returns true if the loader can load the specified file
  83499. */
  83500. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83501. /**
  83502. * Transform the url before loading if required.
  83503. * @param rootUrl the url of the texture
  83504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83505. * @returns the transformed texture
  83506. */
  83507. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83508. /**
  83509. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83510. * @param rootUrl the url of the texture
  83511. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83512. * @returns the fallback texture
  83513. */
  83514. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83515. /**
  83516. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83517. * @param data contains the texture data
  83518. * @param texture defines the BabylonJS internal texture
  83519. * @param createPolynomials will be true if polynomials have been requested
  83520. * @param onLoad defines the callback to trigger once the texture is ready
  83521. * @param onError defines the callback to trigger in case of error
  83522. */
  83523. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83524. /**
  83525. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83526. * @param data contains the texture data
  83527. * @param texture defines the BabylonJS internal texture
  83528. * @param callback defines the method to call once ready to upload
  83529. */
  83530. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83531. }
  83532. }
  83533. declare module BABYLON {
  83534. /**
  83535. * Creation options of the multi render target texture.
  83536. */
  83537. export interface IMultiRenderTargetOptions {
  83538. /**
  83539. * Define if the texture needs to create mip maps after render.
  83540. */
  83541. generateMipMaps?: boolean;
  83542. /**
  83543. * Define the types of all the draw buffers we want to create
  83544. */
  83545. types?: number[];
  83546. /**
  83547. * Define the sampling modes of all the draw buffers we want to create
  83548. */
  83549. samplingModes?: number[];
  83550. /**
  83551. * Define if a depth buffer is required
  83552. */
  83553. generateDepthBuffer?: boolean;
  83554. /**
  83555. * Define if a stencil buffer is required
  83556. */
  83557. generateStencilBuffer?: boolean;
  83558. /**
  83559. * Define if a depth texture is required instead of a depth buffer
  83560. */
  83561. generateDepthTexture?: boolean;
  83562. /**
  83563. * Define the number of desired draw buffers
  83564. */
  83565. textureCount?: number;
  83566. /**
  83567. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83568. */
  83569. doNotChangeAspectRatio?: boolean;
  83570. /**
  83571. * Define the default type of the buffers we are creating
  83572. */
  83573. defaultType?: number;
  83574. }
  83575. /**
  83576. * A multi render target, like a render target provides the ability to render to a texture.
  83577. * Unlike the render target, it can render to several draw buffers in one draw.
  83578. * This is specially interesting in deferred rendering or for any effects requiring more than
  83579. * just one color from a single pass.
  83580. */
  83581. export class MultiRenderTarget extends RenderTargetTexture {
  83582. private _internalTextures;
  83583. private _textures;
  83584. private _multiRenderTargetOptions;
  83585. /**
  83586. * Get if draw buffers are currently supported by the used hardware and browser.
  83587. */
  83588. readonly isSupported: boolean;
  83589. /**
  83590. * Get the list of textures generated by the multi render target.
  83591. */
  83592. readonly textures: Texture[];
  83593. /**
  83594. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83595. */
  83596. readonly depthTexture: Texture;
  83597. /**
  83598. * Set the wrapping mode on U of all the textures we are rendering to.
  83599. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83600. */
  83601. wrapU: number;
  83602. /**
  83603. * Set the wrapping mode on V of all the textures we are rendering to.
  83604. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83605. */
  83606. wrapV: number;
  83607. /**
  83608. * Instantiate a new multi render target texture.
  83609. * A multi render target, like a render target provides the ability to render to a texture.
  83610. * Unlike the render target, it can render to several draw buffers in one draw.
  83611. * This is specially interesting in deferred rendering or for any effects requiring more than
  83612. * just one color from a single pass.
  83613. * @param name Define the name of the texture
  83614. * @param size Define the size of the buffers to render to
  83615. * @param count Define the number of target we are rendering into
  83616. * @param scene Define the scene the texture belongs to
  83617. * @param options Define the options used to create the multi render target
  83618. */
  83619. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83620. /** @hidden */
  83621. _rebuild(): void;
  83622. private _createInternalTextures;
  83623. private _createTextures;
  83624. /**
  83625. * Define the number of samples used if MSAA is enabled.
  83626. */
  83627. samples: number;
  83628. /**
  83629. * Resize all the textures in the multi render target.
  83630. * Be carrefull as it will recreate all the data in the new texture.
  83631. * @param size Define the new size
  83632. */
  83633. resize(size: any): void;
  83634. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83635. /**
  83636. * Dispose the render targets and their associated resources
  83637. */
  83638. dispose(): void;
  83639. /**
  83640. * Release all the underlying texture used as draw buffers.
  83641. */
  83642. releaseInternalTextures(): void;
  83643. }
  83644. }
  83645. declare module BABYLON {
  83646. /**
  83647. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83649. */
  83650. export class Analyser {
  83651. /**
  83652. * Gets or sets the smoothing
  83653. * @ignorenaming
  83654. */
  83655. SMOOTHING: number;
  83656. /**
  83657. * Gets or sets the FFT table size
  83658. * @ignorenaming
  83659. */
  83660. FFT_SIZE: number;
  83661. /**
  83662. * Gets or sets the bar graph amplitude
  83663. * @ignorenaming
  83664. */
  83665. BARGRAPHAMPLITUDE: number;
  83666. /**
  83667. * Gets or sets the position of the debug canvas
  83668. * @ignorenaming
  83669. */
  83670. DEBUGCANVASPOS: {
  83671. x: number;
  83672. y: number;
  83673. };
  83674. /**
  83675. * Gets or sets the debug canvas size
  83676. * @ignorenaming
  83677. */
  83678. DEBUGCANVASSIZE: {
  83679. width: number;
  83680. height: number;
  83681. };
  83682. private _byteFreqs;
  83683. private _byteTime;
  83684. private _floatFreqs;
  83685. private _webAudioAnalyser;
  83686. private _debugCanvas;
  83687. private _debugCanvasContext;
  83688. private _scene;
  83689. private _registerFunc;
  83690. private _audioEngine;
  83691. /**
  83692. * Creates a new analyser
  83693. * @param scene defines hosting scene
  83694. */
  83695. constructor(scene: Scene);
  83696. /**
  83697. * Get the number of data values you will have to play with for the visualization
  83698. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83699. * @returns a number
  83700. */
  83701. getFrequencyBinCount(): number;
  83702. /**
  83703. * Gets the current frequency data as a byte array
  83704. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83705. * @returns a Uint8Array
  83706. */
  83707. getByteFrequencyData(): Uint8Array;
  83708. /**
  83709. * Gets the current waveform as a byte array
  83710. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83711. * @returns a Uint8Array
  83712. */
  83713. getByteTimeDomainData(): Uint8Array;
  83714. /**
  83715. * Gets the current frequency data as a float array
  83716. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83717. * @returns a Float32Array
  83718. */
  83719. getFloatFrequencyData(): Float32Array;
  83720. /**
  83721. * Renders the debug canvas
  83722. */
  83723. drawDebugCanvas(): void;
  83724. /**
  83725. * Stops rendering the debug canvas and removes it
  83726. */
  83727. stopDebugCanvas(): void;
  83728. /**
  83729. * Connects two audio nodes
  83730. * @param inputAudioNode defines first node to connect
  83731. * @param outputAudioNode defines second node to connect
  83732. */
  83733. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83734. /**
  83735. * Releases all associated resources
  83736. */
  83737. dispose(): void;
  83738. }
  83739. }
  83740. declare module BABYLON {
  83741. /**
  83742. * This represents an audio engine and it is responsible
  83743. * to play, synchronize and analyse sounds throughout the application.
  83744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83745. */
  83746. export interface IAudioEngine extends IDisposable {
  83747. /**
  83748. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83749. */
  83750. readonly canUseWebAudio: boolean;
  83751. /**
  83752. * Gets the current AudioContext if available.
  83753. */
  83754. readonly audioContext: Nullable<AudioContext>;
  83755. /**
  83756. * The master gain node defines the global audio volume of your audio engine.
  83757. */
  83758. readonly masterGain: GainNode;
  83759. /**
  83760. * Gets whether or not mp3 are supported by your browser.
  83761. */
  83762. readonly isMP3supported: boolean;
  83763. /**
  83764. * Gets whether or not ogg are supported by your browser.
  83765. */
  83766. readonly isOGGsupported: boolean;
  83767. /**
  83768. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83769. * @ignoreNaming
  83770. */
  83771. WarnedWebAudioUnsupported: boolean;
  83772. /**
  83773. * Defines if the audio engine relies on a custom unlocked button.
  83774. * In this case, the embedded button will not be displayed.
  83775. */
  83776. useCustomUnlockedButton: boolean;
  83777. /**
  83778. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83779. */
  83780. readonly unlocked: boolean;
  83781. /**
  83782. * Event raised when audio has been unlocked on the browser.
  83783. */
  83784. onAudioUnlockedObservable: Observable<AudioEngine>;
  83785. /**
  83786. * Event raised when audio has been locked on the browser.
  83787. */
  83788. onAudioLockedObservable: Observable<AudioEngine>;
  83789. /**
  83790. * Flags the audio engine in Locked state.
  83791. * This happens due to new browser policies preventing audio to autoplay.
  83792. */
  83793. lock(): void;
  83794. /**
  83795. * Unlocks the audio engine once a user action has been done on the dom.
  83796. * This is helpful to resume play once browser policies have been satisfied.
  83797. */
  83798. unlock(): void;
  83799. }
  83800. /**
  83801. * This represents the default audio engine used in babylon.
  83802. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83804. */
  83805. export class AudioEngine implements IAudioEngine {
  83806. private _audioContext;
  83807. private _audioContextInitialized;
  83808. private _muteButton;
  83809. private _hostElement;
  83810. /**
  83811. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83812. */
  83813. canUseWebAudio: boolean;
  83814. /**
  83815. * The master gain node defines the global audio volume of your audio engine.
  83816. */
  83817. masterGain: GainNode;
  83818. /**
  83819. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83820. * @ignoreNaming
  83821. */
  83822. WarnedWebAudioUnsupported: boolean;
  83823. /**
  83824. * Gets whether or not mp3 are supported by your browser.
  83825. */
  83826. isMP3supported: boolean;
  83827. /**
  83828. * Gets whether or not ogg are supported by your browser.
  83829. */
  83830. isOGGsupported: boolean;
  83831. /**
  83832. * Gets whether audio has been unlocked on the device.
  83833. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83834. * a user interaction has happened.
  83835. */
  83836. unlocked: boolean;
  83837. /**
  83838. * Defines if the audio engine relies on a custom unlocked button.
  83839. * In this case, the embedded button will not be displayed.
  83840. */
  83841. useCustomUnlockedButton: boolean;
  83842. /**
  83843. * Event raised when audio has been unlocked on the browser.
  83844. */
  83845. onAudioUnlockedObservable: Observable<AudioEngine>;
  83846. /**
  83847. * Event raised when audio has been locked on the browser.
  83848. */
  83849. onAudioLockedObservable: Observable<AudioEngine>;
  83850. /**
  83851. * Gets the current AudioContext if available.
  83852. */
  83853. readonly audioContext: Nullable<AudioContext>;
  83854. private _connectedAnalyser;
  83855. /**
  83856. * Instantiates a new audio engine.
  83857. *
  83858. * There should be only one per page as some browsers restrict the number
  83859. * of audio contexts you can create.
  83860. * @param hostElement defines the host element where to display the mute icon if necessary
  83861. */
  83862. constructor(hostElement?: Nullable<HTMLElement>);
  83863. /**
  83864. * Flags the audio engine in Locked state.
  83865. * This happens due to new browser policies preventing audio to autoplay.
  83866. */
  83867. lock(): void;
  83868. /**
  83869. * Unlocks the audio engine once a user action has been done on the dom.
  83870. * This is helpful to resume play once browser policies have been satisfied.
  83871. */
  83872. unlock(): void;
  83873. private _resumeAudioContext;
  83874. private _initializeAudioContext;
  83875. private _tryToRun;
  83876. private _triggerRunningState;
  83877. private _triggerSuspendedState;
  83878. private _displayMuteButton;
  83879. private _moveButtonToTopLeft;
  83880. private _onResize;
  83881. private _hideMuteButton;
  83882. /**
  83883. * Destroy and release the resources associated with the audio ccontext.
  83884. */
  83885. dispose(): void;
  83886. /**
  83887. * Gets the global volume sets on the master gain.
  83888. * @returns the global volume if set or -1 otherwise
  83889. */
  83890. getGlobalVolume(): number;
  83891. /**
  83892. * Sets the global volume of your experience (sets on the master gain).
  83893. * @param newVolume Defines the new global volume of the application
  83894. */
  83895. setGlobalVolume(newVolume: number): void;
  83896. /**
  83897. * Connect the audio engine to an audio analyser allowing some amazing
  83898. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83900. * @param analyser The analyser to connect to the engine
  83901. */
  83902. connectToAnalyser(analyser: Analyser): void;
  83903. }
  83904. }
  83905. declare module BABYLON {
  83906. /**
  83907. * Interface used to present a loading screen while loading a scene
  83908. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83909. */
  83910. export interface ILoadingScreen {
  83911. /**
  83912. * Function called to display the loading screen
  83913. */
  83914. displayLoadingUI: () => void;
  83915. /**
  83916. * Function called to hide the loading screen
  83917. */
  83918. hideLoadingUI: () => void;
  83919. /**
  83920. * Gets or sets the color to use for the background
  83921. */
  83922. loadingUIBackgroundColor: string;
  83923. /**
  83924. * Gets or sets the text to display while loading
  83925. */
  83926. loadingUIText: string;
  83927. }
  83928. /**
  83929. * Class used for the default loading screen
  83930. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83931. */
  83932. export class DefaultLoadingScreen implements ILoadingScreen {
  83933. private _renderingCanvas;
  83934. private _loadingText;
  83935. private _loadingDivBackgroundColor;
  83936. private _loadingDiv;
  83937. private _loadingTextDiv;
  83938. /**
  83939. * Creates a new default loading screen
  83940. * @param _renderingCanvas defines the canvas used to render the scene
  83941. * @param _loadingText defines the default text to display
  83942. * @param _loadingDivBackgroundColor defines the default background color
  83943. */
  83944. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83945. /**
  83946. * Function called to display the loading screen
  83947. */
  83948. displayLoadingUI(): void;
  83949. /**
  83950. * Function called to hide the loading screen
  83951. */
  83952. hideLoadingUI(): void;
  83953. /**
  83954. * Gets or sets the text to display while loading
  83955. */
  83956. loadingUIText: string;
  83957. /**
  83958. * Gets or sets the color to use for the background
  83959. */
  83960. loadingUIBackgroundColor: string;
  83961. private _resizeLoadingUI;
  83962. }
  83963. }
  83964. declare module BABYLON {
  83965. /**
  83966. * Settings for finer control over video usage
  83967. */
  83968. export interface VideoTextureSettings {
  83969. /**
  83970. * Applies `autoplay` to video, if specified
  83971. */
  83972. autoPlay?: boolean;
  83973. /**
  83974. * Applies `loop` to video, if specified
  83975. */
  83976. loop?: boolean;
  83977. /**
  83978. * Automatically updates internal texture from video at every frame in the render loop
  83979. */
  83980. autoUpdateTexture: boolean;
  83981. /**
  83982. * Image src displayed during the video loading or until the user interacts with the video.
  83983. */
  83984. poster?: string;
  83985. }
  83986. /**
  83987. * If you want to display a video in your scene, this is the special texture for that.
  83988. * This special texture works similar to other textures, with the exception of a few parameters.
  83989. * @see https://doc.babylonjs.com/how_to/video_texture
  83990. */
  83991. export class VideoTexture extends Texture {
  83992. /**
  83993. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83994. */
  83995. readonly autoUpdateTexture: boolean;
  83996. /**
  83997. * The video instance used by the texture internally
  83998. */
  83999. readonly video: HTMLVideoElement;
  84000. private _onUserActionRequestedObservable;
  84001. /**
  84002. * Event triggerd when a dom action is required by the user to play the video.
  84003. * This happens due to recent changes in browser policies preventing video to auto start.
  84004. */
  84005. readonly onUserActionRequestedObservable: Observable<Texture>;
  84006. private _generateMipMaps;
  84007. private _engine;
  84008. private _stillImageCaptured;
  84009. private _displayingPosterTexture;
  84010. private _settings;
  84011. private _createInternalTextureOnEvent;
  84012. /**
  84013. * Creates a video texture.
  84014. * If you want to display a video in your scene, this is the special texture for that.
  84015. * This special texture works similar to other textures, with the exception of a few parameters.
  84016. * @see https://doc.babylonjs.com/how_to/video_texture
  84017. * @param name optional name, will detect from video source, if not defined
  84018. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84019. * @param scene is obviously the current scene.
  84020. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84021. * @param invertY is false by default but can be used to invert video on Y axis
  84022. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84023. * @param settings allows finer control over video usage
  84024. */
  84025. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84026. private _getName;
  84027. private _getVideo;
  84028. private _createInternalTexture;
  84029. private reset;
  84030. /**
  84031. * @hidden Internal method to initiate `update`.
  84032. */
  84033. _rebuild(): void;
  84034. /**
  84035. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84036. */
  84037. update(): void;
  84038. /**
  84039. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84040. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84041. */
  84042. updateTexture(isVisible: boolean): void;
  84043. protected _updateInternalTexture: () => void;
  84044. /**
  84045. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84046. * @param url New url.
  84047. */
  84048. updateURL(url: string): void;
  84049. /**
  84050. * Dispose the texture and release its associated resources.
  84051. */
  84052. dispose(): void;
  84053. /**
  84054. * Creates a video texture straight from a stream.
  84055. * @param scene Define the scene the texture should be created in
  84056. * @param stream Define the stream the texture should be created from
  84057. * @returns The created video texture as a promise
  84058. */
  84059. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84060. /**
  84061. * Creates a video texture straight from your WebCam video feed.
  84062. * @param scene Define the scene the texture should be created in
  84063. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84064. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84065. * @returns The created video texture as a promise
  84066. */
  84067. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84068. minWidth: number;
  84069. maxWidth: number;
  84070. minHeight: number;
  84071. maxHeight: number;
  84072. deviceId: string;
  84073. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84074. /**
  84075. * Creates a video texture straight from your WebCam video feed.
  84076. * @param scene Define the scene the texture should be created in
  84077. * @param onReady Define a callback to triggered once the texture will be ready
  84078. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84079. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84080. */
  84081. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  84082. minWidth: number;
  84083. maxWidth: number;
  84084. minHeight: number;
  84085. maxHeight: number;
  84086. deviceId: string;
  84087. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  84088. }
  84089. }
  84090. declare module BABYLON {
  84091. /**
  84092. * Interface for attribute information associated with buffer instanciation
  84093. */
  84094. export class InstancingAttributeInfo {
  84095. /**
  84096. * Index/offset of the attribute in the vertex shader
  84097. */
  84098. index: number;
  84099. /**
  84100. * size of the attribute, 1, 2, 3 or 4
  84101. */
  84102. attributeSize: number;
  84103. /**
  84104. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  84105. * default is FLOAT
  84106. */
  84107. attribyteType: number;
  84108. /**
  84109. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  84110. */
  84111. normalized: boolean;
  84112. /**
  84113. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  84114. */
  84115. offset: number;
  84116. /**
  84117. * Name of the GLSL attribute, for debugging purpose only
  84118. */
  84119. attributeName: string;
  84120. }
  84121. /**
  84122. * Define options used to create a depth texture
  84123. */
  84124. export class DepthTextureCreationOptions {
  84125. /** Specifies whether or not a stencil should be allocated in the texture */
  84126. generateStencil?: boolean;
  84127. /** Specifies whether or not bilinear filtering is enable on the texture */
  84128. bilinearFiltering?: boolean;
  84129. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84130. comparisonFunction?: number;
  84131. /** Specifies if the created texture is a cube texture */
  84132. isCube?: boolean;
  84133. }
  84134. /**
  84135. * Class used to describe the capabilities of the engine relatively to the current browser
  84136. */
  84137. export class EngineCapabilities {
  84138. /** Maximum textures units per fragment shader */
  84139. maxTexturesImageUnits: number;
  84140. /** Maximum texture units per vertex shader */
  84141. maxVertexTextureImageUnits: number;
  84142. /** Maximum textures units in the entire pipeline */
  84143. maxCombinedTexturesImageUnits: number;
  84144. /** Maximum texture size */
  84145. maxTextureSize: number;
  84146. /** Maximum cube texture size */
  84147. maxCubemapTextureSize: number;
  84148. /** Maximum render texture size */
  84149. maxRenderTextureSize: number;
  84150. /** Maximum number of vertex attributes */
  84151. maxVertexAttribs: number;
  84152. /** Maximum number of varyings */
  84153. maxVaryingVectors: number;
  84154. /** Maximum number of uniforms per vertex shader */
  84155. maxVertexUniformVectors: number;
  84156. /** Maximum number of uniforms per fragment shader */
  84157. maxFragmentUniformVectors: number;
  84158. /** Defines if standard derivates (dx/dy) are supported */
  84159. standardDerivatives: boolean;
  84160. /** Defines if s3tc texture compression is supported */
  84161. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84162. /** Defines if pvrtc texture compression is supported */
  84163. pvrtc: any;
  84164. /** Defines if etc1 texture compression is supported */
  84165. etc1: any;
  84166. /** Defines if etc2 texture compression is supported */
  84167. etc2: any;
  84168. /** Defines if astc texture compression is supported */
  84169. astc: any;
  84170. /** Defines if float textures are supported */
  84171. textureFloat: boolean;
  84172. /** Defines if vertex array objects are supported */
  84173. vertexArrayObject: boolean;
  84174. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84175. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84176. /** Gets the maximum level of anisotropy supported */
  84177. maxAnisotropy: number;
  84178. /** Defines if instancing is supported */
  84179. instancedArrays: boolean;
  84180. /** Defines if 32 bits indices are supported */
  84181. uintIndices: boolean;
  84182. /** Defines if high precision shaders are supported */
  84183. highPrecisionShaderSupported: boolean;
  84184. /** Defines if depth reading in the fragment shader is supported */
  84185. fragmentDepthSupported: boolean;
  84186. /** Defines if float texture linear filtering is supported*/
  84187. textureFloatLinearFiltering: boolean;
  84188. /** Defines if rendering to float textures is supported */
  84189. textureFloatRender: boolean;
  84190. /** Defines if half float textures are supported*/
  84191. textureHalfFloat: boolean;
  84192. /** Defines if half float texture linear filtering is supported*/
  84193. textureHalfFloatLinearFiltering: boolean;
  84194. /** Defines if rendering to half float textures is supported */
  84195. textureHalfFloatRender: boolean;
  84196. /** Defines if textureLOD shader command is supported */
  84197. textureLOD: boolean;
  84198. /** Defines if draw buffers extension is supported */
  84199. drawBuffersExtension: boolean;
  84200. /** Defines if depth textures are supported */
  84201. depthTextureExtension: boolean;
  84202. /** Defines if float color buffer are supported */
  84203. colorBufferFloat: boolean;
  84204. /** Gets disjoint timer query extension (null if not supported) */
  84205. timerQuery: EXT_disjoint_timer_query;
  84206. /** Defines if timestamp can be used with timer query */
  84207. canUseTimestampForTimerQuery: boolean;
  84208. /** Function used to let the system compiles shaders in background */
  84209. parallelShaderCompile: {
  84210. MAX_SHADER_COMPILER_THREADS_KHR: number;
  84211. maxShaderCompilerThreadsKHR: (thread: number) => void;
  84212. COMPLETION_STATUS_KHR: number;
  84213. };
  84214. }
  84215. /** Interface defining initialization parameters for Engine class */
  84216. export interface EngineOptions extends WebGLContextAttributes {
  84217. /**
  84218. * Defines if the engine should no exceed a specified device ratio
  84219. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  84220. */
  84221. limitDeviceRatio?: number;
  84222. /**
  84223. * Defines if webvr should be enabled automatically
  84224. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84225. */
  84226. autoEnableWebVR?: boolean;
  84227. /**
  84228. * Defines if webgl2 should be turned off even if supported
  84229. * @see http://doc.babylonjs.com/features/webgl2
  84230. */
  84231. disableWebGL2Support?: boolean;
  84232. /**
  84233. * Defines if webaudio should be initialized as well
  84234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84235. */
  84236. audioEngine?: boolean;
  84237. /**
  84238. * Defines if animations should run using a deterministic lock step
  84239. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84240. */
  84241. deterministicLockstep?: boolean;
  84242. /** Defines the maximum steps to use with deterministic lock step mode */
  84243. lockstepMaxSteps?: number;
  84244. /**
  84245. * Defines that engine should ignore context lost events
  84246. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  84247. */
  84248. doNotHandleContextLost?: boolean;
  84249. /**
  84250. * Defines that engine should ignore modifying touch action attribute and style
  84251. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  84252. */
  84253. doNotHandleTouchAction?: boolean;
  84254. /**
  84255. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  84256. */
  84257. useHighPrecisionFloats?: boolean;
  84258. }
  84259. /**
  84260. * Defines the interface used by display changed events
  84261. */
  84262. export interface IDisplayChangedEventArgs {
  84263. /** Gets the vrDisplay object (if any) */
  84264. vrDisplay: Nullable<any>;
  84265. /** Gets a boolean indicating if webVR is supported */
  84266. vrSupported: boolean;
  84267. }
  84268. /**
  84269. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  84270. */
  84271. export class Engine {
  84272. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  84273. static ExceptionList: ({
  84274. key: string;
  84275. capture: string;
  84276. captureConstraint: number;
  84277. targets: string[];
  84278. } | {
  84279. key: string;
  84280. capture: null;
  84281. captureConstraint: null;
  84282. targets: string[];
  84283. })[];
  84284. /** Gets the list of created engines */
  84285. static readonly Instances: Engine[];
  84286. /**
  84287. * Gets the latest created engine
  84288. */
  84289. static readonly LastCreatedEngine: Nullable<Engine>;
  84290. /**
  84291. * Gets the latest created scene
  84292. */
  84293. static readonly LastCreatedScene: Nullable<Scene>;
  84294. /**
  84295. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  84296. * @param flag defines which part of the materials must be marked as dirty
  84297. * @param predicate defines a predicate used to filter which materials should be affected
  84298. */
  84299. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  84300. /**
  84301. * Hidden
  84302. */
  84303. static _TextureLoaders: IInternalTextureLoader[];
  84304. /** Defines that alpha blending is disabled */
  84305. static readonly ALPHA_DISABLE: number;
  84306. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  84307. static readonly ALPHA_ADD: number;
  84308. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  84309. static readonly ALPHA_COMBINE: number;
  84310. /** Defines that alpha blending to DEST - SRC * DEST */
  84311. static readonly ALPHA_SUBTRACT: number;
  84312. /** Defines that alpha blending to SRC * DEST */
  84313. static readonly ALPHA_MULTIPLY: number;
  84314. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  84315. static readonly ALPHA_MAXIMIZED: number;
  84316. /** Defines that alpha blending to SRC + DEST */
  84317. static readonly ALPHA_ONEONE: number;
  84318. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  84319. static readonly ALPHA_PREMULTIPLIED: number;
  84320. /**
  84321. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  84322. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  84323. */
  84324. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  84325. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  84326. static readonly ALPHA_INTERPOLATE: number;
  84327. /**
  84328. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  84329. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  84330. */
  84331. static readonly ALPHA_SCREENMODE: number;
  84332. /** Defines that the ressource is not delayed*/
  84333. static readonly DELAYLOADSTATE_NONE: number;
  84334. /** Defines that the ressource was successfully delay loaded */
  84335. static readonly DELAYLOADSTATE_LOADED: number;
  84336. /** Defines that the ressource is currently delay loading */
  84337. static readonly DELAYLOADSTATE_LOADING: number;
  84338. /** Defines that the ressource is delayed and has not started loading */
  84339. static readonly DELAYLOADSTATE_NOTLOADED: number;
  84340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  84341. static readonly NEVER: number;
  84342. /** 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 */
  84343. static readonly ALWAYS: number;
  84344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  84345. static readonly LESS: number;
  84346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  84347. static readonly EQUAL: number;
  84348. /** 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 */
  84349. static readonly LEQUAL: number;
  84350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84351. static readonly GREATER: number;
  84352. /** 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 */
  84353. static readonly GEQUAL: number;
  84354. /** 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 */
  84355. static readonly NOTEQUAL: number;
  84356. /** Passed to stencilOperation to specify that stencil value must be kept */
  84357. static readonly KEEP: number;
  84358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84359. static readonly REPLACE: number;
  84360. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84361. static readonly INCR: number;
  84362. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84363. static readonly DECR: number;
  84364. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84365. static readonly INVERT: number;
  84366. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84367. static readonly INCR_WRAP: number;
  84368. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84369. static readonly DECR_WRAP: number;
  84370. /** Texture is not repeating outside of 0..1 UVs */
  84371. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84372. /** Texture is repeating outside of 0..1 UVs */
  84373. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84374. /** Texture is repeating and mirrored */
  84375. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84376. /** ALPHA */
  84377. static readonly TEXTUREFORMAT_ALPHA: number;
  84378. /** LUMINANCE */
  84379. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84380. /** LUMINANCE_ALPHA */
  84381. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84382. /** RGB */
  84383. static readonly TEXTUREFORMAT_RGB: number;
  84384. /** RGBA */
  84385. static readonly TEXTUREFORMAT_RGBA: number;
  84386. /** RED */
  84387. static readonly TEXTUREFORMAT_RED: number;
  84388. /** RED (2nd reference) */
  84389. static readonly TEXTUREFORMAT_R: number;
  84390. /** RG */
  84391. static readonly TEXTUREFORMAT_RG: number;
  84392. /** RED_INTEGER */
  84393. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84394. /** RED_INTEGER (2nd reference) */
  84395. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84396. /** RG_INTEGER */
  84397. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84398. /** RGB_INTEGER */
  84399. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84400. /** RGBA_INTEGER */
  84401. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84402. /** UNSIGNED_BYTE */
  84403. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84404. /** UNSIGNED_BYTE (2nd reference) */
  84405. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84406. /** FLOAT */
  84407. static readonly TEXTURETYPE_FLOAT: number;
  84408. /** HALF_FLOAT */
  84409. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84410. /** BYTE */
  84411. static readonly TEXTURETYPE_BYTE: number;
  84412. /** SHORT */
  84413. static readonly TEXTURETYPE_SHORT: number;
  84414. /** UNSIGNED_SHORT */
  84415. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84416. /** INT */
  84417. static readonly TEXTURETYPE_INT: number;
  84418. /** UNSIGNED_INT */
  84419. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84420. /** UNSIGNED_SHORT_4_4_4_4 */
  84421. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84422. /** UNSIGNED_SHORT_5_5_5_1 */
  84423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84424. /** UNSIGNED_SHORT_5_6_5 */
  84425. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84426. /** UNSIGNED_INT_2_10_10_10_REV */
  84427. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84428. /** UNSIGNED_INT_24_8 */
  84429. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84430. /** UNSIGNED_INT_10F_11F_11F_REV */
  84431. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84432. /** UNSIGNED_INT_5_9_9_9_REV */
  84433. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84434. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84435. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84436. /** nearest is mag = nearest and min = nearest and mip = linear */
  84437. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84439. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84440. /** Trilinear is mag = linear and min = linear and mip = linear */
  84441. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84442. /** nearest is mag = nearest and min = nearest and mip = linear */
  84443. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84445. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84446. /** Trilinear is mag = linear and min = linear and mip = linear */
  84447. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84448. /** mag = nearest and min = nearest and mip = nearest */
  84449. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84450. /** mag = nearest and min = linear and mip = nearest */
  84451. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84452. /** mag = nearest and min = linear and mip = linear */
  84453. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84454. /** mag = nearest and min = linear and mip = none */
  84455. static readonly TEXTURE_NEAREST_LINEAR: number;
  84456. /** mag = nearest and min = nearest and mip = none */
  84457. static readonly TEXTURE_NEAREST_NEAREST: number;
  84458. /** mag = linear and min = nearest and mip = nearest */
  84459. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84460. /** mag = linear and min = nearest and mip = linear */
  84461. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84462. /** mag = linear and min = linear and mip = none */
  84463. static readonly TEXTURE_LINEAR_LINEAR: number;
  84464. /** mag = linear and min = nearest and mip = none */
  84465. static readonly TEXTURE_LINEAR_NEAREST: number;
  84466. /** Explicit coordinates mode */
  84467. static readonly TEXTURE_EXPLICIT_MODE: number;
  84468. /** Spherical coordinates mode */
  84469. static readonly TEXTURE_SPHERICAL_MODE: number;
  84470. /** Planar coordinates mode */
  84471. static readonly TEXTURE_PLANAR_MODE: number;
  84472. /** Cubic coordinates mode */
  84473. static readonly TEXTURE_CUBIC_MODE: number;
  84474. /** Projection coordinates mode */
  84475. static readonly TEXTURE_PROJECTION_MODE: number;
  84476. /** Skybox coordinates mode */
  84477. static readonly TEXTURE_SKYBOX_MODE: number;
  84478. /** Inverse Cubic coordinates mode */
  84479. static readonly TEXTURE_INVCUBIC_MODE: number;
  84480. /** Equirectangular coordinates mode */
  84481. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84482. /** Equirectangular Fixed coordinates mode */
  84483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84484. /** Equirectangular Fixed Mirrored coordinates mode */
  84485. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84486. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84487. static readonly SCALEMODE_FLOOR: number;
  84488. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84489. static readonly SCALEMODE_NEAREST: number;
  84490. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84491. static readonly SCALEMODE_CEILING: number;
  84492. /**
  84493. * Returns the current version of the framework
  84494. */
  84495. static readonly Version: string;
  84496. /**
  84497. * Returns a string describing the current engine
  84498. */
  84499. readonly description: string;
  84500. /**
  84501. * Gets or sets the epsilon value used by collision engine
  84502. */
  84503. static CollisionsEpsilon: number;
  84504. /**
  84505. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84506. */
  84507. static ShadersRepository: string;
  84508. /**
  84509. * Method called to create the default loading screen.
  84510. * This can be overriden in your own app.
  84511. * @param canvas The rendering canvas element
  84512. * @returns The loading screen
  84513. */
  84514. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84515. /**
  84516. * Method called to create the default rescale post process on each engine.
  84517. */
  84518. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84519. /**
  84520. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84521. */
  84522. forcePOTTextures: boolean;
  84523. /**
  84524. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84525. */
  84526. isFullscreen: boolean;
  84527. /**
  84528. * Gets a boolean indicating if the pointer is currently locked
  84529. */
  84530. isPointerLock: boolean;
  84531. /**
  84532. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84533. */
  84534. cullBackFaces: boolean;
  84535. /**
  84536. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84537. */
  84538. renderEvenInBackground: boolean;
  84539. /**
  84540. * Gets or sets a boolean indicating that cache can be kept between frames
  84541. */
  84542. preventCacheWipeBetweenFrames: boolean;
  84543. /**
  84544. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84545. **/
  84546. enableOfflineSupport: boolean;
  84547. /**
  84548. * 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)
  84549. **/
  84550. disableManifestCheck: boolean;
  84551. /**
  84552. * Gets the list of created scenes
  84553. */
  84554. scenes: Scene[];
  84555. /**
  84556. * Event raised when a new scene is created
  84557. */
  84558. onNewSceneAddedObservable: Observable<Scene>;
  84559. /**
  84560. * Gets the list of created postprocesses
  84561. */
  84562. postProcesses: PostProcess[];
  84563. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84564. validateShaderPrograms: boolean;
  84565. /**
  84566. * Observable event triggered each time the rendering canvas is resized
  84567. */
  84568. onResizeObservable: Observable<Engine>;
  84569. /**
  84570. * Observable event triggered each time the canvas loses focus
  84571. */
  84572. onCanvasBlurObservable: Observable<Engine>;
  84573. /**
  84574. * Observable event triggered each time the canvas gains focus
  84575. */
  84576. onCanvasFocusObservable: Observable<Engine>;
  84577. /**
  84578. * Observable event triggered each time the canvas receives pointerout event
  84579. */
  84580. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84581. /**
  84582. * Observable event triggered before each texture is initialized
  84583. */
  84584. onBeforeTextureInitObservable: Observable<Texture>;
  84585. private _vrDisplay;
  84586. private _vrSupported;
  84587. private _oldSize;
  84588. private _oldHardwareScaleFactor;
  84589. private _vrExclusivePointerMode;
  84590. private _webVRInitPromise;
  84591. /**
  84592. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84593. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84594. */
  84595. readonly isInVRExclusivePointerMode: boolean;
  84596. /**
  84597. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84598. */
  84599. disableUniformBuffers: boolean;
  84600. /** @hidden */
  84601. _uniformBuffers: UniformBuffer[];
  84602. /**
  84603. * Gets a boolean indicating that the engine supports uniform buffers
  84604. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84605. */
  84606. readonly supportsUniformBuffers: boolean;
  84607. /**
  84608. * Observable raised when the engine begins a new frame
  84609. */
  84610. onBeginFrameObservable: Observable<Engine>;
  84611. /**
  84612. * If set, will be used to request the next animation frame for the render loop
  84613. */
  84614. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84615. /**
  84616. * Observable raised when the engine ends the current frame
  84617. */
  84618. onEndFrameObservable: Observable<Engine>;
  84619. /**
  84620. * Observable raised when the engine is about to compile a shader
  84621. */
  84622. onBeforeShaderCompilationObservable: Observable<Engine>;
  84623. /**
  84624. * Observable raised when the engine has jsut compiled a shader
  84625. */
  84626. onAfterShaderCompilationObservable: Observable<Engine>;
  84627. /** @hidden */
  84628. _gl: WebGLRenderingContext;
  84629. private _renderingCanvas;
  84630. private _windowIsBackground;
  84631. private _webGLVersion;
  84632. protected _highPrecisionShadersAllowed: boolean;
  84633. /** @hidden */
  84634. readonly _shouldUseHighPrecisionShader: boolean;
  84635. /**
  84636. * Gets a boolean indicating that only power of 2 textures are supported
  84637. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84638. */
  84639. readonly needPOTTextures: boolean;
  84640. /** @hidden */
  84641. _badOS: boolean;
  84642. /** @hidden */
  84643. _badDesktopOS: boolean;
  84644. /**
  84645. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84646. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84647. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84648. */
  84649. disableTextureBindingOptimization: boolean;
  84650. /**
  84651. * Gets the audio engine
  84652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84653. * @ignorenaming
  84654. */
  84655. static audioEngine: IAudioEngine;
  84656. /**
  84657. * Default AudioEngine factory responsible of creating the Audio Engine.
  84658. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84659. */
  84660. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84661. /**
  84662. * Default offline support factory responsible of creating a tool used to store data locally.
  84663. * By default, this will create a Database object if the workload has been embedded.
  84664. */
  84665. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84666. private _onFocus;
  84667. private _onBlur;
  84668. private _onCanvasPointerOut;
  84669. private _onCanvasBlur;
  84670. private _onCanvasFocus;
  84671. private _onFullscreenChange;
  84672. private _onPointerLockChange;
  84673. private _onVRDisplayPointerRestricted;
  84674. private _onVRDisplayPointerUnrestricted;
  84675. private _onVrDisplayConnect;
  84676. private _onVrDisplayDisconnect;
  84677. private _onVrDisplayPresentChange;
  84678. /**
  84679. * Observable signaled when VR display mode changes
  84680. */
  84681. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84682. /**
  84683. * Observable signaled when VR request present is complete
  84684. */
  84685. onVRRequestPresentComplete: Observable<boolean>;
  84686. /**
  84687. * Observable signaled when VR request present starts
  84688. */
  84689. onVRRequestPresentStart: Observable<Engine>;
  84690. private _hardwareScalingLevel;
  84691. /** @hidden */
  84692. protected _caps: EngineCapabilities;
  84693. private _pointerLockRequested;
  84694. private _isStencilEnable;
  84695. private _colorWrite;
  84696. private _loadingScreen;
  84697. /** @hidden */
  84698. _drawCalls: PerfCounter;
  84699. /** @hidden */
  84700. _textureCollisions: PerfCounter;
  84701. private _glVersion;
  84702. private _glRenderer;
  84703. private _glVendor;
  84704. private _videoTextureSupported;
  84705. private _renderingQueueLaunched;
  84706. private _activeRenderLoops;
  84707. private _deterministicLockstep;
  84708. private _lockstepMaxSteps;
  84709. /**
  84710. * Observable signaled when a context lost event is raised
  84711. */
  84712. onContextLostObservable: Observable<Engine>;
  84713. /**
  84714. * Observable signaled when a context restored event is raised
  84715. */
  84716. onContextRestoredObservable: Observable<Engine>;
  84717. private _onContextLost;
  84718. private _onContextRestored;
  84719. private _contextWasLost;
  84720. private _doNotHandleContextLost;
  84721. /**
  84722. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84724. */
  84725. doNotHandleContextLost: boolean;
  84726. private _performanceMonitor;
  84727. private _fps;
  84728. private _deltaTime;
  84729. /**
  84730. * Turn this value on if you want to pause FPS computation when in background
  84731. */
  84732. disablePerformanceMonitorInBackground: boolean;
  84733. /**
  84734. * Gets the performance monitor attached to this engine
  84735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84736. */
  84737. readonly performanceMonitor: PerformanceMonitor;
  84738. /** @hidden */
  84739. protected _depthCullingState: _DepthCullingState;
  84740. /** @hidden */
  84741. protected _stencilState: _StencilState;
  84742. /** @hidden */
  84743. protected _alphaState: _AlphaState;
  84744. /** @hidden */
  84745. protected _alphaMode: number;
  84746. protected _internalTexturesCache: InternalTexture[];
  84747. /** @hidden */
  84748. protected _activeChannel: number;
  84749. private _currentTextureChannel;
  84750. /** @hidden */
  84751. protected _boundTexturesCache: {
  84752. [key: string]: Nullable<InternalTexture>;
  84753. };
  84754. /** @hidden */
  84755. protected _currentEffect: Nullable<Effect>;
  84756. /** @hidden */
  84757. protected _currentProgram: Nullable<WebGLProgram>;
  84758. private _compiledEffects;
  84759. private _vertexAttribArraysEnabled;
  84760. /** @hidden */
  84761. protected _cachedViewport: Nullable<Viewport>;
  84762. private _cachedVertexArrayObject;
  84763. /** @hidden */
  84764. protected _cachedVertexBuffers: any;
  84765. /** @hidden */
  84766. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84767. /** @hidden */
  84768. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84769. /** @hidden */
  84770. protected _currentRenderTarget: Nullable<InternalTexture>;
  84771. private _uintIndicesCurrentlySet;
  84772. private _currentBoundBuffer;
  84773. /** @hidden */
  84774. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84775. private _currentBufferPointers;
  84776. private _currentInstanceLocations;
  84777. private _currentInstanceBuffers;
  84778. private _textureUnits;
  84779. private _firstBoundInternalTextureTracker;
  84780. private _lastBoundInternalTextureTracker;
  84781. private _workingCanvas;
  84782. private _workingContext;
  84783. private _rescalePostProcess;
  84784. private _dummyFramebuffer;
  84785. private _externalData;
  84786. private _bindedRenderFunction;
  84787. private _vaoRecordInProgress;
  84788. private _mustWipeVertexAttributes;
  84789. private _emptyTexture;
  84790. private _emptyCubeTexture;
  84791. private _emptyTexture3D;
  84792. /** @hidden */
  84793. _frameHandler: number;
  84794. private _nextFreeTextureSlots;
  84795. private _maxSimultaneousTextures;
  84796. private _activeRequests;
  84797. private _texturesSupported;
  84798. private _textureFormatInUse;
  84799. /**
  84800. * Gets the list of texture formats supported
  84801. */
  84802. readonly texturesSupported: Array<string>;
  84803. /**
  84804. * Gets the list of texture formats in use
  84805. */
  84806. readonly textureFormatInUse: Nullable<string>;
  84807. /**
  84808. * Gets the current viewport
  84809. */
  84810. readonly currentViewport: Nullable<Viewport>;
  84811. /**
  84812. * Gets the default empty texture
  84813. */
  84814. readonly emptyTexture: InternalTexture;
  84815. /**
  84816. * Gets the default empty 3D texture
  84817. */
  84818. readonly emptyTexture3D: InternalTexture;
  84819. /**
  84820. * Gets the default empty cube texture
  84821. */
  84822. readonly emptyCubeTexture: InternalTexture;
  84823. /**
  84824. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84825. */
  84826. readonly premultipliedAlpha: boolean;
  84827. /**
  84828. * Creates a new engine
  84829. * @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
  84830. * @param antialias defines enable antialiasing (default: false)
  84831. * @param options defines further options to be sent to the getContext() function
  84832. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84833. */
  84834. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84835. private _disableTouchAction;
  84836. private _rebuildInternalTextures;
  84837. private _rebuildEffects;
  84838. /**
  84839. * Gets a boolean indicating if all created effects are ready
  84840. * @returns true if all effects are ready
  84841. */
  84842. areAllEffectsReady(): boolean;
  84843. private _rebuildBuffers;
  84844. private _initGLContext;
  84845. /**
  84846. * Gets version of the current webGL context
  84847. */
  84848. readonly webGLVersion: number;
  84849. /**
  84850. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84851. */
  84852. readonly isStencilEnable: boolean;
  84853. private _prepareWorkingCanvas;
  84854. /**
  84855. * Reset the texture cache to empty state
  84856. */
  84857. resetTextureCache(): void;
  84858. /**
  84859. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84860. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84861. * @returns true if engine is in deterministic lock step mode
  84862. */
  84863. isDeterministicLockStep(): boolean;
  84864. /**
  84865. * Gets the max steps when engine is running in deterministic lock step
  84866. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84867. * @returns the max steps
  84868. */
  84869. getLockstepMaxSteps(): number;
  84870. /**
  84871. * Gets an object containing information about the current webGL context
  84872. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84873. */
  84874. getGlInfo(): {
  84875. vendor: string;
  84876. renderer: string;
  84877. version: string;
  84878. };
  84879. /**
  84880. * Gets current aspect ratio
  84881. * @param camera defines the camera to use to get the aspect ratio
  84882. * @param useScreen defines if screen size must be used (or the current render target if any)
  84883. * @returns a number defining the aspect ratio
  84884. */
  84885. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84886. /**
  84887. * Gets current screen aspect ratio
  84888. * @returns a number defining the aspect ratio
  84889. */
  84890. getScreenAspectRatio(): number;
  84891. /**
  84892. * Gets the current render width
  84893. * @param useScreen defines if screen size must be used (or the current render target if any)
  84894. * @returns a number defining the current render width
  84895. */
  84896. getRenderWidth(useScreen?: boolean): number;
  84897. /**
  84898. * Gets the current render height
  84899. * @param useScreen defines if screen size must be used (or the current render target if any)
  84900. * @returns a number defining the current render height
  84901. */
  84902. getRenderHeight(useScreen?: boolean): number;
  84903. /**
  84904. * Gets the HTML canvas attached with the current webGL context
  84905. * @returns a HTML canvas
  84906. */
  84907. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84908. /**
  84909. * Gets the client rect of the HTML canvas attached with the current webGL context
  84910. * @returns a client rectanglee
  84911. */
  84912. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84913. /**
  84914. * Defines the hardware scaling level.
  84915. * By default the hardware scaling level is computed from the window device ratio.
  84916. * 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.
  84917. * @param level defines the level to use
  84918. */
  84919. setHardwareScalingLevel(level: number): void;
  84920. /**
  84921. * Gets the current hardware scaling level.
  84922. * By default the hardware scaling level is computed from the window device ratio.
  84923. * 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.
  84924. * @returns a number indicating the current hardware scaling level
  84925. */
  84926. getHardwareScalingLevel(): number;
  84927. /**
  84928. * Gets the list of loaded textures
  84929. * @returns an array containing all loaded textures
  84930. */
  84931. getLoadedTexturesCache(): InternalTexture[];
  84932. /**
  84933. * Gets the object containing all engine capabilities
  84934. * @returns the EngineCapabilities object
  84935. */
  84936. getCaps(): EngineCapabilities;
  84937. /**
  84938. * Gets the current depth function
  84939. * @returns a number defining the depth function
  84940. */
  84941. getDepthFunction(): Nullable<number>;
  84942. /**
  84943. * Sets the current depth function
  84944. * @param depthFunc defines the function to use
  84945. */
  84946. setDepthFunction(depthFunc: number): void;
  84947. /**
  84948. * Sets the current depth function to GREATER
  84949. */
  84950. setDepthFunctionToGreater(): void;
  84951. /**
  84952. * Sets the current depth function to GEQUAL
  84953. */
  84954. setDepthFunctionToGreaterOrEqual(): void;
  84955. /**
  84956. * Sets the current depth function to LESS
  84957. */
  84958. setDepthFunctionToLess(): void;
  84959. /**
  84960. * Sets the current depth function to LEQUAL
  84961. */
  84962. setDepthFunctionToLessOrEqual(): void;
  84963. /**
  84964. * Gets a boolean indicating if stencil buffer is enabled
  84965. * @returns the current stencil buffer state
  84966. */
  84967. getStencilBuffer(): boolean;
  84968. /**
  84969. * Enable or disable the stencil buffer
  84970. * @param enable defines if the stencil buffer must be enabled or disabled
  84971. */
  84972. setStencilBuffer(enable: boolean): void;
  84973. /**
  84974. * Gets the current stencil mask
  84975. * @returns a number defining the new stencil mask to use
  84976. */
  84977. getStencilMask(): number;
  84978. /**
  84979. * Sets the current stencil mask
  84980. * @param mask defines the new stencil mask to use
  84981. */
  84982. setStencilMask(mask: number): void;
  84983. /**
  84984. * Gets the current stencil function
  84985. * @returns a number defining the stencil function to use
  84986. */
  84987. getStencilFunction(): number;
  84988. /**
  84989. * Gets the current stencil reference value
  84990. * @returns a number defining the stencil reference value to use
  84991. */
  84992. getStencilFunctionReference(): number;
  84993. /**
  84994. * Gets the current stencil mask
  84995. * @returns a number defining the stencil mask to use
  84996. */
  84997. getStencilFunctionMask(): number;
  84998. /**
  84999. * Sets the current stencil function
  85000. * @param stencilFunc defines the new stencil function to use
  85001. */
  85002. setStencilFunction(stencilFunc: number): void;
  85003. /**
  85004. * Sets the current stencil reference
  85005. * @param reference defines the new stencil reference to use
  85006. */
  85007. setStencilFunctionReference(reference: number): void;
  85008. /**
  85009. * Sets the current stencil mask
  85010. * @param mask defines the new stencil mask to use
  85011. */
  85012. setStencilFunctionMask(mask: number): void;
  85013. /**
  85014. * Gets the current stencil operation when stencil fails
  85015. * @returns a number defining stencil operation to use when stencil fails
  85016. */
  85017. getStencilOperationFail(): number;
  85018. /**
  85019. * Gets the current stencil operation when depth fails
  85020. * @returns a number defining stencil operation to use when depth fails
  85021. */
  85022. getStencilOperationDepthFail(): number;
  85023. /**
  85024. * Gets the current stencil operation when stencil passes
  85025. * @returns a number defining stencil operation to use when stencil passes
  85026. */
  85027. getStencilOperationPass(): number;
  85028. /**
  85029. * Sets the stencil operation to use when stencil fails
  85030. * @param operation defines the stencil operation to use when stencil fails
  85031. */
  85032. setStencilOperationFail(operation: number): void;
  85033. /**
  85034. * Sets the stencil operation to use when depth fails
  85035. * @param operation defines the stencil operation to use when depth fails
  85036. */
  85037. setStencilOperationDepthFail(operation: number): void;
  85038. /**
  85039. * Sets the stencil operation to use when stencil passes
  85040. * @param operation defines the stencil operation to use when stencil passes
  85041. */
  85042. setStencilOperationPass(operation: number): void;
  85043. /**
  85044. * Sets a boolean indicating if the dithering state is enabled or disabled
  85045. * @param value defines the dithering state
  85046. */
  85047. setDitheringState(value: boolean): void;
  85048. /**
  85049. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85050. * @param value defines the rasterizer state
  85051. */
  85052. setRasterizerState(value: boolean): void;
  85053. /**
  85054. * stop executing a render loop function and remove it from the execution array
  85055. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85056. */
  85057. stopRenderLoop(renderFunction?: () => void): void;
  85058. /** @hidden */
  85059. _renderLoop(): void;
  85060. /**
  85061. * Register and execute a render loop. The engine can have more than one render function
  85062. * @param renderFunction defines the function to continuously execute
  85063. */
  85064. runRenderLoop(renderFunction: () => void): void;
  85065. /**
  85066. * Toggle full screen mode
  85067. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85068. */
  85069. switchFullscreen(requestPointerLock: boolean): void;
  85070. /**
  85071. * Enters full screen mode
  85072. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85073. */
  85074. enterFullscreen(requestPointerLock: boolean): void;
  85075. /**
  85076. * Exits full screen mode
  85077. */
  85078. exitFullscreen(): void;
  85079. /**
  85080. * Clear the current render buffer or the current render target (if any is set up)
  85081. * @param color defines the color to use
  85082. * @param backBuffer defines if the back buffer must be cleared
  85083. * @param depth defines if the depth buffer must be cleared
  85084. * @param stencil defines if the stencil buffer must be cleared
  85085. */
  85086. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  85087. /**
  85088. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  85089. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85090. * @param y defines the y-coordinate of the corner of the clear rectangle
  85091. * @param width defines the width of the clear rectangle
  85092. * @param height defines the height of the clear rectangle
  85093. * @param clearColor defines the clear color
  85094. */
  85095. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  85096. /**
  85097. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  85098. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85099. * @param y defines the y-coordinate of the corner of the clear rectangle
  85100. * @param width defines the width of the clear rectangle
  85101. * @param height defines the height of the clear rectangle
  85102. */
  85103. enableScissor(x: number, y: number, width: number, height: number): void;
  85104. /**
  85105. * Disable previously set scissor test rectangle
  85106. */
  85107. disableScissor(): void;
  85108. private _viewportCached;
  85109. /** @hidden */
  85110. _viewport(x: number, y: number, width: number, height: number): void;
  85111. /**
  85112. * Set the WebGL's viewport
  85113. * @param viewport defines the viewport element to be used
  85114. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  85115. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  85116. */
  85117. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  85118. /**
  85119. * Directly set the WebGL Viewport
  85120. * @param x defines the x coordinate of the viewport (in screen space)
  85121. * @param y defines the y coordinate of the viewport (in screen space)
  85122. * @param width defines the width of the viewport (in screen space)
  85123. * @param height defines the height of the viewport (in screen space)
  85124. * @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
  85125. */
  85126. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  85127. /**
  85128. * Begin a new frame
  85129. */
  85130. beginFrame(): void;
  85131. /**
  85132. * Enf the current frame
  85133. */
  85134. endFrame(): void;
  85135. /**
  85136. * Resize the view according to the canvas' size
  85137. */
  85138. resize(): void;
  85139. /**
  85140. * Force a specific size of the canvas
  85141. * @param width defines the new canvas' width
  85142. * @param height defines the new canvas' height
  85143. */
  85144. setSize(width: number, height: number): void;
  85145. /**
  85146. * Gets a boolean indicating if a webVR device was detected
  85147. * @returns true if a webVR device was detected
  85148. */
  85149. isVRDevicePresent(): boolean;
  85150. /**
  85151. * Gets the current webVR device
  85152. * @returns the current webVR device (or null)
  85153. */
  85154. getVRDevice(): any;
  85155. /**
  85156. * Initializes a webVR display and starts listening to display change events
  85157. * The onVRDisplayChangedObservable will be notified upon these changes
  85158. * @returns The onVRDisplayChangedObservable
  85159. */
  85160. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85161. /**
  85162. * Initializes a webVR display and starts listening to display change events
  85163. * The onVRDisplayChangedObservable will be notified upon these changes
  85164. * @returns A promise containing a VRDisplay and if vr is supported
  85165. */
  85166. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85167. /**
  85168. * Call this function to switch to webVR mode
  85169. * Will do nothing if webVR is not supported or if there is no webVR device
  85170. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85171. */
  85172. enableVR(): void;
  85173. /**
  85174. * Call this function to leave webVR mode
  85175. * Will do nothing if webVR is not supported or if there is no webVR device
  85176. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85177. */
  85178. disableVR(): void;
  85179. private _onVRFullScreenTriggered;
  85180. private _getVRDisplaysAsync;
  85181. /**
  85182. * Binds the frame buffer to the specified texture.
  85183. * @param texture The texture to render to or null for the default canvas
  85184. * @param faceIndex The face of the texture to render to in case of cube texture
  85185. * @param requiredWidth The width of the target to render to
  85186. * @param requiredHeight The height of the target to render to
  85187. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85188. * @param depthStencilTexture The depth stencil texture to use to render
  85189. * @param lodLevel defines le lod level to bind to the frame buffer
  85190. */
  85191. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  85192. private bindUnboundFramebuffer;
  85193. /**
  85194. * Unbind the current render target texture from the webGL context
  85195. * @param texture defines the render target texture to unbind
  85196. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85197. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85198. */
  85199. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85200. /**
  85201. * Unbind a list of render target textures from the webGL context
  85202. * This is used only when drawBuffer extension or webGL2 are active
  85203. * @param textures defines the render target textures to unbind
  85204. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85205. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85206. */
  85207. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85208. /**
  85209. * Force the mipmap generation for the given render target texture
  85210. * @param texture defines the render target texture to use
  85211. */
  85212. generateMipMapsForCubemap(texture: InternalTexture): void;
  85213. /**
  85214. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  85215. */
  85216. flushFramebuffer(): void;
  85217. /**
  85218. * Unbind the current render target and bind the default framebuffer
  85219. */
  85220. restoreDefaultFramebuffer(): void;
  85221. /**
  85222. * Create an uniform buffer
  85223. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85224. * @param elements defines the content of the uniform buffer
  85225. * @returns the webGL uniform buffer
  85226. */
  85227. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  85228. /**
  85229. * Create a dynamic uniform buffer
  85230. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85231. * @param elements defines the content of the uniform buffer
  85232. * @returns the webGL uniform buffer
  85233. */
  85234. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  85235. /**
  85236. * Update an existing uniform buffer
  85237. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85238. * @param uniformBuffer defines the target uniform buffer
  85239. * @param elements defines the content to update
  85240. * @param offset defines the offset in the uniform buffer where update should start
  85241. * @param count defines the size of the data to update
  85242. */
  85243. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85244. private _resetVertexBufferBinding;
  85245. /**
  85246. * Creates a vertex buffer
  85247. * @param data the data for the vertex buffer
  85248. * @returns the new WebGL static buffer
  85249. */
  85250. createVertexBuffer(data: DataArray): WebGLBuffer;
  85251. /**
  85252. * Creates a dynamic vertex buffer
  85253. * @param data the data for the dynamic vertex buffer
  85254. * @returns the new WebGL dynamic buffer
  85255. */
  85256. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  85257. /**
  85258. * Update a dynamic index buffer
  85259. * @param indexBuffer defines the target index buffer
  85260. * @param indices defines the data to update
  85261. * @param offset defines the offset in the target index buffer where update should start
  85262. */
  85263. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  85264. /**
  85265. * Updates a dynamic vertex buffer.
  85266. * @param vertexBuffer the vertex buffer to update
  85267. * @param data the data used to update the vertex buffer
  85268. * @param byteOffset the byte offset of the data
  85269. * @param byteLength the byte length of the data
  85270. */
  85271. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  85272. private _resetIndexBufferBinding;
  85273. /**
  85274. * Creates a new index buffer
  85275. * @param indices defines the content of the index buffer
  85276. * @param updatable defines if the index buffer must be updatable
  85277. * @returns a new webGL buffer
  85278. */
  85279. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  85280. /**
  85281. * Bind a webGL buffer to the webGL context
  85282. * @param buffer defines the buffer to bind
  85283. */
  85284. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  85285. /**
  85286. * Bind an uniform buffer to the current webGL context
  85287. * @param buffer defines the buffer to bind
  85288. */
  85289. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  85290. /**
  85291. * Bind a buffer to the current webGL context at a given location
  85292. * @param buffer defines the buffer to bind
  85293. * @param location defines the index where to bind the buffer
  85294. */
  85295. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  85296. /**
  85297. * Bind a specific block at a given index in a specific shader program
  85298. * @param shaderProgram defines the shader program
  85299. * @param blockName defines the block name
  85300. * @param index defines the index where to bind the block
  85301. */
  85302. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  85303. private bindIndexBuffer;
  85304. private bindBuffer;
  85305. /**
  85306. * update the bound buffer with the given data
  85307. * @param data defines the data to update
  85308. */
  85309. updateArrayBuffer(data: Float32Array): void;
  85310. private _vertexAttribPointer;
  85311. private _bindIndexBufferWithCache;
  85312. private _bindVertexBuffersAttributes;
  85313. /**
  85314. * Records a vertex array object
  85315. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85316. * @param vertexBuffers defines the list of vertex buffers to store
  85317. * @param indexBuffer defines the index buffer to store
  85318. * @param effect defines the effect to store
  85319. * @returns the new vertex array object
  85320. */
  85321. recordVertexArrayObject(vertexBuffers: {
  85322. [key: string]: VertexBuffer;
  85323. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  85324. /**
  85325. * Bind a specific vertex array object
  85326. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85327. * @param vertexArrayObject defines the vertex array object to bind
  85328. * @param indexBuffer defines the index buffer to bind
  85329. */
  85330. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  85331. /**
  85332. * Bind webGl buffers directly to the webGL context
  85333. * @param vertexBuffer defines the vertex buffer to bind
  85334. * @param indexBuffer defines the index buffer to bind
  85335. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  85336. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  85337. * @param effect defines the effect associated with the vertex buffer
  85338. */
  85339. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  85340. private _unbindVertexArrayObject;
  85341. /**
  85342. * Bind a list of vertex buffers to the webGL context
  85343. * @param vertexBuffers defines the list of vertex buffers to bind
  85344. * @param indexBuffer defines the index buffer to bind
  85345. * @param effect defines the effect associated with the vertex buffers
  85346. */
  85347. bindBuffers(vertexBuffers: {
  85348. [key: string]: Nullable<VertexBuffer>;
  85349. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  85350. /**
  85351. * Unbind all instance attributes
  85352. */
  85353. unbindInstanceAttributes(): void;
  85354. /**
  85355. * Release and free the memory of a vertex array object
  85356. * @param vao defines the vertex array object to delete
  85357. */
  85358. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85359. /** @hidden */
  85360. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85361. /**
  85362. * Creates a webGL buffer to use with instanciation
  85363. * @param capacity defines the size of the buffer
  85364. * @returns the webGL buffer
  85365. */
  85366. createInstancesBuffer(capacity: number): WebGLBuffer;
  85367. /**
  85368. * Delete a webGL buffer used with instanciation
  85369. * @param buffer defines the webGL buffer to delete
  85370. */
  85371. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85372. /**
  85373. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85374. * @param instancesBuffer defines the webGL buffer to update and bind
  85375. * @param data defines the data to store in the buffer
  85376. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85377. */
  85378. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85379. /**
  85380. * Apply all cached states (depth, culling, stencil and alpha)
  85381. */
  85382. applyStates(): void;
  85383. /**
  85384. * Send a draw order
  85385. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85386. * @param indexStart defines the starting index
  85387. * @param indexCount defines the number of index to draw
  85388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85389. */
  85390. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85391. /**
  85392. * Draw a list of points
  85393. * @param verticesStart defines the index of first vertex to draw
  85394. * @param verticesCount defines the count of vertices to draw
  85395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85396. */
  85397. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85398. /**
  85399. * Draw a list of unindexed primitives
  85400. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85401. * @param verticesStart defines the index of first vertex to draw
  85402. * @param verticesCount defines the count of vertices to draw
  85403. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85404. */
  85405. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85406. /**
  85407. * Draw a list of indexed primitives
  85408. * @param fillMode defines the primitive to use
  85409. * @param indexStart defines the starting index
  85410. * @param indexCount defines the number of index to draw
  85411. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85412. */
  85413. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85414. /**
  85415. * Draw a list of unindexed primitives
  85416. * @param fillMode defines the primitive to use
  85417. * @param verticesStart defines the index of first vertex to draw
  85418. * @param verticesCount defines the count of vertices to draw
  85419. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85420. */
  85421. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85422. private _drawMode;
  85423. /** @hidden */
  85424. _releaseEffect(effect: Effect): void;
  85425. /** @hidden */
  85426. _deleteProgram(program: WebGLProgram): void;
  85427. /**
  85428. * Create a new effect (used to store vertex/fragment shaders)
  85429. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85430. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85431. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85432. * @param samplers defines an array of string used to represent textures
  85433. * @param defines defines the string containing the defines to use to compile the shaders
  85434. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85435. * @param onCompiled defines a function to call when the effect creation is successful
  85436. * @param onError defines a function to call when the effect creation has failed
  85437. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85438. * @returns the new Effect
  85439. */
  85440. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  85441. private _compileShader;
  85442. private _compileRawShader;
  85443. /**
  85444. * Directly creates a webGL program
  85445. * @param vertexCode defines the vertex shader code to use
  85446. * @param fragmentCode defines the fragment shader code to use
  85447. * @param context defines the webGL context to use (if not set, the current one will be used)
  85448. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85449. * @returns the new webGL program
  85450. */
  85451. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85452. /**
  85453. * Creates a webGL program
  85454. * @param vertexCode defines the vertex shader code to use
  85455. * @param fragmentCode defines the fragment shader code to use
  85456. * @param defines defines the string containing the defines to use to compile the shaders
  85457. * @param context defines the webGL context to use (if not set, the current one will be used)
  85458. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85459. * @returns the new webGL program
  85460. */
  85461. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85462. private _createShaderProgram;
  85463. private _finalizeProgram;
  85464. /** @hidden */
  85465. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85466. /** @hidden */
  85467. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85468. /**
  85469. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85470. * @param shaderProgram defines the webGL program to use
  85471. * @param uniformsNames defines the list of uniform names
  85472. * @returns an array of webGL uniform locations
  85473. */
  85474. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85475. /**
  85476. * Gets the lsit of active attributes for a given webGL program
  85477. * @param shaderProgram defines the webGL program to use
  85478. * @param attributesNames defines the list of attribute names to get
  85479. * @returns an array of indices indicating the offset of each attribute
  85480. */
  85481. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85482. /**
  85483. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85484. * @param effect defines the effect to activate
  85485. */
  85486. enableEffect(effect: Nullable<Effect>): void;
  85487. /**
  85488. * Set the value of an uniform to an array of int32
  85489. * @param uniform defines the webGL uniform location where to store the value
  85490. * @param array defines the array of int32 to store
  85491. */
  85492. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85493. /**
  85494. * Set the value of an uniform to an array of int32 (stored as vec2)
  85495. * @param uniform defines the webGL uniform location where to store the value
  85496. * @param array defines the array of int32 to store
  85497. */
  85498. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85499. /**
  85500. * Set the value of an uniform to an array of int32 (stored as vec3)
  85501. * @param uniform defines the webGL uniform location where to store the value
  85502. * @param array defines the array of int32 to store
  85503. */
  85504. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85505. /**
  85506. * Set the value of an uniform to an array of int32 (stored as vec4)
  85507. * @param uniform defines the webGL uniform location where to store the value
  85508. * @param array defines the array of int32 to store
  85509. */
  85510. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85511. /**
  85512. * Set the value of an uniform to an array of float32
  85513. * @param uniform defines the webGL uniform location where to store the value
  85514. * @param array defines the array of float32 to store
  85515. */
  85516. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85517. /**
  85518. * Set the value of an uniform to an array of float32 (stored as vec2)
  85519. * @param uniform defines the webGL uniform location where to store the value
  85520. * @param array defines the array of float32 to store
  85521. */
  85522. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85523. /**
  85524. * Set the value of an uniform to an array of float32 (stored as vec3)
  85525. * @param uniform defines the webGL uniform location where to store the value
  85526. * @param array defines the array of float32 to store
  85527. */
  85528. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85529. /**
  85530. * Set the value of an uniform to an array of float32 (stored as vec4)
  85531. * @param uniform defines the webGL uniform location where to store the value
  85532. * @param array defines the array of float32 to store
  85533. */
  85534. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85535. /**
  85536. * Set the value of an uniform to an array of number
  85537. * @param uniform defines the webGL uniform location where to store the value
  85538. * @param array defines the array of number to store
  85539. */
  85540. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85541. /**
  85542. * Set the value of an uniform to an array of number (stored as vec2)
  85543. * @param uniform defines the webGL uniform location where to store the value
  85544. * @param array defines the array of number to store
  85545. */
  85546. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85547. /**
  85548. * Set the value of an uniform to an array of number (stored as vec3)
  85549. * @param uniform defines the webGL uniform location where to store the value
  85550. * @param array defines the array of number to store
  85551. */
  85552. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85553. /**
  85554. * Set the value of an uniform to an array of number (stored as vec4)
  85555. * @param uniform defines the webGL uniform location where to store the value
  85556. * @param array defines the array of number to store
  85557. */
  85558. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85559. /**
  85560. * Set the value of an uniform to an array of float32 (stored as matrices)
  85561. * @param uniform defines the webGL uniform location where to store the value
  85562. * @param matrices defines the array of float32 to store
  85563. */
  85564. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85565. /**
  85566. * Set the value of an uniform to a matrix
  85567. * @param uniform defines the webGL uniform location where to store the value
  85568. * @param matrix defines the matrix to store
  85569. */
  85570. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85571. /**
  85572. * Set the value of an uniform to a matrix (3x3)
  85573. * @param uniform defines the webGL uniform location where to store the value
  85574. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85575. */
  85576. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85577. /**
  85578. * Set the value of an uniform to a matrix (2x2)
  85579. * @param uniform defines the webGL uniform location where to store the value
  85580. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85581. */
  85582. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85583. /**
  85584. * Set the value of an uniform to a number (int)
  85585. * @param uniform defines the webGL uniform location where to store the value
  85586. * @param value defines the int number to store
  85587. */
  85588. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85589. /**
  85590. * Set the value of an uniform to a number (float)
  85591. * @param uniform defines the webGL uniform location where to store the value
  85592. * @param value defines the float number to store
  85593. */
  85594. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85595. /**
  85596. * Set the value of an uniform to a vec2
  85597. * @param uniform defines the webGL uniform location where to store the value
  85598. * @param x defines the 1st component of the value
  85599. * @param y defines the 2nd component of the value
  85600. */
  85601. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85602. /**
  85603. * Set the value of an uniform to a vec3
  85604. * @param uniform defines the webGL uniform location where to store the value
  85605. * @param x defines the 1st component of the value
  85606. * @param y defines the 2nd component of the value
  85607. * @param z defines the 3rd component of the value
  85608. */
  85609. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85610. /**
  85611. * Set the value of an uniform to a boolean
  85612. * @param uniform defines the webGL uniform location where to store the value
  85613. * @param bool defines the boolean to store
  85614. */
  85615. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85616. /**
  85617. * Set the value of an uniform to a vec4
  85618. * @param uniform defines the webGL uniform location where to store the value
  85619. * @param x defines the 1st component of the value
  85620. * @param y defines the 2nd component of the value
  85621. * @param z defines the 3rd component of the value
  85622. * @param w defines the 4th component of the value
  85623. */
  85624. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85625. /**
  85626. * Set the value of an uniform to a Color3
  85627. * @param uniform defines the webGL uniform location where to store the value
  85628. * @param color3 defines the color to store
  85629. */
  85630. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85631. /**
  85632. * Set the value of an uniform to a Color3 and an alpha value
  85633. * @param uniform defines the webGL uniform location where to store the value
  85634. * @param color3 defines the color to store
  85635. * @param alpha defines the alpha component to store
  85636. */
  85637. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85638. /**
  85639. * Sets a Color4 on a uniform variable
  85640. * @param uniform defines the uniform location
  85641. * @param color4 defines the value to be set
  85642. */
  85643. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85644. /**
  85645. * Set various states to the webGL context
  85646. * @param culling defines backface culling state
  85647. * @param zOffset defines the value to apply to zOffset (0 by default)
  85648. * @param force defines if states must be applied even if cache is up to date
  85649. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85650. */
  85651. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85652. /**
  85653. * Set the z offset to apply to current rendering
  85654. * @param value defines the offset to apply
  85655. */
  85656. setZOffset(value: number): void;
  85657. /**
  85658. * Gets the current value of the zOffset
  85659. * @returns the current zOffset state
  85660. */
  85661. getZOffset(): number;
  85662. /**
  85663. * Enable or disable depth buffering
  85664. * @param enable defines the state to set
  85665. */
  85666. setDepthBuffer(enable: boolean): void;
  85667. /**
  85668. * Gets a boolean indicating if depth writing is enabled
  85669. * @returns the current depth writing state
  85670. */
  85671. getDepthWrite(): boolean;
  85672. /**
  85673. * Enable or disable depth writing
  85674. * @param enable defines the state to set
  85675. */
  85676. setDepthWrite(enable: boolean): void;
  85677. /**
  85678. * Enable or disable color writing
  85679. * @param enable defines the state to set
  85680. */
  85681. setColorWrite(enable: boolean): void;
  85682. /**
  85683. * Gets a boolean indicating if color writing is enabled
  85684. * @returns the current color writing state
  85685. */
  85686. getColorWrite(): boolean;
  85687. /**
  85688. * Sets alpha constants used by some alpha blending modes
  85689. * @param r defines the red component
  85690. * @param g defines the green component
  85691. * @param b defines the blue component
  85692. * @param a defines the alpha component
  85693. */
  85694. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85695. /**
  85696. * Sets the current alpha mode
  85697. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85698. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85699. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85700. */
  85701. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85702. /**
  85703. * Gets the current alpha mode
  85704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85705. * @returns the current alpha mode
  85706. */
  85707. getAlphaMode(): number;
  85708. /**
  85709. * Clears the list of texture accessible through engine.
  85710. * This can help preventing texture load conflict due to name collision.
  85711. */
  85712. clearInternalTexturesCache(): void;
  85713. /**
  85714. * Force the entire cache to be cleared
  85715. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85716. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85717. */
  85718. wipeCaches(bruteForce?: boolean): void;
  85719. /**
  85720. * Set the compressed texture format to use, based on the formats you have, and the formats
  85721. * supported by the hardware / browser.
  85722. *
  85723. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85724. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85725. * to API arguments needed to compressed textures. This puts the burden on the container
  85726. * generator to house the arcane code for determining these for current & future formats.
  85727. *
  85728. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85729. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85730. *
  85731. * Note: The result of this call is not taken into account when a texture is base64.
  85732. *
  85733. * @param formatsAvailable defines the list of those format families you have created
  85734. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85735. *
  85736. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85737. * @returns The extension selected.
  85738. */
  85739. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85740. private _getSamplingParameters;
  85741. private _partialLoadImg;
  85742. private _cascadeLoadImgs;
  85743. /** @hidden */
  85744. _createTexture(): WebGLTexture;
  85745. /**
  85746. * Usually called from Texture.ts.
  85747. * Passed information to create a WebGLTexture
  85748. * @param urlArg defines a value which contains one of the following:
  85749. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85750. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85751. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85753. * @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)
  85754. * @param scene needed for loading to the correct scene
  85755. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85756. * @param onLoad optional callback to be called upon successful completion
  85757. * @param onError optional callback to be called upon failure
  85758. * @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
  85759. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85760. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85761. * @param forcedExtension defines the extension to use to pick the right loader
  85762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85763. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85764. */
  85765. 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;
  85766. private _rescaleTexture;
  85767. /**
  85768. * Update a raw texture
  85769. * @param texture defines the texture to update
  85770. * @param data defines the data to store in the texture
  85771. * @param format defines the format of the data
  85772. * @param invertY defines if data must be stored with Y axis inverted
  85773. * @param compression defines the compression used (null by default)
  85774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85775. */
  85776. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85777. /**
  85778. * Creates a raw texture
  85779. * @param data defines the data to store in the texture
  85780. * @param width defines the width of the texture
  85781. * @param height defines the height of the texture
  85782. * @param format defines the format of the data
  85783. * @param generateMipMaps defines if the engine should generate the mip levels
  85784. * @param invertY defines if data must be stored with Y axis inverted
  85785. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85786. * @param compression defines the compression used (null by default)
  85787. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85788. * @returns the raw texture inside an InternalTexture
  85789. */
  85790. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85791. private _unpackFlipYCached;
  85792. /**
  85793. * In case you are sharing the context with other applications, it might
  85794. * be interested to not cache the unpack flip y state to ensure a consistent
  85795. * value would be set.
  85796. */
  85797. enableUnpackFlipYCached: boolean;
  85798. /** @hidden */
  85799. _unpackFlipY(value: boolean): void;
  85800. /** @hidden */
  85801. _getUnpackAlignement(): number;
  85802. /**
  85803. * Creates a dynamic texture
  85804. * @param width defines the width of the texture
  85805. * @param height defines the height of the texture
  85806. * @param generateMipMaps defines if the engine should generate the mip levels
  85807. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85808. * @returns the dynamic texture inside an InternalTexture
  85809. */
  85810. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85811. /**
  85812. * Update the sampling mode of a given texture
  85813. * @param samplingMode defines the required sampling mode
  85814. * @param texture defines the texture to update
  85815. */
  85816. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85817. /**
  85818. * Update the content of a dynamic texture
  85819. * @param texture defines the texture to update
  85820. * @param canvas defines the canvas containing the source
  85821. * @param invertY defines if data must be stored with Y axis inverted
  85822. * @param premulAlpha defines if alpha is stored as premultiplied
  85823. * @param format defines the format of the data
  85824. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85825. */
  85826. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85827. /**
  85828. * Update a video texture
  85829. * @param texture defines the texture to update
  85830. * @param video defines the video element to use
  85831. * @param invertY defines if data must be stored with Y axis inverted
  85832. */
  85833. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85834. /**
  85835. * Updates a depth texture Comparison Mode and Function.
  85836. * If the comparison Function is equal to 0, the mode will be set to none.
  85837. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85838. * @param texture The texture to set the comparison function for
  85839. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85840. */
  85841. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85842. private _setupDepthStencilTexture;
  85843. /**
  85844. * Creates a depth stencil texture.
  85845. * This is only available in WebGL 2 or with the depth texture extension available.
  85846. * @param size The size of face edge in the texture.
  85847. * @param options The options defining the texture.
  85848. * @returns The texture
  85849. */
  85850. createDepthStencilTexture(size: number | {
  85851. width: number;
  85852. height: number;
  85853. }, options: DepthTextureCreationOptions): InternalTexture;
  85854. /**
  85855. * Creates a depth stencil texture.
  85856. * This is only available in WebGL 2 or with the depth texture extension available.
  85857. * @param size The size of face edge in the texture.
  85858. * @param options The options defining the texture.
  85859. * @returns The texture
  85860. */
  85861. private _createDepthStencilTexture;
  85862. /**
  85863. * Creates a depth stencil cube texture.
  85864. * This is only available in WebGL 2.
  85865. * @param size The size of face edge in the cube texture.
  85866. * @param options The options defining the cube texture.
  85867. * @returns The cube texture
  85868. */
  85869. private _createDepthStencilCubeTexture;
  85870. /**
  85871. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85872. * @param renderTarget The render target to set the frame buffer for
  85873. */
  85874. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85875. /**
  85876. * Creates a new render target texture
  85877. * @param size defines the size of the texture
  85878. * @param options defines the options used to create the texture
  85879. * @returns a new render target texture stored in an InternalTexture
  85880. */
  85881. createRenderTargetTexture(size: number | {
  85882. width: number;
  85883. height: number;
  85884. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85885. /**
  85886. * Create a multi render target texture
  85887. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85888. * @param size defines the size of the texture
  85889. * @param options defines the creation options
  85890. * @returns the cube texture as an InternalTexture
  85891. */
  85892. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85893. private _setupFramebufferDepthAttachments;
  85894. /**
  85895. * Updates the sample count of a render target texture
  85896. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85897. * @param texture defines the texture to update
  85898. * @param samples defines the sample count to set
  85899. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85900. */
  85901. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85902. /**
  85903. * Update the sample count for a given multiple render target texture
  85904. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85905. * @param textures defines the textures to update
  85906. * @param samples defines the sample count to set
  85907. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85908. */
  85909. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85910. /** @hidden */
  85911. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85912. /** @hidden */
  85913. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85914. /** @hidden */
  85915. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85916. /** @hidden */
  85917. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85918. /**
  85919. * Creates a new render target cube texture
  85920. * @param size defines the size of the texture
  85921. * @param options defines the options used to create the texture
  85922. * @returns a new render target cube texture stored in an InternalTexture
  85923. */
  85924. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85925. /**
  85926. * Creates a cube texture
  85927. * @param rootUrl defines the url where the files to load is located
  85928. * @param scene defines the current scene
  85929. * @param files defines the list of files to load (1 per face)
  85930. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85931. * @param onLoad defines an optional callback raised when the texture is loaded
  85932. * @param onError defines an optional callback raised if there is an issue to load the texture
  85933. * @param format defines the format of the data
  85934. * @param forcedExtension defines the extension to use to pick the right loader
  85935. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85936. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85937. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85938. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85939. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85940. * @returns the cube texture as an InternalTexture
  85941. */
  85942. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  85943. /**
  85944. * @hidden
  85945. */
  85946. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85947. /**
  85948. * Update a raw cube texture
  85949. * @param texture defines the texture to udpdate
  85950. * @param data defines the data to store
  85951. * @param format defines the data format
  85952. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85953. * @param invertY defines if data must be stored with Y axis inverted
  85954. * @param compression defines the compression used (null by default)
  85955. * @param level defines which level of the texture to update
  85956. */
  85957. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85958. /**
  85959. * Creates a new raw cube texture
  85960. * @param data defines the array of data to use to create each face
  85961. * @param size defines the size of the textures
  85962. * @param format defines the format of the data
  85963. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85964. * @param generateMipMaps defines if the engine should generate the mip levels
  85965. * @param invertY defines if data must be stored with Y axis inverted
  85966. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85967. * @param compression defines the compression used (null by default)
  85968. * @returns the cube texture as an InternalTexture
  85969. */
  85970. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85971. /**
  85972. * Creates a new raw cube texture from a specified url
  85973. * @param url defines the url where the data is located
  85974. * @param scene defines the current scene
  85975. * @param size defines the size of the textures
  85976. * @param format defines the format of the data
  85977. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85978. * @param noMipmap defines if the engine should avoid generating the mip levels
  85979. * @param callback defines a callback used to extract texture data from loaded data
  85980. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85981. * @param onLoad defines a callback called when texture is loaded
  85982. * @param onError defines a callback called if there is an error
  85983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85984. * @param invertY defines if data must be stored with Y axis inverted
  85985. * @returns the cube texture as an InternalTexture
  85986. */
  85987. 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;
  85988. /**
  85989. * Update a raw 3D texture
  85990. * @param texture defines the texture to update
  85991. * @param data defines the data to store
  85992. * @param format defines the data format
  85993. * @param invertY defines if data must be stored with Y axis inverted
  85994. * @param compression defines the used compression (can be null)
  85995. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85996. */
  85997. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85998. /**
  85999. * Creates a new raw 3D texture
  86000. * @param data defines the data used to create the texture
  86001. * @param width defines the width of the texture
  86002. * @param height defines the height of the texture
  86003. * @param depth defines the depth of the texture
  86004. * @param format defines the format of the texture
  86005. * @param generateMipMaps defines if the engine must generate mip levels
  86006. * @param invertY defines if data must be stored with Y axis inverted
  86007. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86008. * @param compression defines the compressed used (can be null)
  86009. * @param textureType defines the compressed used (can be null)
  86010. * @returns a new raw 3D texture (stored in an InternalTexture)
  86011. */
  86012. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86013. private _prepareWebGLTextureContinuation;
  86014. private _prepareWebGLTexture;
  86015. private _convertRGBtoRGBATextureData;
  86016. /** @hidden */
  86017. _releaseFramebufferObjects(texture: InternalTexture): void;
  86018. /** @hidden */
  86019. _releaseTexture(texture: InternalTexture): void;
  86020. private setProgram;
  86021. private _boundUniforms;
  86022. /**
  86023. * Binds an effect to the webGL context
  86024. * @param effect defines the effect to bind
  86025. */
  86026. bindSamplers(effect: Effect): void;
  86027. private _moveBoundTextureOnTop;
  86028. private _getCorrectTextureChannel;
  86029. private _linkTrackers;
  86030. private _removeDesignatedSlot;
  86031. private _activateCurrentTexture;
  86032. /** @hidden */
  86033. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86034. /** @hidden */
  86035. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86036. /**
  86037. * Sets a texture to the webGL context from a postprocess
  86038. * @param channel defines the channel to use
  86039. * @param postProcess defines the source postprocess
  86040. */
  86041. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86042. /**
  86043. * Binds the output of the passed in post process to the texture channel specified
  86044. * @param channel The channel the texture should be bound to
  86045. * @param postProcess The post process which's output should be bound
  86046. */
  86047. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86048. /**
  86049. * Unbind all textures from the webGL context
  86050. */
  86051. unbindAllTextures(): void;
  86052. /**
  86053. * Sets a texture to the according uniform.
  86054. * @param channel The texture channel
  86055. * @param uniform The uniform to set
  86056. * @param texture The texture to apply
  86057. */
  86058. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  86059. /**
  86060. * Sets a depth stencil texture from a render target to the according uniform.
  86061. * @param channel The texture channel
  86062. * @param uniform The uniform to set
  86063. * @param texture The render target texture containing the depth stencil texture to apply
  86064. */
  86065. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  86066. private _bindSamplerUniformToChannel;
  86067. private _getTextureWrapMode;
  86068. private _setTexture;
  86069. /**
  86070. * Sets an array of texture to the webGL context
  86071. * @param channel defines the channel where the texture array must be set
  86072. * @param uniform defines the associated uniform location
  86073. * @param textures defines the array of textures to bind
  86074. */
  86075. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  86076. /** @hidden */
  86077. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  86078. private _setTextureParameterFloat;
  86079. private _setTextureParameterInteger;
  86080. /**
  86081. * Reads pixels from the current frame buffer. Please note that this function can be slow
  86082. * @param x defines the x coordinate of the rectangle where pixels must be read
  86083. * @param y defines the y coordinate of the rectangle where pixels must be read
  86084. * @param width defines the width of the rectangle where pixels must be read
  86085. * @param height defines the height of the rectangle where pixels must be read
  86086. * @returns a Uint8Array containing RGBA colors
  86087. */
  86088. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  86089. /**
  86090. * Add an externaly attached data from its key.
  86091. * This method call will fail and return false, if such key already exists.
  86092. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  86093. * @param key the unique key that identifies the data
  86094. * @param data the data object to associate to the key for this Engine instance
  86095. * @return true if no such key were already present and the data was added successfully, false otherwise
  86096. */
  86097. addExternalData<T>(key: string, data: T): boolean;
  86098. /**
  86099. * Get an externaly attached data from its key
  86100. * @param key the unique key that identifies the data
  86101. * @return the associated data, if present (can be null), or undefined if not present
  86102. */
  86103. getExternalData<T>(key: string): T;
  86104. /**
  86105. * Get an externaly attached data from its key, create it using a factory if it's not already present
  86106. * @param key the unique key that identifies the data
  86107. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  86108. * @return the associated data, can be null if the factory returned null.
  86109. */
  86110. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  86111. /**
  86112. * Remove an externaly attached data from the Engine instance
  86113. * @param key the unique key that identifies the data
  86114. * @return true if the data was successfully removed, false if it doesn't exist
  86115. */
  86116. removeExternalData(key: string): boolean;
  86117. /**
  86118. * Unbind all vertex attributes from the webGL context
  86119. */
  86120. unbindAllAttributes(): void;
  86121. /**
  86122. * 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
  86123. */
  86124. releaseEffects(): void;
  86125. /**
  86126. * Dispose and release all associated resources
  86127. */
  86128. dispose(): void;
  86129. /**
  86130. * Display the loading screen
  86131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86132. */
  86133. displayLoadingUI(): void;
  86134. /**
  86135. * Hide the loading screen
  86136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86137. */
  86138. hideLoadingUI(): void;
  86139. /**
  86140. * Gets the current loading screen object
  86141. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86142. */
  86143. /**
  86144. * Sets the current loading screen object
  86145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86146. */
  86147. loadingScreen: ILoadingScreen;
  86148. /**
  86149. * Sets the current loading screen text
  86150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86151. */
  86152. loadingUIText: string;
  86153. /**
  86154. * Sets the current loading screen background color
  86155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86156. */
  86157. loadingUIBackgroundColor: string;
  86158. /**
  86159. * Attach a new callback raised when context lost event is fired
  86160. * @param callback defines the callback to call
  86161. */
  86162. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86163. /**
  86164. * Attach a new callback raised when context restored event is fired
  86165. * @param callback defines the callback to call
  86166. */
  86167. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86168. /**
  86169. * Gets the source code of the vertex shader associated with a specific webGL program
  86170. * @param program defines the program to use
  86171. * @returns a string containing the source code of the vertex shader associated with the program
  86172. */
  86173. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86174. /**
  86175. * Gets the source code of the fragment shader associated with a specific webGL program
  86176. * @param program defines the program to use
  86177. * @returns a string containing the source code of the fragment shader associated with the program
  86178. */
  86179. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86180. /**
  86181. * Get the current error code of the webGL context
  86182. * @returns the error code
  86183. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86184. */
  86185. getError(): number;
  86186. /**
  86187. * Gets the current framerate
  86188. * @returns a number representing the framerate
  86189. */
  86190. getFps(): number;
  86191. /**
  86192. * Gets the time spent between current and previous frame
  86193. * @returns a number representing the delta time in ms
  86194. */
  86195. getDeltaTime(): number;
  86196. private _measureFps;
  86197. /** @hidden */
  86198. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  86199. private _canRenderToFloatFramebuffer;
  86200. private _canRenderToHalfFloatFramebuffer;
  86201. private _canRenderToFramebuffer;
  86202. /** @hidden */
  86203. _getWebGLTextureType(type: number): number;
  86204. private _getInternalFormat;
  86205. /** @hidden */
  86206. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  86207. /** @hidden */
  86208. _getRGBAMultiSampleBufferFormat(type: number): number;
  86209. /** @hidden */
  86210. _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;
  86211. /** @hidden */
  86212. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  86213. private _partialLoadFile;
  86214. private _cascadeLoadFiles;
  86215. /**
  86216. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  86217. * @returns true if the engine can be created
  86218. * @ignorenaming
  86219. */
  86220. static isSupported(): boolean;
  86221. }
  86222. }
  86223. declare module BABYLON {
  86224. /**
  86225. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86226. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86227. */
  86228. export class EffectFallbacks {
  86229. private _defines;
  86230. private _currentRank;
  86231. private _maxRank;
  86232. private _mesh;
  86233. /**
  86234. * Removes the fallback from the bound mesh.
  86235. */
  86236. unBindMesh(): void;
  86237. /**
  86238. * Adds a fallback on the specified property.
  86239. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86240. * @param define The name of the define in the shader
  86241. */
  86242. addFallback(rank: number, define: string): void;
  86243. /**
  86244. * Sets the mesh to use CPU skinning when needing to fallback.
  86245. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86246. * @param mesh The mesh to use the fallbacks.
  86247. */
  86248. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86249. /**
  86250. * Checks to see if more fallbacks are still availible.
  86251. */
  86252. readonly isMoreFallbacks: boolean;
  86253. /**
  86254. * Removes the defines that shoould be removed when falling back.
  86255. * @param currentDefines defines the current define statements for the shader.
  86256. * @param effect defines the current effect we try to compile
  86257. * @returns The resulting defines with defines of the current rank removed.
  86258. */
  86259. reduce(currentDefines: string, effect: Effect): string;
  86260. }
  86261. /**
  86262. * Options to be used when creating an effect.
  86263. */
  86264. export class EffectCreationOptions {
  86265. /**
  86266. * Atrributes that will be used in the shader.
  86267. */
  86268. attributes: string[];
  86269. /**
  86270. * Uniform varible names that will be set in the shader.
  86271. */
  86272. uniformsNames: string[];
  86273. /**
  86274. * Uniform buffer varible names that will be set in the shader.
  86275. */
  86276. uniformBuffersNames: string[];
  86277. /**
  86278. * Sampler texture variable names that will be set in the shader.
  86279. */
  86280. samplers: string[];
  86281. /**
  86282. * Define statements that will be set in the shader.
  86283. */
  86284. defines: any;
  86285. /**
  86286. * Possible fallbacks for this effect to improve performance when needed.
  86287. */
  86288. fallbacks: Nullable<EffectFallbacks>;
  86289. /**
  86290. * Callback that will be called when the shader is compiled.
  86291. */
  86292. onCompiled: Nullable<(effect: Effect) => void>;
  86293. /**
  86294. * Callback that will be called if an error occurs during shader compilation.
  86295. */
  86296. onError: Nullable<(effect: Effect, errors: string) => void>;
  86297. /**
  86298. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86299. */
  86300. indexParameters: any;
  86301. /**
  86302. * Max number of lights that can be used in the shader.
  86303. */
  86304. maxSimultaneousLights: number;
  86305. /**
  86306. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  86307. */
  86308. transformFeedbackVaryings: Nullable<string[]>;
  86309. }
  86310. /**
  86311. * Effect containing vertex and fragment shader that can be executed on an object.
  86312. */
  86313. export class Effect {
  86314. /**
  86315. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86316. */
  86317. static ShadersRepository: string;
  86318. /**
  86319. * Name of the effect.
  86320. */
  86321. name: any;
  86322. /**
  86323. * String container all the define statements that should be set on the shader.
  86324. */
  86325. defines: string;
  86326. /**
  86327. * Callback that will be called when the shader is compiled.
  86328. */
  86329. onCompiled: Nullable<(effect: Effect) => void>;
  86330. /**
  86331. * Callback that will be called if an error occurs during shader compilation.
  86332. */
  86333. onError: Nullable<(effect: Effect, errors: string) => void>;
  86334. /**
  86335. * Callback that will be called when effect is bound.
  86336. */
  86337. onBind: Nullable<(effect: Effect) => void>;
  86338. /**
  86339. * Unique ID of the effect.
  86340. */
  86341. uniqueId: number;
  86342. /**
  86343. * Observable that will be called when the shader is compiled.
  86344. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  86345. */
  86346. onCompileObservable: Observable<Effect>;
  86347. /**
  86348. * Observable that will be called if an error occurs during shader compilation.
  86349. */
  86350. onErrorObservable: Observable<Effect>;
  86351. /** @hidden */
  86352. _onBindObservable: Nullable<Observable<Effect>>;
  86353. /**
  86354. * Observable that will be called when effect is bound.
  86355. */
  86356. readonly onBindObservable: Observable<Effect>;
  86357. /** @hidden */
  86358. _bonesComputationForcedToCPU: boolean;
  86359. private static _uniqueIdSeed;
  86360. private _engine;
  86361. private _uniformBuffersNames;
  86362. private _uniformsNames;
  86363. private _samplers;
  86364. private _isReady;
  86365. private _compilationError;
  86366. private _attributesNames;
  86367. private _attributes;
  86368. private _uniforms;
  86369. /**
  86370. * Key for the effect.
  86371. * @hidden
  86372. */
  86373. _key: string;
  86374. private _indexParameters;
  86375. private _fallbacks;
  86376. private _vertexSourceCode;
  86377. private _fragmentSourceCode;
  86378. private _vertexSourceCodeOverride;
  86379. private _fragmentSourceCodeOverride;
  86380. private _transformFeedbackVaryings;
  86381. /**
  86382. * Compiled shader to webGL program.
  86383. * @hidden
  86384. */
  86385. _program: WebGLProgram;
  86386. private _valueCache;
  86387. private static _baseCache;
  86388. /**
  86389. * Instantiates an effect.
  86390. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86391. * @param baseName Name of the effect.
  86392. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86393. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86394. * @param samplers List of sampler variables that will be passed to the shader.
  86395. * @param engine Engine to be used to render the effect
  86396. * @param defines Define statements to be added to the shader.
  86397. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86398. * @param onCompiled Callback that will be called when the shader is compiled.
  86399. * @param onError Callback that will be called if an error occurs during shader compilation.
  86400. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86401. */
  86402. 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);
  86403. /**
  86404. * Unique key for this effect
  86405. */
  86406. readonly key: string;
  86407. /**
  86408. * If the effect has been compiled and prepared.
  86409. * @returns if the effect is compiled and prepared.
  86410. */
  86411. isReady(): boolean;
  86412. /**
  86413. * The engine the effect was initialized with.
  86414. * @returns the engine.
  86415. */
  86416. getEngine(): Engine;
  86417. /**
  86418. * The compiled webGL program for the effect
  86419. * @returns the webGL program.
  86420. */
  86421. getProgram(): WebGLProgram;
  86422. /**
  86423. * The set of names of attribute variables for the shader.
  86424. * @returns An array of attribute names.
  86425. */
  86426. getAttributesNames(): string[];
  86427. /**
  86428. * Returns the attribute at the given index.
  86429. * @param index The index of the attribute.
  86430. * @returns The location of the attribute.
  86431. */
  86432. getAttributeLocation(index: number): number;
  86433. /**
  86434. * Returns the attribute based on the name of the variable.
  86435. * @param name of the attribute to look up.
  86436. * @returns the attribute location.
  86437. */
  86438. getAttributeLocationByName(name: string): number;
  86439. /**
  86440. * The number of attributes.
  86441. * @returns the numnber of attributes.
  86442. */
  86443. getAttributesCount(): number;
  86444. /**
  86445. * Gets the index of a uniform variable.
  86446. * @param uniformName of the uniform to look up.
  86447. * @returns the index.
  86448. */
  86449. getUniformIndex(uniformName: string): number;
  86450. /**
  86451. * Returns the attribute based on the name of the variable.
  86452. * @param uniformName of the uniform to look up.
  86453. * @returns the location of the uniform.
  86454. */
  86455. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86456. /**
  86457. * Returns an array of sampler variable names
  86458. * @returns The array of sampler variable neames.
  86459. */
  86460. getSamplers(): string[];
  86461. /**
  86462. * The error from the last compilation.
  86463. * @returns the error string.
  86464. */
  86465. getCompilationError(): string;
  86466. /**
  86467. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86468. * @param func The callback to be used.
  86469. */
  86470. executeWhenCompiled(func: (effect: Effect) => void): void;
  86471. private _checkIsReady;
  86472. /** @hidden */
  86473. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86474. /** @hidden */
  86475. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86476. /** @hidden */
  86477. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86478. private _processShaderConversion;
  86479. private _processIncludes;
  86480. private _processPrecision;
  86481. /**
  86482. * Recompiles the webGL program
  86483. * @param vertexSourceCode The source code for the vertex shader.
  86484. * @param fragmentSourceCode The source code for the fragment shader.
  86485. * @param onCompiled Callback called when completed.
  86486. * @param onError Callback called on error.
  86487. * @hidden
  86488. */
  86489. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86490. /**
  86491. * Gets the uniform locations of the the specified variable names
  86492. * @param names THe names of the variables to lookup.
  86493. * @returns Array of locations in the same order as variable names.
  86494. */
  86495. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86496. /**
  86497. * Prepares the effect
  86498. * @hidden
  86499. */
  86500. _prepareEffect(): void;
  86501. /**
  86502. * Checks if the effect is supported. (Must be called after compilation)
  86503. */
  86504. readonly isSupported: boolean;
  86505. /**
  86506. * Binds a texture to the engine to be used as output of the shader.
  86507. * @param channel Name of the output variable.
  86508. * @param texture Texture to bind.
  86509. * @hidden
  86510. */
  86511. _bindTexture(channel: string, texture: InternalTexture): void;
  86512. /**
  86513. * Sets a texture on the engine to be used in the shader.
  86514. * @param channel Name of the sampler variable.
  86515. * @param texture Texture to set.
  86516. */
  86517. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86518. /**
  86519. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86520. * @param channel Name of the sampler variable.
  86521. * @param texture Texture to set.
  86522. */
  86523. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86524. /**
  86525. * Sets an array of textures on the engine to be used in the shader.
  86526. * @param channel Name of the variable.
  86527. * @param textures Textures to set.
  86528. */
  86529. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86530. /**
  86531. * 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)
  86532. * @param channel Name of the sampler variable.
  86533. * @param postProcess Post process to get the input texture from.
  86534. */
  86535. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86536. /**
  86537. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86538. * 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)
  86539. * @param channel Name of the sampler variable.
  86540. * @param postProcess Post process to get the output texture from.
  86541. */
  86542. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86543. /** @hidden */
  86544. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86545. /** @hidden */
  86546. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86547. /** @hidden */
  86548. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86549. /** @hidden */
  86550. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86551. /**
  86552. * Binds a buffer to a uniform.
  86553. * @param buffer Buffer to bind.
  86554. * @param name Name of the uniform variable to bind to.
  86555. */
  86556. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86557. /**
  86558. * Binds block to a uniform.
  86559. * @param blockName Name of the block to bind.
  86560. * @param index Index to bind.
  86561. */
  86562. bindUniformBlock(blockName: string, index: number): void;
  86563. /**
  86564. * Sets an interger value on a uniform variable.
  86565. * @param uniformName Name of the variable.
  86566. * @param value Value to be set.
  86567. * @returns this effect.
  86568. */
  86569. setInt(uniformName: string, value: number): Effect;
  86570. /**
  86571. * Sets an int array on a uniform variable.
  86572. * @param uniformName Name of the variable.
  86573. * @param array array to be set.
  86574. * @returns this effect.
  86575. */
  86576. setIntArray(uniformName: string, array: Int32Array): Effect;
  86577. /**
  86578. * 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)
  86579. * @param uniformName Name of the variable.
  86580. * @param array array to be set.
  86581. * @returns this effect.
  86582. */
  86583. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86584. /**
  86585. * 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)
  86586. * @param uniformName Name of the variable.
  86587. * @param array array to be set.
  86588. * @returns this effect.
  86589. */
  86590. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86591. /**
  86592. * 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)
  86593. * @param uniformName Name of the variable.
  86594. * @param array array to be set.
  86595. * @returns this effect.
  86596. */
  86597. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86598. /**
  86599. * Sets an float array on a uniform variable.
  86600. * @param uniformName Name of the variable.
  86601. * @param array array to be set.
  86602. * @returns this effect.
  86603. */
  86604. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86605. /**
  86606. * 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)
  86607. * @param uniformName Name of the variable.
  86608. * @param array array to be set.
  86609. * @returns this effect.
  86610. */
  86611. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86612. /**
  86613. * 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)
  86614. * @param uniformName Name of the variable.
  86615. * @param array array to be set.
  86616. * @returns this effect.
  86617. */
  86618. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86619. /**
  86620. * 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)
  86621. * @param uniformName Name of the variable.
  86622. * @param array array to be set.
  86623. * @returns this effect.
  86624. */
  86625. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86626. /**
  86627. * Sets an array on a uniform variable.
  86628. * @param uniformName Name of the variable.
  86629. * @param array array to be set.
  86630. * @returns this effect.
  86631. */
  86632. setArray(uniformName: string, array: number[]): Effect;
  86633. /**
  86634. * 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)
  86635. * @param uniformName Name of the variable.
  86636. * @param array array to be set.
  86637. * @returns this effect.
  86638. */
  86639. setArray2(uniformName: string, array: number[]): Effect;
  86640. /**
  86641. * 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)
  86642. * @param uniformName Name of the variable.
  86643. * @param array array to be set.
  86644. * @returns this effect.
  86645. */
  86646. setArray3(uniformName: string, array: number[]): Effect;
  86647. /**
  86648. * 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)
  86649. * @param uniformName Name of the variable.
  86650. * @param array array to be set.
  86651. * @returns this effect.
  86652. */
  86653. setArray4(uniformName: string, array: number[]): Effect;
  86654. /**
  86655. * Sets matrices on a uniform variable.
  86656. * @param uniformName Name of the variable.
  86657. * @param matrices matrices to be set.
  86658. * @returns this effect.
  86659. */
  86660. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86661. /**
  86662. * Sets matrix on a uniform variable.
  86663. * @param uniformName Name of the variable.
  86664. * @param matrix matrix to be set.
  86665. * @returns this effect.
  86666. */
  86667. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86668. /**
  86669. * 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)
  86670. * @param uniformName Name of the variable.
  86671. * @param matrix matrix to be set.
  86672. * @returns this effect.
  86673. */
  86674. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86675. /**
  86676. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86677. * @param uniformName Name of the variable.
  86678. * @param matrix matrix to be set.
  86679. * @returns this effect.
  86680. */
  86681. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86682. /**
  86683. * Sets a float on a uniform variable.
  86684. * @param uniformName Name of the variable.
  86685. * @param value value to be set.
  86686. * @returns this effect.
  86687. */
  86688. setFloat(uniformName: string, value: number): Effect;
  86689. /**
  86690. * Sets a boolean on a uniform variable.
  86691. * @param uniformName Name of the variable.
  86692. * @param bool value to be set.
  86693. * @returns this effect.
  86694. */
  86695. setBool(uniformName: string, bool: boolean): Effect;
  86696. /**
  86697. * Sets a Vector2 on a uniform variable.
  86698. * @param uniformName Name of the variable.
  86699. * @param vector2 vector2 to be set.
  86700. * @returns this effect.
  86701. */
  86702. setVector2(uniformName: string, vector2: Vector2): Effect;
  86703. /**
  86704. * Sets a float2 on a uniform variable.
  86705. * @param uniformName Name of the variable.
  86706. * @param x First float in float2.
  86707. * @param y Second float in float2.
  86708. * @returns this effect.
  86709. */
  86710. setFloat2(uniformName: string, x: number, y: number): Effect;
  86711. /**
  86712. * Sets a Vector3 on a uniform variable.
  86713. * @param uniformName Name of the variable.
  86714. * @param vector3 Value to be set.
  86715. * @returns this effect.
  86716. */
  86717. setVector3(uniformName: string, vector3: Vector3): Effect;
  86718. /**
  86719. * Sets a float3 on a uniform variable.
  86720. * @param uniformName Name of the variable.
  86721. * @param x First float in float3.
  86722. * @param y Second float in float3.
  86723. * @param z Third float in float3.
  86724. * @returns this effect.
  86725. */
  86726. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86727. /**
  86728. * Sets a Vector4 on a uniform variable.
  86729. * @param uniformName Name of the variable.
  86730. * @param vector4 Value to be set.
  86731. * @returns this effect.
  86732. */
  86733. setVector4(uniformName: string, vector4: Vector4): Effect;
  86734. /**
  86735. * Sets a float4 on a uniform variable.
  86736. * @param uniformName Name of the variable.
  86737. * @param x First float in float4.
  86738. * @param y Second float in float4.
  86739. * @param z Third float in float4.
  86740. * @param w Fourth float in float4.
  86741. * @returns this effect.
  86742. */
  86743. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86744. /**
  86745. * Sets a Color3 on a uniform variable.
  86746. * @param uniformName Name of the variable.
  86747. * @param color3 Value to be set.
  86748. * @returns this effect.
  86749. */
  86750. setColor3(uniformName: string, color3: Color3): Effect;
  86751. /**
  86752. * Sets a Color4 on a uniform variable.
  86753. * @param uniformName Name of the variable.
  86754. * @param color3 Value to be set.
  86755. * @param alpha Alpha value to be set.
  86756. * @returns this effect.
  86757. */
  86758. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86759. /**
  86760. * Sets a Color4 on a uniform variable
  86761. * @param uniformName defines the name of the variable
  86762. * @param color4 defines the value to be set
  86763. * @returns this effect.
  86764. */
  86765. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86766. /**
  86767. * This function will add a new shader to the shader store
  86768. * @param name the name of the shader
  86769. * @param pixelShader optional pixel shader content
  86770. * @param vertexShader optional vertex shader content
  86771. */
  86772. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86773. /**
  86774. * Store of each shader (The can be looked up using effect.key)
  86775. */
  86776. static ShadersStore: {
  86777. [key: string]: string;
  86778. };
  86779. /**
  86780. * Store of each included file for a shader (The can be looked up using effect.key)
  86781. */
  86782. static IncludesShadersStore: {
  86783. [key: string]: string;
  86784. };
  86785. /**
  86786. * Resets the cache of effects.
  86787. */
  86788. static ResetCache(): void;
  86789. }
  86790. }
  86791. declare module BABYLON {
  86792. /**
  86793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86795. * 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;
  86796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86797. */
  86798. export class ColorCurves {
  86799. private _dirty;
  86800. private _tempColor;
  86801. private _globalCurve;
  86802. private _highlightsCurve;
  86803. private _midtonesCurve;
  86804. private _shadowsCurve;
  86805. private _positiveCurve;
  86806. private _negativeCurve;
  86807. private _globalHue;
  86808. private _globalDensity;
  86809. private _globalSaturation;
  86810. private _globalExposure;
  86811. /**
  86812. * Gets the global Hue value.
  86813. * 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).
  86814. */
  86815. /**
  86816. * Sets the global Hue value.
  86817. * 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).
  86818. */
  86819. globalHue: number;
  86820. /**
  86821. * Gets the global Density value.
  86822. * 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.
  86823. * Values less than zero provide a filter of opposite hue.
  86824. */
  86825. /**
  86826. * Sets the global Density value.
  86827. * 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.
  86828. * Values less than zero provide a filter of opposite hue.
  86829. */
  86830. globalDensity: number;
  86831. /**
  86832. * Gets the global Saturation value.
  86833. * 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.
  86834. */
  86835. /**
  86836. * Sets the global Saturation value.
  86837. * 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.
  86838. */
  86839. globalSaturation: number;
  86840. /**
  86841. * Gets the global Exposure value.
  86842. * 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.
  86843. */
  86844. /**
  86845. * Sets the global Exposure value.
  86846. * 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.
  86847. */
  86848. globalExposure: number;
  86849. private _highlightsHue;
  86850. private _highlightsDensity;
  86851. private _highlightsSaturation;
  86852. private _highlightsExposure;
  86853. /**
  86854. * Gets the highlights Hue value.
  86855. * 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).
  86856. */
  86857. /**
  86858. * Sets the highlights Hue value.
  86859. * 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).
  86860. */
  86861. highlightsHue: number;
  86862. /**
  86863. * Gets the highlights Density value.
  86864. * 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.
  86865. * Values less than zero provide a filter of opposite hue.
  86866. */
  86867. /**
  86868. * Sets the highlights Density value.
  86869. * 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.
  86870. * Values less than zero provide a filter of opposite hue.
  86871. */
  86872. highlightsDensity: number;
  86873. /**
  86874. * Gets the highlights Saturation value.
  86875. * 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.
  86876. */
  86877. /**
  86878. * Sets the highlights Saturation value.
  86879. * 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.
  86880. */
  86881. highlightsSaturation: number;
  86882. /**
  86883. * Gets the highlights Exposure value.
  86884. * 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.
  86885. */
  86886. /**
  86887. * Sets the highlights Exposure value.
  86888. * 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.
  86889. */
  86890. highlightsExposure: number;
  86891. private _midtonesHue;
  86892. private _midtonesDensity;
  86893. private _midtonesSaturation;
  86894. private _midtonesExposure;
  86895. /**
  86896. * Gets the midtones Hue value.
  86897. * 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).
  86898. */
  86899. /**
  86900. * Sets the midtones Hue value.
  86901. * 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).
  86902. */
  86903. midtonesHue: number;
  86904. /**
  86905. * Gets the midtones Density value.
  86906. * 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.
  86907. * Values less than zero provide a filter of opposite hue.
  86908. */
  86909. /**
  86910. * Sets the midtones Density value.
  86911. * 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.
  86912. * Values less than zero provide a filter of opposite hue.
  86913. */
  86914. midtonesDensity: number;
  86915. /**
  86916. * Gets the midtones Saturation value.
  86917. * 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.
  86918. */
  86919. /**
  86920. * Sets the midtones Saturation value.
  86921. * 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.
  86922. */
  86923. midtonesSaturation: number;
  86924. /**
  86925. * Gets the midtones Exposure value.
  86926. * 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.
  86927. */
  86928. /**
  86929. * Sets the midtones Exposure value.
  86930. * 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.
  86931. */
  86932. midtonesExposure: number;
  86933. private _shadowsHue;
  86934. private _shadowsDensity;
  86935. private _shadowsSaturation;
  86936. private _shadowsExposure;
  86937. /**
  86938. * Gets the shadows Hue value.
  86939. * 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).
  86940. */
  86941. /**
  86942. * Sets the shadows Hue value.
  86943. * 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).
  86944. */
  86945. shadowsHue: number;
  86946. /**
  86947. * Gets the shadows Density value.
  86948. * 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.
  86949. * Values less than zero provide a filter of opposite hue.
  86950. */
  86951. /**
  86952. * Sets the shadows Density value.
  86953. * 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.
  86954. * Values less than zero provide a filter of opposite hue.
  86955. */
  86956. shadowsDensity: number;
  86957. /**
  86958. * Gets the shadows Saturation value.
  86959. * 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.
  86960. */
  86961. /**
  86962. * Sets the shadows Saturation value.
  86963. * 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.
  86964. */
  86965. shadowsSaturation: number;
  86966. /**
  86967. * Gets the shadows Exposure value.
  86968. * 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.
  86969. */
  86970. /**
  86971. * Sets the shadows Exposure value.
  86972. * 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.
  86973. */
  86974. shadowsExposure: number;
  86975. /**
  86976. * Returns the class name
  86977. * @returns The class name
  86978. */
  86979. getClassName(): string;
  86980. /**
  86981. * Binds the color curves to the shader.
  86982. * @param colorCurves The color curve to bind
  86983. * @param effect The effect to bind to
  86984. * @param positiveUniform The positive uniform shader parameter
  86985. * @param neutralUniform The neutral uniform shader parameter
  86986. * @param negativeUniform The negative uniform shader parameter
  86987. */
  86988. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86989. /**
  86990. * Prepare the list of uniforms associated with the ColorCurves effects.
  86991. * @param uniformsList The list of uniforms used in the effect
  86992. */
  86993. static PrepareUniforms(uniformsList: string[]): void;
  86994. /**
  86995. * Returns color grading data based on a hue, density, saturation and exposure value.
  86996. * @param filterHue The hue of the color filter.
  86997. * @param filterDensity The density of the color filter.
  86998. * @param saturation The saturation.
  86999. * @param exposure The exposure.
  87000. * @param result The result data container.
  87001. */
  87002. private getColorGradingDataToRef;
  87003. /**
  87004. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87005. * @param value The input slider value in range [-100,100].
  87006. * @returns Adjusted value.
  87007. */
  87008. private static applyColorGradingSliderNonlinear;
  87009. /**
  87010. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87011. * @param hue The hue (H) input.
  87012. * @param saturation The saturation (S) input.
  87013. * @param brightness The brightness (B) input.
  87014. * @result An RGBA color represented as Vector4.
  87015. */
  87016. private static fromHSBToRef;
  87017. /**
  87018. * Returns a value clamped between min and max
  87019. * @param value The value to clamp
  87020. * @param min The minimum of value
  87021. * @param max The maximum of value
  87022. * @returns The clamped value.
  87023. */
  87024. private static clamp;
  87025. /**
  87026. * Clones the current color curve instance.
  87027. * @return The cloned curves
  87028. */
  87029. clone(): ColorCurves;
  87030. /**
  87031. * Serializes the current color curve instance to a json representation.
  87032. * @return a JSON representation
  87033. */
  87034. serialize(): any;
  87035. /**
  87036. * Parses the color curve from a json representation.
  87037. * @param source the JSON source to parse
  87038. * @return The parsed curves
  87039. */
  87040. static Parse(source: any): ColorCurves;
  87041. }
  87042. }
  87043. declare module BABYLON {
  87044. /**
  87045. * Interface to follow in your material defines to integrate easily the
  87046. * Image proccessing functions.
  87047. * @hidden
  87048. */
  87049. export interface IImageProcessingConfigurationDefines {
  87050. IMAGEPROCESSING: boolean;
  87051. VIGNETTE: boolean;
  87052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87053. VIGNETTEBLENDMODEOPAQUE: boolean;
  87054. TONEMAPPING: boolean;
  87055. TONEMAPPING_ACES: boolean;
  87056. CONTRAST: boolean;
  87057. EXPOSURE: boolean;
  87058. COLORCURVES: boolean;
  87059. COLORGRADING: boolean;
  87060. COLORGRADING3D: boolean;
  87061. SAMPLER3DGREENDEPTH: boolean;
  87062. SAMPLER3DBGRMAP: boolean;
  87063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87064. }
  87065. /**
  87066. * @hidden
  87067. */
  87068. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87069. IMAGEPROCESSING: boolean;
  87070. VIGNETTE: boolean;
  87071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87072. VIGNETTEBLENDMODEOPAQUE: boolean;
  87073. TONEMAPPING: boolean;
  87074. TONEMAPPING_ACES: boolean;
  87075. CONTRAST: boolean;
  87076. COLORCURVES: boolean;
  87077. COLORGRADING: boolean;
  87078. COLORGRADING3D: boolean;
  87079. SAMPLER3DGREENDEPTH: boolean;
  87080. SAMPLER3DBGRMAP: boolean;
  87081. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87082. EXPOSURE: boolean;
  87083. constructor();
  87084. }
  87085. /**
  87086. * This groups together the common properties used for image processing either in direct forward pass
  87087. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87088. * or not.
  87089. */
  87090. export class ImageProcessingConfiguration {
  87091. /**
  87092. * Default tone mapping applied in BabylonJS.
  87093. */
  87094. static readonly TONEMAPPING_STANDARD: number;
  87095. /**
  87096. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87097. * to other engines rendering to increase portability.
  87098. */
  87099. static readonly TONEMAPPING_ACES: number;
  87100. /**
  87101. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87102. */
  87103. colorCurves: Nullable<ColorCurves>;
  87104. private _colorCurvesEnabled;
  87105. /**
  87106. * Gets wether the color curves effect is enabled.
  87107. */
  87108. /**
  87109. * Sets wether the color curves effect is enabled.
  87110. */
  87111. colorCurvesEnabled: boolean;
  87112. private _colorGradingTexture;
  87113. /**
  87114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87115. */
  87116. /**
  87117. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87118. */
  87119. colorGradingTexture: Nullable<BaseTexture>;
  87120. private _colorGradingEnabled;
  87121. /**
  87122. * Gets wether the color grading effect is enabled.
  87123. */
  87124. /**
  87125. * Sets wether the color grading effect is enabled.
  87126. */
  87127. colorGradingEnabled: boolean;
  87128. private _colorGradingWithGreenDepth;
  87129. /**
  87130. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87131. */
  87132. /**
  87133. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87134. */
  87135. colorGradingWithGreenDepth: boolean;
  87136. private _colorGradingBGR;
  87137. /**
  87138. * Gets wether the color grading texture contains BGR values.
  87139. */
  87140. /**
  87141. * Sets wether the color grading texture contains BGR values.
  87142. */
  87143. colorGradingBGR: boolean;
  87144. /** @hidden */
  87145. _exposure: number;
  87146. /**
  87147. * Gets the Exposure used in the effect.
  87148. */
  87149. /**
  87150. * Sets the Exposure used in the effect.
  87151. */
  87152. exposure: number;
  87153. private _toneMappingEnabled;
  87154. /**
  87155. * Gets wether the tone mapping effect is enabled.
  87156. */
  87157. /**
  87158. * Sets wether the tone mapping effect is enabled.
  87159. */
  87160. toneMappingEnabled: boolean;
  87161. private _toneMappingType;
  87162. /**
  87163. * Gets the type of tone mapping effect.
  87164. */
  87165. /**
  87166. * Sets the type of tone mapping effect used in BabylonJS.
  87167. */
  87168. toneMappingType: number;
  87169. protected _contrast: number;
  87170. /**
  87171. * Gets the contrast used in the effect.
  87172. */
  87173. /**
  87174. * Sets the contrast used in the effect.
  87175. */
  87176. contrast: number;
  87177. /**
  87178. * Vignette stretch size.
  87179. */
  87180. vignetteStretch: number;
  87181. /**
  87182. * Vignette centre X Offset.
  87183. */
  87184. vignetteCentreX: number;
  87185. /**
  87186. * Vignette centre Y Offset.
  87187. */
  87188. vignetteCentreY: number;
  87189. /**
  87190. * Vignette weight or intensity of the vignette effect.
  87191. */
  87192. vignetteWeight: number;
  87193. /**
  87194. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87195. * if vignetteEnabled is set to true.
  87196. */
  87197. vignetteColor: Color4;
  87198. /**
  87199. * Camera field of view used by the Vignette effect.
  87200. */
  87201. vignetteCameraFov: number;
  87202. private _vignetteBlendMode;
  87203. /**
  87204. * Gets the vignette blend mode allowing different kind of effect.
  87205. */
  87206. /**
  87207. * Sets the vignette blend mode allowing different kind of effect.
  87208. */
  87209. vignetteBlendMode: number;
  87210. private _vignetteEnabled;
  87211. /**
  87212. * Gets wether the vignette effect is enabled.
  87213. */
  87214. /**
  87215. * Sets wether the vignette effect is enabled.
  87216. */
  87217. vignetteEnabled: boolean;
  87218. private _applyByPostProcess;
  87219. /**
  87220. * Gets wether the image processing is applied through a post process or not.
  87221. */
  87222. /**
  87223. * Sets wether the image processing is applied through a post process or not.
  87224. */
  87225. applyByPostProcess: boolean;
  87226. private _isEnabled;
  87227. /**
  87228. * Gets wether the image processing is enabled or not.
  87229. */
  87230. /**
  87231. * Sets wether the image processing is enabled or not.
  87232. */
  87233. isEnabled: boolean;
  87234. /**
  87235. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87236. */
  87237. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87238. /**
  87239. * Method called each time the image processing information changes requires to recompile the effect.
  87240. */
  87241. protected _updateParameters(): void;
  87242. /**
  87243. * Gets the current class name.
  87244. * @return "ImageProcessingConfiguration"
  87245. */
  87246. getClassName(): string;
  87247. /**
  87248. * Prepare the list of uniforms associated with the Image Processing effects.
  87249. * @param uniforms The list of uniforms used in the effect
  87250. * @param defines the list of defines currently in use
  87251. */
  87252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87253. /**
  87254. * Prepare the list of samplers associated with the Image Processing effects.
  87255. * @param samplersList The list of uniforms used in the effect
  87256. * @param defines the list of defines currently in use
  87257. */
  87258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87259. /**
  87260. * Prepare the list of defines associated to the shader.
  87261. * @param defines the list of defines to complete
  87262. * @param forPostProcess Define if we are currently in post process mode or not
  87263. */
  87264. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87265. /**
  87266. * Returns true if all the image processing information are ready.
  87267. * @returns True if ready, otherwise, false
  87268. */
  87269. isReady(): boolean;
  87270. /**
  87271. * Binds the image processing to the shader.
  87272. * @param effect The effect to bind to
  87273. * @param aspectRatio Define the current aspect ratio of the effect
  87274. */
  87275. bind(effect: Effect, aspectRatio?: number): void;
  87276. /**
  87277. * Clones the current image processing instance.
  87278. * @return The cloned image processing
  87279. */
  87280. clone(): ImageProcessingConfiguration;
  87281. /**
  87282. * Serializes the current image processing instance to a json representation.
  87283. * @return a JSON representation
  87284. */
  87285. serialize(): any;
  87286. /**
  87287. * Parses the image processing from a json representation.
  87288. * @param source the JSON source to parse
  87289. * @return The parsed image processing
  87290. */
  87291. static Parse(source: any): ImageProcessingConfiguration;
  87292. private static _VIGNETTEMODE_MULTIPLY;
  87293. private static _VIGNETTEMODE_OPAQUE;
  87294. /**
  87295. * Used to apply the vignette as a mix with the pixel color.
  87296. */
  87297. static readonly VIGNETTEMODE_MULTIPLY: number;
  87298. /**
  87299. * Used to apply the vignette as a replacement of the pixel color.
  87300. */
  87301. static readonly VIGNETTEMODE_OPAQUE: number;
  87302. }
  87303. }
  87304. declare module BABYLON {
  87305. /**
  87306. * This represents all the required information to add a fresnel effect on a material:
  87307. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  87308. */
  87309. export class FresnelParameters {
  87310. private _isEnabled;
  87311. /**
  87312. * Define if the fresnel effect is enable or not.
  87313. */
  87314. isEnabled: boolean;
  87315. /**
  87316. * Define the color used on edges (grazing angle)
  87317. */
  87318. leftColor: Color3;
  87319. /**
  87320. * Define the color used on center
  87321. */
  87322. rightColor: Color3;
  87323. /**
  87324. * Define bias applied to computed fresnel term
  87325. */
  87326. bias: number;
  87327. /**
  87328. * Defined the power exponent applied to fresnel term
  87329. */
  87330. power: number;
  87331. /**
  87332. * Clones the current fresnel and its valuues
  87333. * @returns a clone fresnel configuration
  87334. */
  87335. clone(): FresnelParameters;
  87336. /**
  87337. * Serializes the current fresnel parameters to a JSON representation.
  87338. * @return the JSON serialization
  87339. */
  87340. serialize(): any;
  87341. /**
  87342. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  87343. * @param parsedFresnelParameters Define the JSON representation
  87344. * @returns the parsed parameters
  87345. */
  87346. static Parse(parsedFresnelParameters: any): FresnelParameters;
  87347. }
  87348. }
  87349. declare module BABYLON {
  87350. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  87351. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87352. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87353. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87354. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87355. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87356. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87357. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87358. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87359. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87360. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87361. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87362. /**
  87363. * Decorator used to define property that can be serialized as reference to a camera
  87364. * @param sourceName defines the name of the property to decorate
  87365. */
  87366. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87367. /**
  87368. * Class used to help serialization objects
  87369. */
  87370. export class SerializationHelper {
  87371. /** hidden */
  87372. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87373. /** hidden */
  87374. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87375. /** hidden */
  87376. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87377. /** hidden */
  87378. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87379. /**
  87380. * Appends the serialized animations from the source animations
  87381. * @param source Source containing the animations
  87382. * @param destination Target to store the animations
  87383. */
  87384. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87385. /**
  87386. * Static function used to serialized a specific entity
  87387. * @param entity defines the entity to serialize
  87388. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87389. * @returns a JSON compatible object representing the serialization of the entity
  87390. */
  87391. static Serialize<T>(entity: T, serializationObject?: any): any;
  87392. /**
  87393. * Creates a new entity from a serialization data object
  87394. * @param creationFunction defines a function used to instanciated the new entity
  87395. * @param source defines the source serialization data
  87396. * @param scene defines the hosting scene
  87397. * @param rootUrl defines the root url for resources
  87398. * @returns a new entity
  87399. */
  87400. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87401. /**
  87402. * Clones an object
  87403. * @param creationFunction defines the function used to instanciate the new object
  87404. * @param source defines the source object
  87405. * @returns the cloned object
  87406. */
  87407. static Clone<T>(creationFunction: () => T, source: T): T;
  87408. /**
  87409. * Instanciates a new object based on a source one (some data will be shared between both object)
  87410. * @param creationFunction defines the function used to instanciate the new object
  87411. * @param source defines the source object
  87412. * @returns the new object
  87413. */
  87414. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87415. }
  87416. }
  87417. declare module BABYLON {
  87418. /**
  87419. * This is the base class of all the camera used in the application.
  87420. * @see http://doc.babylonjs.com/features/cameras
  87421. */
  87422. export class Camera extends Node {
  87423. /** @hidden */
  87424. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87425. /**
  87426. * This is the default projection mode used by the cameras.
  87427. * It helps recreating a feeling of perspective and better appreciate depth.
  87428. * This is the best way to simulate real life cameras.
  87429. */
  87430. static readonly PERSPECTIVE_CAMERA: number;
  87431. /**
  87432. * This helps creating camera with an orthographic mode.
  87433. * 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.
  87434. */
  87435. static readonly ORTHOGRAPHIC_CAMERA: number;
  87436. /**
  87437. * This is the default FOV mode for perspective cameras.
  87438. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87439. */
  87440. static readonly FOVMODE_VERTICAL_FIXED: number;
  87441. /**
  87442. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87443. */
  87444. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87445. /**
  87446. * This specifies ther is no need for a camera rig.
  87447. * Basically only one eye is rendered corresponding to the camera.
  87448. */
  87449. static readonly RIG_MODE_NONE: number;
  87450. /**
  87451. * Simulates a camera Rig with one blue eye and one red eye.
  87452. * This can be use with 3d blue and red glasses.
  87453. */
  87454. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87455. /**
  87456. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87457. */
  87458. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87459. /**
  87460. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87461. */
  87462. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87463. /**
  87464. * Defines that both eyes of the camera will be rendered over under each other.
  87465. */
  87466. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87467. /**
  87468. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87469. */
  87470. static readonly RIG_MODE_VR: number;
  87471. /**
  87472. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87473. */
  87474. static readonly RIG_MODE_WEBVR: number;
  87475. /**
  87476. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87477. */
  87478. static readonly RIG_MODE_CUSTOM: number;
  87479. /**
  87480. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87481. */
  87482. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87483. /**
  87484. * @hidden
  87485. * Might be removed once multiview will be a thing
  87486. */
  87487. static UseAlternateWebVRRendering: boolean;
  87488. /**
  87489. * Define the input manager associated with the camera.
  87490. */
  87491. inputs: CameraInputsManager<Camera>;
  87492. /** @hidden */
  87493. _position: Vector3;
  87494. /**
  87495. * Define the current local position of the camera in the scene
  87496. */
  87497. position: Vector3;
  87498. /**
  87499. * The vector the camera should consider as up.
  87500. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87501. */
  87502. upVector: Vector3;
  87503. /**
  87504. * Define the current limit on the left side for an orthographic camera
  87505. * In scene unit
  87506. */
  87507. orthoLeft: Nullable<number>;
  87508. /**
  87509. * Define the current limit on the right side for an orthographic camera
  87510. * In scene unit
  87511. */
  87512. orthoRight: Nullable<number>;
  87513. /**
  87514. * Define the current limit on the bottom side for an orthographic camera
  87515. * In scene unit
  87516. */
  87517. orthoBottom: Nullable<number>;
  87518. /**
  87519. * Define the current limit on the top side for an orthographic camera
  87520. * In scene unit
  87521. */
  87522. orthoTop: Nullable<number>;
  87523. /**
  87524. * Field Of View is set in Radians. (default is 0.8)
  87525. */
  87526. fov: number;
  87527. /**
  87528. * Define the minimum distance the camera can see from.
  87529. * This is important to note that the depth buffer are not infinite and the closer it starts
  87530. * the more your scene might encounter depth fighting issue.
  87531. */
  87532. minZ: number;
  87533. /**
  87534. * Define the maximum distance the camera can see to.
  87535. * This is important to note that the depth buffer are not infinite and the further it end
  87536. * the more your scene might encounter depth fighting issue.
  87537. */
  87538. maxZ: number;
  87539. /**
  87540. * Define the default inertia of the camera.
  87541. * This helps giving a smooth feeling to the camera movement.
  87542. */
  87543. inertia: number;
  87544. /**
  87545. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87546. */
  87547. mode: number;
  87548. /**
  87549. * Define wether the camera is intermediate.
  87550. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87551. */
  87552. isIntermediate: boolean;
  87553. /**
  87554. * Define the viewport of the camera.
  87555. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87556. */
  87557. viewport: Viewport;
  87558. /**
  87559. * Restricts the camera to viewing objects with the same layerMask.
  87560. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87561. */
  87562. layerMask: number;
  87563. /**
  87564. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87565. */
  87566. fovMode: number;
  87567. /**
  87568. * Rig mode of the camera.
  87569. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87570. * This is normally controlled byt the camera themselves as internal use.
  87571. */
  87572. cameraRigMode: number;
  87573. /**
  87574. * Defines the distance between both "eyes" in case of a RIG
  87575. */
  87576. interaxialDistance: number;
  87577. /**
  87578. * Defines if stereoscopic rendering is done side by side or over under.
  87579. */
  87580. isStereoscopicSideBySide: boolean;
  87581. /**
  87582. * 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
  87583. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87584. * else in the scene.
  87585. */
  87586. customRenderTargets: RenderTargetTexture[];
  87587. /**
  87588. * When set, the camera will render to this render target instead of the default canvas
  87589. */
  87590. outputRenderTarget: Nullable<RenderTargetTexture>;
  87591. /**
  87592. * Observable triggered when the camera view matrix has changed.
  87593. */
  87594. onViewMatrixChangedObservable: Observable<Camera>;
  87595. /**
  87596. * Observable triggered when the camera Projection matrix has changed.
  87597. */
  87598. onProjectionMatrixChangedObservable: Observable<Camera>;
  87599. /**
  87600. * Observable triggered when the inputs have been processed.
  87601. */
  87602. onAfterCheckInputsObservable: Observable<Camera>;
  87603. /**
  87604. * Observable triggered when reset has been called and applied to the camera.
  87605. */
  87606. onRestoreStateObservable: Observable<Camera>;
  87607. /** @hidden */
  87608. _cameraRigParams: any;
  87609. /** @hidden */
  87610. _rigCameras: Camera[];
  87611. /** @hidden */
  87612. _rigPostProcess: Nullable<PostProcess>;
  87613. protected _webvrViewMatrix: Matrix;
  87614. /** @hidden */
  87615. _skipRendering: boolean;
  87616. /** @hidden */
  87617. _alternateCamera: Camera;
  87618. /** @hidden */
  87619. _projectionMatrix: Matrix;
  87620. /** @hidden */
  87621. _postProcesses: Nullable<PostProcess>[];
  87622. /** @hidden */
  87623. _activeMeshes: SmartArray<AbstractMesh>;
  87624. protected _globalPosition: Vector3;
  87625. /** hidden */
  87626. _computedViewMatrix: Matrix;
  87627. private _doNotComputeProjectionMatrix;
  87628. private _transformMatrix;
  87629. private _frustumPlanes;
  87630. private _refreshFrustumPlanes;
  87631. private _storedFov;
  87632. private _stateStored;
  87633. /**
  87634. * Instantiates a new camera object.
  87635. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87636. * @see http://doc.babylonjs.com/features/cameras
  87637. * @param name Defines the name of the camera in the scene
  87638. * @param position Defines the position of the camera
  87639. * @param scene Defines the scene the camera belongs too
  87640. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87641. */
  87642. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87643. /**
  87644. * Store current camera state (fov, position, etc..)
  87645. * @returns the camera
  87646. */
  87647. storeState(): Camera;
  87648. /**
  87649. * Restores the camera state values if it has been stored. You must call storeState() first
  87650. */
  87651. protected _restoreStateValues(): boolean;
  87652. /**
  87653. * Restored camera state. You must call storeState() first.
  87654. * @returns true if restored and false otherwise
  87655. */
  87656. restoreState(): boolean;
  87657. /**
  87658. * Gets the class name of the camera.
  87659. * @returns the class name
  87660. */
  87661. getClassName(): string;
  87662. /** @hidden */
  87663. readonly _isCamera: boolean;
  87664. /**
  87665. * Gets a string representation of the camera useful for debug purpose.
  87666. * @param fullDetails Defines that a more verboe level of logging is required
  87667. * @returns the string representation
  87668. */
  87669. toString(fullDetails?: boolean): string;
  87670. /**
  87671. * Gets the current world space position of the camera.
  87672. */
  87673. readonly globalPosition: Vector3;
  87674. /**
  87675. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87676. * @returns the active meshe list
  87677. */
  87678. getActiveMeshes(): SmartArray<AbstractMesh>;
  87679. /**
  87680. * Check wether a mesh is part of the current active mesh list of the camera
  87681. * @param mesh Defines the mesh to check
  87682. * @returns true if active, false otherwise
  87683. */
  87684. isActiveMesh(mesh: Mesh): boolean;
  87685. /**
  87686. * Is this camera ready to be used/rendered
  87687. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87688. * @return true if the camera is ready
  87689. */
  87690. isReady(completeCheck?: boolean): boolean;
  87691. /** @hidden */
  87692. _initCache(): void;
  87693. /** @hidden */
  87694. _updateCache(ignoreParentClass?: boolean): void;
  87695. /** @hidden */
  87696. _isSynchronized(): boolean;
  87697. /** @hidden */
  87698. _isSynchronizedViewMatrix(): boolean;
  87699. /** @hidden */
  87700. _isSynchronizedProjectionMatrix(): boolean;
  87701. /**
  87702. * Attach the input controls to a specific dom element to get the input from.
  87703. * @param element Defines the element the controls should be listened from
  87704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87705. */
  87706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87707. /**
  87708. * Detach the current controls from the specified dom element.
  87709. * @param element Defines the element to stop listening the inputs from
  87710. */
  87711. detachControl(element: HTMLElement): void;
  87712. /**
  87713. * Update the camera state according to the different inputs gathered during the frame.
  87714. */
  87715. update(): void;
  87716. /** @hidden */
  87717. _checkInputs(): void;
  87718. /** @hidden */
  87719. readonly rigCameras: Camera[];
  87720. /**
  87721. * Gets the post process used by the rig cameras
  87722. */
  87723. readonly rigPostProcess: Nullable<PostProcess>;
  87724. /**
  87725. * Internal, gets the first post proces.
  87726. * @returns the first post process to be run on this camera.
  87727. */
  87728. _getFirstPostProcess(): Nullable<PostProcess>;
  87729. private _cascadePostProcessesToRigCams;
  87730. /**
  87731. * Attach a post process to the camera.
  87732. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87733. * @param postProcess The post process to attach to the camera
  87734. * @param insertAt The position of the post process in case several of them are in use in the scene
  87735. * @returns the position the post process has been inserted at
  87736. */
  87737. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87738. /**
  87739. * Detach a post process to the camera.
  87740. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87741. * @param postProcess The post process to detach from the camera
  87742. */
  87743. detachPostProcess(postProcess: PostProcess): void;
  87744. /**
  87745. * Gets the current world matrix of the camera
  87746. */
  87747. getWorldMatrix(): Matrix;
  87748. /** @hidden */
  87749. _getViewMatrix(): Matrix;
  87750. /**
  87751. * Gets the current view matrix of the camera.
  87752. * @param force forces the camera to recompute the matrix without looking at the cached state
  87753. * @returns the view matrix
  87754. */
  87755. getViewMatrix(force?: boolean): Matrix;
  87756. /**
  87757. * Freeze the projection matrix.
  87758. * It will prevent the cache check of the camera projection compute and can speed up perf
  87759. * if no parameter of the camera are meant to change
  87760. * @param projection Defines manually a projection if necessary
  87761. */
  87762. freezeProjectionMatrix(projection?: Matrix): void;
  87763. /**
  87764. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87765. */
  87766. unfreezeProjectionMatrix(): void;
  87767. /**
  87768. * Gets the current projection matrix of the camera.
  87769. * @param force forces the camera to recompute the matrix without looking at the cached state
  87770. * @returns the projection matrix
  87771. */
  87772. getProjectionMatrix(force?: boolean): Matrix;
  87773. /**
  87774. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87775. * @returns a Matrix
  87776. */
  87777. getTransformationMatrix(): Matrix;
  87778. private _updateFrustumPlanes;
  87779. /**
  87780. * Checks if a cullable object (mesh...) is in the camera frustum
  87781. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87782. * @param target The object to check
  87783. * @returns true if the object is in frustum otherwise false
  87784. */
  87785. isInFrustum(target: ICullable): boolean;
  87786. /**
  87787. * Checks if a cullable object (mesh...) is in the camera frustum
  87788. * Unlike isInFrustum this cheks the full bounding box
  87789. * @param target The object to check
  87790. * @returns true if the object is in frustum otherwise false
  87791. */
  87792. isCompletelyInFrustum(target: ICullable): boolean;
  87793. /**
  87794. * Gets a ray in the forward direction from the camera.
  87795. * @param length Defines the length of the ray to create
  87796. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87797. * @param origin Defines the start point of the ray which defaults to the camera position
  87798. * @returns the forward ray
  87799. */
  87800. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87801. /**
  87802. * Releases resources associated with this node.
  87803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87805. */
  87806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87807. /** @hidden */
  87808. _isLeftCamera: boolean;
  87809. /**
  87810. * Gets the left camera of a rig setup in case of Rigged Camera
  87811. */
  87812. readonly isLeftCamera: boolean;
  87813. /** @hidden */
  87814. _isRightCamera: boolean;
  87815. /**
  87816. * Gets the right camera of a rig setup in case of Rigged Camera
  87817. */
  87818. readonly isRightCamera: boolean;
  87819. /**
  87820. * Gets the left camera of a rig setup in case of Rigged Camera
  87821. */
  87822. readonly leftCamera: Nullable<FreeCamera>;
  87823. /**
  87824. * Gets the right camera of a rig setup in case of Rigged Camera
  87825. */
  87826. readonly rightCamera: Nullable<FreeCamera>;
  87827. /**
  87828. * Gets the left camera target of a rig setup in case of Rigged Camera
  87829. * @returns the target position
  87830. */
  87831. getLeftTarget(): Nullable<Vector3>;
  87832. /**
  87833. * Gets the right camera target of a rig setup in case of Rigged Camera
  87834. * @returns the target position
  87835. */
  87836. getRightTarget(): Nullable<Vector3>;
  87837. /**
  87838. * @hidden
  87839. */
  87840. setCameraRigMode(mode: number, rigParams: any): void;
  87841. /** @hidden */
  87842. static _setStereoscopicRigMode(camera: Camera): void;
  87843. /** @hidden */
  87844. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87845. /** @hidden */
  87846. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87847. /** @hidden */
  87848. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87849. /** @hidden */
  87850. _getVRProjectionMatrix(): Matrix;
  87851. protected _updateCameraRotationMatrix(): void;
  87852. protected _updateWebVRCameraRotationMatrix(): void;
  87853. /**
  87854. * This function MUST be overwritten by the different WebVR cameras available.
  87855. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87856. * @hidden
  87857. */
  87858. _getWebVRProjectionMatrix(): Matrix;
  87859. /**
  87860. * This function MUST be overwritten by the different WebVR cameras available.
  87861. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87862. * @hidden
  87863. */
  87864. _getWebVRViewMatrix(): Matrix;
  87865. /** @hidden */
  87866. setCameraRigParameter(name: string, value: any): void;
  87867. /**
  87868. * needs to be overridden by children so sub has required properties to be copied
  87869. * @hidden
  87870. */
  87871. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87872. /**
  87873. * May need to be overridden by children
  87874. * @hidden
  87875. */
  87876. _updateRigCameras(): void;
  87877. /** @hidden */
  87878. _setupInputs(): void;
  87879. /**
  87880. * Serialiaze the camera setup to a json represention
  87881. * @returns the JSON representation
  87882. */
  87883. serialize(): any;
  87884. /**
  87885. * Clones the current camera.
  87886. * @param name The cloned camera name
  87887. * @returns the cloned camera
  87888. */
  87889. clone(name: string): Camera;
  87890. /**
  87891. * Gets the direction of the camera relative to a given local axis.
  87892. * @param localAxis Defines the reference axis to provide a relative direction.
  87893. * @return the direction
  87894. */
  87895. getDirection(localAxis: Vector3): Vector3;
  87896. /**
  87897. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87898. * @param localAxis Defines the reference axis to provide a relative direction.
  87899. * @param result Defines the vector to store the result in
  87900. */
  87901. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87902. /**
  87903. * Gets a camera constructor for a given camera type
  87904. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87905. * @param name The name of the camera the result will be able to instantiate
  87906. * @param scene The scene the result will construct the camera in
  87907. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87908. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87909. * @returns a factory method to construc the camera
  87910. */
  87911. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87912. /**
  87913. * Compute the world matrix of the camera.
  87914. * @returns the camera workd matrix
  87915. */
  87916. computeWorldMatrix(): Matrix;
  87917. /**
  87918. * Parse a JSON and creates the camera from the parsed information
  87919. * @param parsedCamera The JSON to parse
  87920. * @param scene The scene to instantiate the camera in
  87921. * @returns the newly constructed camera
  87922. */
  87923. static Parse(parsedCamera: any, scene: Scene): Camera;
  87924. }
  87925. }
  87926. declare module BABYLON {
  87927. /**
  87928. * Interface for any object that can request an animation frame
  87929. */
  87930. export interface ICustomAnimationFrameRequester {
  87931. /**
  87932. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87933. */
  87934. renderFunction?: Function;
  87935. /**
  87936. * Called to request the next frame to render to
  87937. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87938. */
  87939. requestAnimationFrame: Function;
  87940. /**
  87941. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87942. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87943. */
  87944. requestID?: number;
  87945. }
  87946. /**
  87947. * Interface containing an array of animations
  87948. */
  87949. export interface IAnimatable {
  87950. /**
  87951. * Array of animations
  87952. */
  87953. animations: Array<Animation>;
  87954. }
  87955. /** Interface used by value gradients (color, factor, ...) */
  87956. export interface IValueGradient {
  87957. /**
  87958. * Gets or sets the gradient value (between 0 and 1)
  87959. */
  87960. gradient: number;
  87961. }
  87962. /** Class used to store color4 gradient */
  87963. export class ColorGradient implements IValueGradient {
  87964. /**
  87965. * Gets or sets the gradient value (between 0 and 1)
  87966. */
  87967. gradient: number;
  87968. /**
  87969. * Gets or sets first associated color
  87970. */
  87971. color1: Color4;
  87972. /**
  87973. * Gets or sets second associated color
  87974. */
  87975. color2?: Color4;
  87976. /**
  87977. * Will get a color picked randomly between color1 and color2.
  87978. * If color2 is undefined then color1 will be used
  87979. * @param result defines the target Color4 to store the result in
  87980. */
  87981. getColorToRef(result: Color4): void;
  87982. }
  87983. /** Class used to store color 3 gradient */
  87984. export class Color3Gradient implements IValueGradient {
  87985. /**
  87986. * Gets or sets the gradient value (between 0 and 1)
  87987. */
  87988. gradient: number;
  87989. /**
  87990. * Gets or sets the associated color
  87991. */
  87992. color: Color3;
  87993. }
  87994. /** Class used to store factor gradient */
  87995. export class FactorGradient implements IValueGradient {
  87996. /**
  87997. * Gets or sets the gradient value (between 0 and 1)
  87998. */
  87999. gradient: number;
  88000. /**
  88001. * Gets or sets first associated factor
  88002. */
  88003. factor1: number;
  88004. /**
  88005. * Gets or sets second associated factor
  88006. */
  88007. factor2?: number;
  88008. /**
  88009. * Will get a number picked randomly between factor1 and factor2.
  88010. * If factor2 is undefined then factor1 will be used
  88011. * @returns the picked number
  88012. */
  88013. getFactor(): number;
  88014. }
  88015. /**
  88016. * @ignore
  88017. * Application error to support additional information when loading a file
  88018. */
  88019. export class LoadFileError extends Error {
  88020. /** defines the optional web request */
  88021. request?: WebRequest | undefined;
  88022. private static _setPrototypeOf;
  88023. /**
  88024. * Creates a new LoadFileError
  88025. * @param message defines the message of the error
  88026. * @param request defines the optional web request
  88027. */
  88028. constructor(message: string,
  88029. /** defines the optional web request */
  88030. request?: WebRequest | undefined);
  88031. }
  88032. /**
  88033. * Class used to define a retry strategy when error happens while loading assets
  88034. */
  88035. export class RetryStrategy {
  88036. /**
  88037. * Function used to defines an exponential back off strategy
  88038. * @param maxRetries defines the maximum number of retries (3 by default)
  88039. * @param baseInterval defines the interval between retries
  88040. * @returns the strategy function to use
  88041. */
  88042. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88043. }
  88044. /**
  88045. * File request interface
  88046. */
  88047. export interface IFileRequest {
  88048. /**
  88049. * Raised when the request is complete (success or error).
  88050. */
  88051. onCompleteObservable: Observable<IFileRequest>;
  88052. /**
  88053. * Aborts the request for a file.
  88054. */
  88055. abort: () => void;
  88056. }
  88057. /**
  88058. * Class containing a set of static utilities functions
  88059. */
  88060. export class Tools {
  88061. /**
  88062. * Gets or sets the base URL to use to load assets
  88063. */
  88064. static BaseUrl: string;
  88065. /**
  88066. * Enable/Disable Custom HTTP Request Headers globally.
  88067. * default = false
  88068. * @see CustomRequestHeaders
  88069. */
  88070. static UseCustomRequestHeaders: boolean;
  88071. /**
  88072. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  88073. * i.e. when loading files, where the server/service expects an Authorization header
  88074. */
  88075. static CustomRequestHeaders: {
  88076. [key: string]: string;
  88077. };
  88078. /**
  88079. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  88080. */
  88081. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  88082. /**
  88083. * Default behaviour for cors in the application.
  88084. * It can be a string if the expected behavior is identical in the entire app.
  88085. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  88086. */
  88087. static CorsBehavior: string | ((url: string | string[]) => string);
  88088. /**
  88089. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  88090. * @ignorenaming
  88091. */
  88092. static UseFallbackTexture: boolean;
  88093. /**
  88094. * Use this object to register external classes like custom textures or material
  88095. * to allow the laoders to instantiate them
  88096. */
  88097. static RegisteredExternalClasses: {
  88098. [key: string]: Object;
  88099. };
  88100. /**
  88101. * Texture content used if a texture cannot loaded
  88102. * @ignorenaming
  88103. */
  88104. static fallbackTexture: string;
  88105. /**
  88106. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  88107. * @param u defines the coordinate on X axis
  88108. * @param v defines the coordinate on Y axis
  88109. * @param width defines the width of the source data
  88110. * @param height defines the height of the source data
  88111. * @param pixels defines the source byte array
  88112. * @param color defines the output color
  88113. */
  88114. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  88115. /**
  88116. * Interpolates between a and b via alpha
  88117. * @param a The lower value (returned when alpha = 0)
  88118. * @param b The upper value (returned when alpha = 1)
  88119. * @param alpha The interpolation-factor
  88120. * @return The mixed value
  88121. */
  88122. static Mix(a: number, b: number, alpha: number): number;
  88123. /**
  88124. * Tries to instantiate a new object from a given class name
  88125. * @param className defines the class name to instantiate
  88126. * @returns the new object or null if the system was not able to do the instantiation
  88127. */
  88128. static Instantiate(className: string): any;
  88129. /**
  88130. * Provides a slice function that will work even on IE
  88131. * @param data defines the array to slice
  88132. * @param start defines the start of the data (optional)
  88133. * @param end defines the end of the data (optional)
  88134. * @returns the new sliced array
  88135. */
  88136. static Slice<T>(data: T, start?: number, end?: number): T;
  88137. /**
  88138. * Polyfill for setImmediate
  88139. * @param action defines the action to execute after the current execution block
  88140. */
  88141. static SetImmediate(action: () => void): void;
  88142. /**
  88143. * Function indicating if a number is an exponent of 2
  88144. * @param value defines the value to test
  88145. * @returns true if the value is an exponent of 2
  88146. */
  88147. static IsExponentOfTwo(value: number): boolean;
  88148. private static _tmpFloatArray;
  88149. /**
  88150. * Returns the nearest 32-bit single precision float representation of a Number
  88151. * @param value A Number. If the parameter is of a different type, it will get converted
  88152. * to a number or to NaN if it cannot be converted
  88153. * @returns number
  88154. */
  88155. static FloatRound(value: number): number;
  88156. /**
  88157. * Find the next highest power of two.
  88158. * @param x Number to start search from.
  88159. * @return Next highest power of two.
  88160. */
  88161. static CeilingPOT(x: number): number;
  88162. /**
  88163. * Find the next lowest power of two.
  88164. * @param x Number to start search from.
  88165. * @return Next lowest power of two.
  88166. */
  88167. static FloorPOT(x: number): number;
  88168. /**
  88169. * Find the nearest power of two.
  88170. * @param x Number to start search from.
  88171. * @return Next nearest power of two.
  88172. */
  88173. static NearestPOT(x: number): number;
  88174. /**
  88175. * Get the closest exponent of two
  88176. * @param value defines the value to approximate
  88177. * @param max defines the maximum value to return
  88178. * @param mode defines how to define the closest value
  88179. * @returns closest exponent of two of the given value
  88180. */
  88181. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88182. /**
  88183. * Extracts the filename from a path
  88184. * @param path defines the path to use
  88185. * @returns the filename
  88186. */
  88187. static GetFilename(path: string): string;
  88188. /**
  88189. * Extracts the "folder" part of a path (everything before the filename).
  88190. * @param uri The URI to extract the info from
  88191. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  88192. * @returns The "folder" part of the path
  88193. */
  88194. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  88195. /**
  88196. * Extracts text content from a DOM element hierarchy
  88197. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  88198. */
  88199. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  88200. /**
  88201. * Convert an angle in radians to degrees
  88202. * @param angle defines the angle to convert
  88203. * @returns the angle in degrees
  88204. */
  88205. static ToDegrees(angle: number): number;
  88206. /**
  88207. * Convert an angle in degrees to radians
  88208. * @param angle defines the angle to convert
  88209. * @returns the angle in radians
  88210. */
  88211. static ToRadians(angle: number): number;
  88212. /**
  88213. * Encode a buffer to a base64 string
  88214. * @param buffer defines the buffer to encode
  88215. * @returns the encoded string
  88216. */
  88217. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  88218. /**
  88219. * Extracts minimum and maximum values from a list of indexed positions
  88220. * @param positions defines the positions to use
  88221. * @param indices defines the indices to the positions
  88222. * @param indexStart defines the start index
  88223. * @param indexCount defines the end index
  88224. * @param bias defines bias value to add to the result
  88225. * @return minimum and maximum values
  88226. */
  88227. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88228. minimum: Vector3;
  88229. maximum: Vector3;
  88230. };
  88231. /**
  88232. * Extracts minimum and maximum values from a list of positions
  88233. * @param positions defines the positions to use
  88234. * @param start defines the start index in the positions array
  88235. * @param count defines the number of positions to handle
  88236. * @param bias defines bias value to add to the result
  88237. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88238. * @return minimum and maximum values
  88239. */
  88240. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88241. minimum: Vector3;
  88242. maximum: Vector3;
  88243. };
  88244. /**
  88245. * Returns an array if obj is not an array
  88246. * @param obj defines the object to evaluate as an array
  88247. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  88248. * @returns either obj directly if obj is an array or a new array containing obj
  88249. */
  88250. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  88251. /**
  88252. * Gets the pointer prefix to use
  88253. * @returns "pointer" if touch is enabled. Else returns "mouse"
  88254. */
  88255. static GetPointerPrefix(): string;
  88256. /**
  88257. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  88258. * @param func - the function to be called
  88259. * @param requester - the object that will request the next frame. Falls back to window.
  88260. * @returns frame number
  88261. */
  88262. static QueueNewFrame(func: () => void, requester?: any): number;
  88263. /**
  88264. * Ask the browser to promote the current element to fullscreen rendering mode
  88265. * @param element defines the DOM element to promote
  88266. */
  88267. static RequestFullscreen(element: HTMLElement): void;
  88268. /**
  88269. * Asks the browser to exit fullscreen mode
  88270. */
  88271. static ExitFullscreen(): void;
  88272. /**
  88273. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  88274. * @param url define the url we are trying
  88275. * @param element define the dom element where to configure the cors policy
  88276. */
  88277. static SetCorsBehavior(url: string | string[], element: {
  88278. crossOrigin: string | null;
  88279. }): void;
  88280. /**
  88281. * Removes unwanted characters from an url
  88282. * @param url defines the url to clean
  88283. * @returns the cleaned url
  88284. */
  88285. static CleanUrl(url: string): string;
  88286. /**
  88287. * Gets or sets a function used to pre-process url before using them to load assets
  88288. */
  88289. static PreprocessUrl: (url: string) => string;
  88290. /**
  88291. * Loads an image as an HTMLImageElement.
  88292. * @param input url string, ArrayBuffer, or Blob to load
  88293. * @param onLoad callback called when the image successfully loads
  88294. * @param onError callback called when the image fails to load
  88295. * @param offlineProvider offline provider for caching
  88296. * @returns the HTMLImageElement of the loaded image
  88297. */
  88298. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  88299. /**
  88300. * Loads a file
  88301. * @param url url string, ArrayBuffer, or Blob to load
  88302. * @param onSuccess callback called when the file successfully loads
  88303. * @param onProgress callback called while file is loading (if the server supports this mode)
  88304. * @param offlineProvider defines the offline provider for caching
  88305. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  88306. * @param onError callback called when the file fails to load
  88307. * @returns a file request object
  88308. */
  88309. 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;
  88310. /**
  88311. * Load a script (identified by an url). When the url returns, the
  88312. * content of this file is added into a new script element, attached to the DOM (body element)
  88313. * @param scriptUrl defines the url of the script to laod
  88314. * @param onSuccess defines the callback called when the script is loaded
  88315. * @param onError defines the callback to call if an error occurs
  88316. */
  88317. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  88318. /**
  88319. * Loads a file from a blob
  88320. * @param fileToLoad defines the blob to use
  88321. * @param callback defines the callback to call when data is loaded
  88322. * @param progressCallback defines the callback to call during loading process
  88323. * @returns a file request object
  88324. */
  88325. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  88326. /**
  88327. * Loads a file
  88328. * @param fileToLoad defines the file to load
  88329. * @param callback defines the callback to call when data is loaded
  88330. * @param progressCallBack defines the callback to call during loading process
  88331. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  88332. * @returns a file request object
  88333. */
  88334. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  88335. /**
  88336. * Creates a data url from a given string content
  88337. * @param content defines the content to convert
  88338. * @returns the new data url link
  88339. */
  88340. static FileAsURL(content: string): string;
  88341. /**
  88342. * Format the given number to a specific decimal format
  88343. * @param value defines the number to format
  88344. * @param decimals defines the number of decimals to use
  88345. * @returns the formatted string
  88346. */
  88347. static Format(value: number, decimals?: number): string;
  88348. /**
  88349. * Checks if a given vector is inside a specific range
  88350. * @param v defines the vector to test
  88351. * @param min defines the minimum range
  88352. * @param max defines the maximum range
  88353. */
  88354. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88355. /**
  88356. * Tries to copy an object by duplicating every property
  88357. * @param source defines the source object
  88358. * @param destination defines the target object
  88359. * @param doNotCopyList defines a list of properties to avoid
  88360. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88361. */
  88362. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88363. /**
  88364. * Gets a boolean indicating if the given object has no own property
  88365. * @param obj defines the object to test
  88366. * @returns true if object has no own property
  88367. */
  88368. static IsEmpty(obj: any): boolean;
  88369. /**
  88370. * Function used to register events at window level
  88371. * @param events defines the events to register
  88372. */
  88373. static RegisterTopRootEvents(events: {
  88374. name: string;
  88375. handler: Nullable<(e: FocusEvent) => any>;
  88376. }[]): void;
  88377. /**
  88378. * Function used to unregister events from window level
  88379. * @param events defines the events to unregister
  88380. */
  88381. static UnregisterTopRootEvents(events: {
  88382. name: string;
  88383. handler: Nullable<(e: FocusEvent) => any>;
  88384. }[]): void;
  88385. /**
  88386. * @ignore
  88387. */
  88388. static _ScreenshotCanvas: HTMLCanvasElement;
  88389. /**
  88390. * Dumps the current bound framebuffer
  88391. * @param width defines the rendering width
  88392. * @param height defines the rendering height
  88393. * @param engine defines the hosting engine
  88394. * @param successCallback defines the callback triggered once the data are available
  88395. * @param mimeType defines the mime type of the result
  88396. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88397. */
  88398. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88399. /**
  88400. * Converts the canvas data to blob.
  88401. * This acts as a polyfill for browsers not supporting the to blob function.
  88402. * @param canvas Defines the canvas to extract the data from
  88403. * @param successCallback Defines the callback triggered once the data are available
  88404. * @param mimeType Defines the mime type of the result
  88405. */
  88406. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88407. /**
  88408. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88409. * @param successCallback defines the callback triggered once the data are available
  88410. * @param mimeType defines the mime type of the result
  88411. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88412. */
  88413. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88414. /**
  88415. * Downloads a blob in the browser
  88416. * @param blob defines the blob to download
  88417. * @param fileName defines the name of the downloaded file
  88418. */
  88419. static Download(blob: Blob, fileName: string): void;
  88420. /**
  88421. * Captures a screenshot of the current rendering
  88422. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88423. * @param engine defines the rendering engine
  88424. * @param camera defines the source camera
  88425. * @param size This parameter can be set to a single number or to an object with the
  88426. * following (optional) properties: precision, width, height. If a single number is passed,
  88427. * it will be used for both width and height. If an object is passed, the screenshot size
  88428. * will be derived from the parameters. The precision property is a multiplier allowing
  88429. * rendering at a higher or lower resolution
  88430. * @param successCallback defines the callback receives a single parameter which contains the
  88431. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88432. * src parameter of an <img> to display it
  88433. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88434. * Check your browser for supported MIME types
  88435. */
  88436. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88437. /**
  88438. * Generates an image screenshot from the specified camera.
  88439. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88440. * @param engine The engine to use for rendering
  88441. * @param camera The camera to use for rendering
  88442. * @param size This parameter can be set to a single number or to an object with the
  88443. * following (optional) properties: precision, width, height. If a single number is passed,
  88444. * it will be used for both width and height. If an object is passed, the screenshot size
  88445. * will be derived from the parameters. The precision property is a multiplier allowing
  88446. * rendering at a higher or lower resolution
  88447. * @param successCallback The callback receives a single parameter which contains the
  88448. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88449. * src parameter of an <img> to display it
  88450. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88451. * Check your browser for supported MIME types
  88452. * @param samples Texture samples (default: 1)
  88453. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88454. * @param fileName A name for for the downloaded file.
  88455. */
  88456. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88457. /**
  88458. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88459. * Be aware Math.random() could cause collisions, but:
  88460. * "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"
  88461. * @returns a pseudo random id
  88462. */
  88463. static RandomId(): string;
  88464. /**
  88465. * Test if the given uri is a base64 string
  88466. * @param uri The uri to test
  88467. * @return True if the uri is a base64 string or false otherwise
  88468. */
  88469. static IsBase64(uri: string): boolean;
  88470. /**
  88471. * Decode the given base64 uri.
  88472. * @param uri The uri to decode
  88473. * @return The decoded base64 data.
  88474. */
  88475. static DecodeBase64(uri: string): ArrayBuffer;
  88476. /**
  88477. * No log
  88478. */
  88479. static readonly NoneLogLevel: number;
  88480. /**
  88481. * Only message logs
  88482. */
  88483. static readonly MessageLogLevel: number;
  88484. /**
  88485. * Only warning logs
  88486. */
  88487. static readonly WarningLogLevel: number;
  88488. /**
  88489. * Only error logs
  88490. */
  88491. static readonly ErrorLogLevel: number;
  88492. /**
  88493. * All logs
  88494. */
  88495. static readonly AllLogLevel: number;
  88496. /**
  88497. * Gets a value indicating the number of loading errors
  88498. * @ignorenaming
  88499. */
  88500. static readonly errorsCount: number;
  88501. /**
  88502. * Callback called when a new log is added
  88503. */
  88504. static OnNewCacheEntry: (entry: string) => void;
  88505. /**
  88506. * Log a message to the console
  88507. * @param message defines the message to log
  88508. */
  88509. static Log(message: string): void;
  88510. /**
  88511. * Write a warning message to the console
  88512. * @param message defines the message to log
  88513. */
  88514. static Warn(message: string): void;
  88515. /**
  88516. * Write an error message to the console
  88517. * @param message defines the message to log
  88518. */
  88519. static Error(message: string): void;
  88520. /**
  88521. * Gets current log cache (list of logs)
  88522. */
  88523. static readonly LogCache: string;
  88524. /**
  88525. * Clears the log cache
  88526. */
  88527. static ClearLogCache(): void;
  88528. /**
  88529. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88530. */
  88531. static LogLevels: number;
  88532. /**
  88533. * Checks if the loaded document was accessed via `file:`-Protocol.
  88534. * @returns boolean
  88535. */
  88536. static IsFileURL(): boolean;
  88537. /**
  88538. * Checks if the window object exists
  88539. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88540. */
  88541. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88542. /**
  88543. * No performance log
  88544. */
  88545. static readonly PerformanceNoneLogLevel: number;
  88546. /**
  88547. * Use user marks to log performance
  88548. */
  88549. static readonly PerformanceUserMarkLogLevel: number;
  88550. /**
  88551. * Log performance to the console
  88552. */
  88553. static readonly PerformanceConsoleLogLevel: number;
  88554. private static _performance;
  88555. /**
  88556. * Sets the current performance log level
  88557. */
  88558. static PerformanceLogLevel: number;
  88559. private static _StartPerformanceCounterDisabled;
  88560. private static _EndPerformanceCounterDisabled;
  88561. private static _StartUserMark;
  88562. private static _EndUserMark;
  88563. private static _StartPerformanceConsole;
  88564. private static _EndPerformanceConsole;
  88565. /**
  88566. * Starts a performance counter
  88567. */
  88568. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88569. /**
  88570. * Ends a specific performance coutner
  88571. */
  88572. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88573. /**
  88574. * Gets either window.performance.now() if supported or Date.now() else
  88575. */
  88576. static readonly Now: number;
  88577. /**
  88578. * This method will return the name of the class used to create the instance of the given object.
  88579. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88580. * @param object the object to get the class name from
  88581. * @param isType defines if the object is actually a type
  88582. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88583. */
  88584. static GetClassName(object: any, isType?: boolean): string;
  88585. /**
  88586. * Gets the first element of an array satisfying a given predicate
  88587. * @param array defines the array to browse
  88588. * @param predicate defines the predicate to use
  88589. * @returns null if not found or the element
  88590. */
  88591. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88592. /**
  88593. * This method will return the name of the full name of the class, including its owning module (if any).
  88594. * 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).
  88595. * @param object the object to get the class name from
  88596. * @param isType defines if the object is actually a type
  88597. * @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.
  88598. * @ignorenaming
  88599. */
  88600. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88601. /**
  88602. * Returns a promise that resolves after the given amount of time.
  88603. * @param delay Number of milliseconds to delay
  88604. * @returns Promise that resolves after the given amount of time
  88605. */
  88606. static DelayAsync(delay: number): Promise<void>;
  88607. /**
  88608. * Gets the current gradient from an array of IValueGradient
  88609. * @param ratio defines the current ratio to get
  88610. * @param gradients defines the array of IValueGradient
  88611. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88612. */
  88613. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88614. }
  88615. /**
  88616. * This class is used to track a performance counter which is number based.
  88617. * The user has access to many properties which give statistics of different nature.
  88618. *
  88619. * The implementer can track two kinds of Performance Counter: time and count.
  88620. * 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.
  88621. * 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.
  88622. */
  88623. export class PerfCounter {
  88624. /**
  88625. * Gets or sets a global boolean to turn on and off all the counters
  88626. */
  88627. static Enabled: boolean;
  88628. /**
  88629. * Returns the smallest value ever
  88630. */
  88631. readonly min: number;
  88632. /**
  88633. * Returns the biggest value ever
  88634. */
  88635. readonly max: number;
  88636. /**
  88637. * Returns the average value since the performance counter is running
  88638. */
  88639. readonly average: number;
  88640. /**
  88641. * Returns the average value of the last second the counter was monitored
  88642. */
  88643. readonly lastSecAverage: number;
  88644. /**
  88645. * Returns the current value
  88646. */
  88647. readonly current: number;
  88648. /**
  88649. * Gets the accumulated total
  88650. */
  88651. readonly total: number;
  88652. /**
  88653. * Gets the total value count
  88654. */
  88655. readonly count: number;
  88656. /**
  88657. * Creates a new counter
  88658. */
  88659. constructor();
  88660. /**
  88661. * Call this method to start monitoring a new frame.
  88662. * 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.
  88663. */
  88664. fetchNewFrame(): void;
  88665. /**
  88666. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88667. * @param newCount the count value to add to the monitored count
  88668. * @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.
  88669. */
  88670. addCount(newCount: number, fetchResult: boolean): void;
  88671. /**
  88672. * Start monitoring this performance counter
  88673. */
  88674. beginMonitoring(): void;
  88675. /**
  88676. * Compute the time lapsed since the previous beginMonitoring() call.
  88677. * @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
  88678. */
  88679. endMonitoring(newFrame?: boolean): void;
  88680. private _fetchResult;
  88681. private _startMonitoringTime;
  88682. private _min;
  88683. private _max;
  88684. private _average;
  88685. private _current;
  88686. private _totalValueCount;
  88687. private _totalAccumulated;
  88688. private _lastSecAverage;
  88689. private _lastSecAccumulated;
  88690. private _lastSecTime;
  88691. private _lastSecValueCount;
  88692. }
  88693. /**
  88694. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88695. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88696. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88697. * @param name The name of the class, case should be preserved
  88698. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88699. */
  88700. export function className(name: string, module?: string): (target: Object) => void;
  88701. /**
  88702. * An implementation of a loop for asynchronous functions.
  88703. */
  88704. export class AsyncLoop {
  88705. /**
  88706. * Defines the number of iterations for the loop
  88707. */
  88708. iterations: number;
  88709. /**
  88710. * Defines the current index of the loop.
  88711. */
  88712. index: number;
  88713. private _done;
  88714. private _fn;
  88715. private _successCallback;
  88716. /**
  88717. * Constructor.
  88718. * @param iterations the number of iterations.
  88719. * @param func the function to run each iteration
  88720. * @param successCallback the callback that will be called upon succesful execution
  88721. * @param offset starting offset.
  88722. */
  88723. constructor(
  88724. /**
  88725. * Defines the number of iterations for the loop
  88726. */
  88727. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88728. /**
  88729. * Execute the next iteration. Must be called after the last iteration was finished.
  88730. */
  88731. executeNext(): void;
  88732. /**
  88733. * Break the loop and run the success callback.
  88734. */
  88735. breakLoop(): void;
  88736. /**
  88737. * Create and run an async loop.
  88738. * @param iterations the number of iterations.
  88739. * @param fn the function to run each iteration
  88740. * @param successCallback the callback that will be called upon succesful execution
  88741. * @param offset starting offset.
  88742. * @returns the created async loop object
  88743. */
  88744. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88745. /**
  88746. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88747. * @param iterations total number of iterations
  88748. * @param syncedIterations number of synchronous iterations in each async iteration.
  88749. * @param fn the function to call each iteration.
  88750. * @param callback a success call back that will be called when iterating stops.
  88751. * @param breakFunction a break condition (optional)
  88752. * @param timeout timeout settings for the setTimeout function. default - 0.
  88753. * @returns the created async loop object
  88754. */
  88755. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88756. }
  88757. }
  88758. declare module BABYLON {
  88759. /** @hidden */
  88760. export interface ICollisionCoordinator {
  88761. createCollider(): Collider;
  88762. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88763. init(scene: Scene): void;
  88764. }
  88765. /** @hidden */
  88766. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88767. private _scene;
  88768. private _scaledPosition;
  88769. private _scaledVelocity;
  88770. private _finalPosition;
  88771. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88772. createCollider(): Collider;
  88773. init(scene: Scene): void;
  88774. private _collideWithWorld;
  88775. }
  88776. }
  88777. declare module BABYLON {
  88778. /**
  88779. * This class defines the direct association between an animation and a target
  88780. */
  88781. export class TargetedAnimation {
  88782. /**
  88783. * Animation to perform
  88784. */
  88785. animation: Animation;
  88786. /**
  88787. * Target to animate
  88788. */
  88789. target: any;
  88790. }
  88791. /**
  88792. * Use this class to create coordinated animations on multiple targets
  88793. */
  88794. export class AnimationGroup implements IDisposable {
  88795. /** The name of the animation group */
  88796. name: string;
  88797. private _scene;
  88798. private _targetedAnimations;
  88799. private _animatables;
  88800. private _from;
  88801. private _to;
  88802. private _isStarted;
  88803. private _isPaused;
  88804. private _speedRatio;
  88805. /**
  88806. * Gets or sets the unique id of the node
  88807. */
  88808. uniqueId: number;
  88809. /**
  88810. * This observable will notify when one animation have ended
  88811. */
  88812. onAnimationEndObservable: Observable<TargetedAnimation>;
  88813. /**
  88814. * Observer raised when one animation loops
  88815. */
  88816. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88817. /**
  88818. * This observable will notify when all animations have ended.
  88819. */
  88820. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88821. /**
  88822. * This observable will notify when all animations have paused.
  88823. */
  88824. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88825. /**
  88826. * This observable will notify when all animations are playing.
  88827. */
  88828. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88829. /**
  88830. * Gets the first frame
  88831. */
  88832. readonly from: number;
  88833. /**
  88834. * Gets the last frame
  88835. */
  88836. readonly to: number;
  88837. /**
  88838. * Define if the animations are started
  88839. */
  88840. readonly isStarted: boolean;
  88841. /**
  88842. * Gets a value indicating that the current group is playing
  88843. */
  88844. readonly isPlaying: boolean;
  88845. /**
  88846. * Gets or sets the speed ratio to use for all animations
  88847. */
  88848. /**
  88849. * Gets or sets the speed ratio to use for all animations
  88850. */
  88851. speedRatio: number;
  88852. /**
  88853. * Gets the targeted animations for this animation group
  88854. */
  88855. readonly targetedAnimations: Array<TargetedAnimation>;
  88856. /**
  88857. * returning the list of animatables controlled by this animation group.
  88858. */
  88859. readonly animatables: Array<Animatable>;
  88860. /**
  88861. * Instantiates a new Animation Group.
  88862. * This helps managing several animations at once.
  88863. * @see http://doc.babylonjs.com/how_to/group
  88864. * @param name Defines the name of the group
  88865. * @param scene Defines the scene the group belongs to
  88866. */
  88867. constructor(
  88868. /** The name of the animation group */
  88869. name: string, scene?: Nullable<Scene>);
  88870. /**
  88871. * Add an animation (with its target) in the group
  88872. * @param animation defines the animation we want to add
  88873. * @param target defines the target of the animation
  88874. * @returns the TargetedAnimation object
  88875. */
  88876. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88877. /**
  88878. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88879. * It can add constant keys at begin or end
  88880. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88881. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88882. * @returns the animation group
  88883. */
  88884. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88885. /**
  88886. * Start all animations on given targets
  88887. * @param loop defines if animations must loop
  88888. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88889. * @param from defines the from key (optional)
  88890. * @param to defines the to key (optional)
  88891. * @returns the current animation group
  88892. */
  88893. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88894. /**
  88895. * Pause all animations
  88896. * @returns the animation group
  88897. */
  88898. pause(): AnimationGroup;
  88899. /**
  88900. * Play all animations to initial state
  88901. * This function will start() the animations if they were not started or will restart() them if they were paused
  88902. * @param loop defines if animations must loop
  88903. * @returns the animation group
  88904. */
  88905. play(loop?: boolean): AnimationGroup;
  88906. /**
  88907. * Reset all animations to initial state
  88908. * @returns the animation group
  88909. */
  88910. reset(): AnimationGroup;
  88911. /**
  88912. * Restart animations from key 0
  88913. * @returns the animation group
  88914. */
  88915. restart(): AnimationGroup;
  88916. /**
  88917. * Stop all animations
  88918. * @returns the animation group
  88919. */
  88920. stop(): AnimationGroup;
  88921. /**
  88922. * Set animation weight for all animatables
  88923. * @param weight defines the weight to use
  88924. * @return the animationGroup
  88925. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88926. */
  88927. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88928. /**
  88929. * Synchronize and normalize all animatables with a source animatable
  88930. * @param root defines the root animatable to synchronize with
  88931. * @return the animationGroup
  88932. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88933. */
  88934. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88935. /**
  88936. * Goes to a specific frame in this animation group
  88937. * @param frame the frame number to go to
  88938. * @return the animationGroup
  88939. */
  88940. goToFrame(frame: number): AnimationGroup;
  88941. /**
  88942. * Dispose all associated resources
  88943. */
  88944. dispose(): void;
  88945. private _checkAnimationGroupEnded;
  88946. /**
  88947. * Clone the current animation group and returns a copy
  88948. * @param newName defines the name of the new group
  88949. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88950. * @returns the new aniamtion group
  88951. */
  88952. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88953. /**
  88954. * Returns a new AnimationGroup object parsed from the source provided.
  88955. * @param parsedAnimationGroup defines the source
  88956. * @param scene defines the scene that will receive the animationGroup
  88957. * @returns a new AnimationGroup
  88958. */
  88959. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88960. /**
  88961. * Returns the string "AnimationGroup"
  88962. * @returns "AnimationGroup"
  88963. */
  88964. getClassName(): string;
  88965. /**
  88966. * Creates a detailled string about the object
  88967. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88968. * @returns a string representing the object
  88969. */
  88970. toString(fullDetails?: boolean): string;
  88971. }
  88972. }
  88973. declare module BABYLON {
  88974. /**
  88975. * Define an interface for all classes that will hold resources
  88976. */
  88977. export interface IDisposable {
  88978. /**
  88979. * Releases all held resources
  88980. */
  88981. dispose(): void;
  88982. }
  88983. /** Interface defining initialization parameters for Scene class */
  88984. export interface SceneOptions {
  88985. /**
  88986. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88987. * It will improve performance when the number of geometries becomes important.
  88988. */
  88989. useGeometryUniqueIdsMap?: boolean;
  88990. /**
  88991. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88992. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88993. */
  88994. useMaterialMeshMap?: boolean;
  88995. /**
  88996. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88997. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88998. */
  88999. useClonedMeshhMap?: boolean;
  89000. }
  89001. /**
  89002. * Represents a scene to be rendered by the engine.
  89003. * @see http://doc.babylonjs.com/features/scene
  89004. */
  89005. export class Scene extends AbstractScene implements IAnimatable {
  89006. private static _uniqueIdCounter;
  89007. /** The fog is deactivated */
  89008. static readonly FOGMODE_NONE: number;
  89009. /** The fog density is following an exponential function */
  89010. static readonly FOGMODE_EXP: number;
  89011. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89012. static readonly FOGMODE_EXP2: number;
  89013. /** The fog density is following a linear function. */
  89014. static readonly FOGMODE_LINEAR: number;
  89015. /**
  89016. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89017. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89018. */
  89019. static MinDeltaTime: number;
  89020. /**
  89021. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89022. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89023. */
  89024. static MaxDeltaTime: number;
  89025. /**
  89026. * Factory used to create the default material.
  89027. * @param name The name of the material to create
  89028. * @param scene The scene to create the material for
  89029. * @returns The default material
  89030. */
  89031. static DefaultMaterialFactory(scene: Scene): Material;
  89032. /**
  89033. * Factory used to create the a collision coordinator.
  89034. * @returns The collision coordinator
  89035. */
  89036. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89037. /** @hidden */
  89038. readonly _isScene: boolean;
  89039. /**
  89040. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89041. */
  89042. autoClear: boolean;
  89043. /**
  89044. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89045. */
  89046. autoClearDepthAndStencil: boolean;
  89047. /**
  89048. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89049. */
  89050. clearColor: Color4;
  89051. /**
  89052. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89053. */
  89054. ambientColor: Color3;
  89055. /** @hidden */
  89056. _environmentBRDFTexture: BaseTexture;
  89057. /** @hidden */
  89058. protected _environmentTexture: Nullable<BaseTexture>;
  89059. /**
  89060. * Texture used in all pbr material as the reflection texture.
  89061. * As in the majority of the scene they are the same (exception for multi room and so on),
  89062. * this is easier to reference from here than from all the materials.
  89063. */
  89064. /**
  89065. * Texture used in all pbr material as the reflection texture.
  89066. * As in the majority of the scene they are the same (exception for multi room and so on),
  89067. * this is easier to set here than in all the materials.
  89068. */
  89069. environmentTexture: Nullable<BaseTexture>;
  89070. /** @hidden */
  89071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89072. /**
  89073. * Default image processing configuration used either in the rendering
  89074. * Forward main pass or through the imageProcessingPostProcess if present.
  89075. * As in the majority of the scene they are the same (exception for multi camera),
  89076. * this is easier to reference from here than from all the materials and post process.
  89077. *
  89078. * No setter as we it is a shared configuration, you can set the values instead.
  89079. */
  89080. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  89081. private _forceWireframe;
  89082. /**
  89083. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  89084. */
  89085. forceWireframe: boolean;
  89086. private _forcePointsCloud;
  89087. /**
  89088. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  89089. */
  89090. forcePointsCloud: boolean;
  89091. /**
  89092. * Gets or sets the active clipplane 1
  89093. */
  89094. clipPlane: Nullable<Plane>;
  89095. /**
  89096. * Gets or sets the active clipplane 2
  89097. */
  89098. clipPlane2: Nullable<Plane>;
  89099. /**
  89100. * Gets or sets the active clipplane 3
  89101. */
  89102. clipPlane3: Nullable<Plane>;
  89103. /**
  89104. * Gets or sets the active clipplane 4
  89105. */
  89106. clipPlane4: Nullable<Plane>;
  89107. /**
  89108. * Gets or sets a boolean indicating if animations are enabled
  89109. */
  89110. animationsEnabled: boolean;
  89111. private _animationPropertiesOverride;
  89112. /**
  89113. * Gets or sets the animation properties override
  89114. */
  89115. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89116. /**
  89117. * Gets or sets a boolean indicating if a constant deltatime has to be used
  89118. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  89119. */
  89120. useConstantAnimationDeltaTime: boolean;
  89121. /**
  89122. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  89123. * Please note that it requires to run a ray cast through the scene on every frame
  89124. */
  89125. constantlyUpdateMeshUnderPointer: boolean;
  89126. /**
  89127. * Defines the HTML cursor to use when hovering over interactive elements
  89128. */
  89129. hoverCursor: string;
  89130. /**
  89131. * Defines the HTML default cursor to use (empty by default)
  89132. */
  89133. defaultCursor: string;
  89134. /**
  89135. * This is used to call preventDefault() on pointer down
  89136. * in order to block unwanted artifacts like system double clicks
  89137. */
  89138. preventDefaultOnPointerDown: boolean;
  89139. /**
  89140. * This is used to call preventDefault() on pointer up
  89141. * in order to block unwanted artifacts like system double clicks
  89142. */
  89143. preventDefaultOnPointerUp: boolean;
  89144. /**
  89145. * Gets or sets user defined metadata
  89146. */
  89147. metadata: any;
  89148. /**
  89149. * For internal use only. Please do not use.
  89150. */
  89151. reservedDataStore: any;
  89152. /**
  89153. * Gets the name of the plugin used to load this scene (null by default)
  89154. */
  89155. loadingPluginName: string;
  89156. /**
  89157. * Use this array to add regular expressions used to disable offline support for specific urls
  89158. */
  89159. disableOfflineSupportExceptionRules: RegExp[];
  89160. /**
  89161. * An event triggered when the scene is disposed.
  89162. */
  89163. onDisposeObservable: Observable<Scene>;
  89164. private _onDisposeObserver;
  89165. /** Sets a function to be executed when this scene is disposed. */
  89166. onDispose: () => void;
  89167. /**
  89168. * An event triggered before rendering the scene (right after animations and physics)
  89169. */
  89170. onBeforeRenderObservable: Observable<Scene>;
  89171. private _onBeforeRenderObserver;
  89172. /** Sets a function to be executed before rendering this scene */
  89173. beforeRender: Nullable<() => void>;
  89174. /**
  89175. * An event triggered after rendering the scene
  89176. */
  89177. onAfterRenderObservable: Observable<Scene>;
  89178. private _onAfterRenderObserver;
  89179. /** Sets a function to be executed after rendering this scene */
  89180. afterRender: Nullable<() => void>;
  89181. /**
  89182. * An event triggered before animating the scene
  89183. */
  89184. onBeforeAnimationsObservable: Observable<Scene>;
  89185. /**
  89186. * An event triggered after animations processing
  89187. */
  89188. onAfterAnimationsObservable: Observable<Scene>;
  89189. /**
  89190. * An event triggered before draw calls are ready to be sent
  89191. */
  89192. onBeforeDrawPhaseObservable: Observable<Scene>;
  89193. /**
  89194. * An event triggered after draw calls have been sent
  89195. */
  89196. onAfterDrawPhaseObservable: Observable<Scene>;
  89197. /**
  89198. * An event triggered when the scene is ready
  89199. */
  89200. onReadyObservable: Observable<Scene>;
  89201. /**
  89202. * An event triggered before rendering a camera
  89203. */
  89204. onBeforeCameraRenderObservable: Observable<Camera>;
  89205. private _onBeforeCameraRenderObserver;
  89206. /** Sets a function to be executed before rendering a camera*/
  89207. beforeCameraRender: () => void;
  89208. /**
  89209. * An event triggered after rendering a camera
  89210. */
  89211. onAfterCameraRenderObservable: Observable<Camera>;
  89212. private _onAfterCameraRenderObserver;
  89213. /** Sets a function to be executed after rendering a camera*/
  89214. afterCameraRender: () => void;
  89215. /**
  89216. * An event triggered when active meshes evaluation is about to start
  89217. */
  89218. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  89219. /**
  89220. * An event triggered when active meshes evaluation is done
  89221. */
  89222. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  89223. /**
  89224. * An event triggered when particles rendering is about to start
  89225. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89226. */
  89227. onBeforeParticlesRenderingObservable: Observable<Scene>;
  89228. /**
  89229. * An event triggered when particles rendering is done
  89230. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89231. */
  89232. onAfterParticlesRenderingObservable: Observable<Scene>;
  89233. /**
  89234. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  89235. */
  89236. onDataLoadedObservable: Observable<Scene>;
  89237. /**
  89238. * An event triggered when a camera is created
  89239. */
  89240. onNewCameraAddedObservable: Observable<Camera>;
  89241. /**
  89242. * An event triggered when a camera is removed
  89243. */
  89244. onCameraRemovedObservable: Observable<Camera>;
  89245. /**
  89246. * An event triggered when a light is created
  89247. */
  89248. onNewLightAddedObservable: Observable<Light>;
  89249. /**
  89250. * An event triggered when a light is removed
  89251. */
  89252. onLightRemovedObservable: Observable<Light>;
  89253. /**
  89254. * An event triggered when a geometry is created
  89255. */
  89256. onNewGeometryAddedObservable: Observable<Geometry>;
  89257. /**
  89258. * An event triggered when a geometry is removed
  89259. */
  89260. onGeometryRemovedObservable: Observable<Geometry>;
  89261. /**
  89262. * An event triggered when a transform node is created
  89263. */
  89264. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  89265. /**
  89266. * An event triggered when a transform node is removed
  89267. */
  89268. onTransformNodeRemovedObservable: Observable<TransformNode>;
  89269. /**
  89270. * An event triggered when a mesh is created
  89271. */
  89272. onNewMeshAddedObservable: Observable<AbstractMesh>;
  89273. /**
  89274. * An event triggered when a mesh is removed
  89275. */
  89276. onMeshRemovedObservable: Observable<AbstractMesh>;
  89277. /**
  89278. * An event triggered when a skeleton is created
  89279. */
  89280. onNewSkeletonAddedObservable: Observable<Skeleton>;
  89281. /**
  89282. * An event triggered when a skeleton is removed
  89283. */
  89284. onSkeletonRemovedObservable: Observable<Skeleton>;
  89285. /**
  89286. * An event triggered when a material is created
  89287. */
  89288. onNewMaterialAddedObservable: Observable<Material>;
  89289. /**
  89290. * An event triggered when a material is removed
  89291. */
  89292. onMaterialRemovedObservable: Observable<Material>;
  89293. /**
  89294. * An event triggered when a texture is created
  89295. */
  89296. onNewTextureAddedObservable: Observable<BaseTexture>;
  89297. /**
  89298. * An event triggered when a texture is removed
  89299. */
  89300. onTextureRemovedObservable: Observable<BaseTexture>;
  89301. /**
  89302. * An event triggered when render targets are about to be rendered
  89303. * Can happen multiple times per frame.
  89304. */
  89305. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  89306. /**
  89307. * An event triggered when render targets were rendered.
  89308. * Can happen multiple times per frame.
  89309. */
  89310. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  89311. /**
  89312. * An event triggered before calculating deterministic simulation step
  89313. */
  89314. onBeforeStepObservable: Observable<Scene>;
  89315. /**
  89316. * An event triggered after calculating deterministic simulation step
  89317. */
  89318. onAfterStepObservable: Observable<Scene>;
  89319. /**
  89320. * An event triggered when the activeCamera property is updated
  89321. */
  89322. onActiveCameraChanged: Observable<Scene>;
  89323. /**
  89324. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  89325. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89326. * 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)
  89327. */
  89328. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89329. /**
  89330. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  89331. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89332. * 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)
  89333. */
  89334. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89335. /**
  89336. * This Observable will when a mesh has been imported into the scene.
  89337. */
  89338. onMeshImportedObservable: Observable<AbstractMesh>;
  89339. /**
  89340. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  89341. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  89342. */
  89343. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  89344. /** @hidden */
  89345. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  89346. /**
  89347. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  89348. */
  89349. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  89350. /**
  89351. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  89352. */
  89353. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  89354. /**
  89355. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89356. */
  89357. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89358. private _onPointerMove;
  89359. private _onPointerDown;
  89360. private _onPointerUp;
  89361. /** Callback called when a pointer move is detected */
  89362. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89363. /** Callback called when a pointer down is detected */
  89364. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89365. /** Callback called when a pointer up is detected */
  89366. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89367. /** Callback called when a pointer pick is detected */
  89368. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89369. /**
  89370. * 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).
  89371. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89372. */
  89373. onPrePointerObservable: Observable<PointerInfoPre>;
  89374. /**
  89375. * Observable event triggered each time an input event is received from the rendering canvas
  89376. */
  89377. onPointerObservable: Observable<PointerInfo>;
  89378. /**
  89379. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89380. */
  89381. readonly unTranslatedPointer: Vector2;
  89382. /** The distance in pixel that you have to move to prevent some events */
  89383. static DragMovementThreshold: number;
  89384. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89385. static LongPressDelay: number;
  89386. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89387. static DoubleClickDelay: number;
  89388. /** If you need to check double click without raising a single click at first click, enable this flag */
  89389. static ExclusiveDoubleClickMode: boolean;
  89390. private _initClickEvent;
  89391. private _initActionManager;
  89392. private _delayedSimpleClick;
  89393. private _delayedSimpleClickTimeout;
  89394. private _previousDelayedSimpleClickTimeout;
  89395. private _meshPickProceed;
  89396. private _previousButtonPressed;
  89397. private _currentPickResult;
  89398. private _previousPickResult;
  89399. private _totalPointersPressed;
  89400. private _doubleClickOccured;
  89401. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89402. cameraToUseForPointers: Nullable<Camera>;
  89403. private _pointerX;
  89404. private _pointerY;
  89405. private _unTranslatedPointerX;
  89406. private _unTranslatedPointerY;
  89407. private _startingPointerPosition;
  89408. private _previousStartingPointerPosition;
  89409. private _startingPointerTime;
  89410. private _previousStartingPointerTime;
  89411. private _pointerCaptures;
  89412. private _timeAccumulator;
  89413. private _currentStepId;
  89414. private _currentInternalStep;
  89415. /** @hidden */
  89416. _mirroredCameraPosition: Nullable<Vector3>;
  89417. /**
  89418. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89419. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89420. */
  89421. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89422. /**
  89423. * Observable event triggered each time an keyboard event is received from the hosting window
  89424. */
  89425. onKeyboardObservable: Observable<KeyboardInfo>;
  89426. private _onKeyDown;
  89427. private _onKeyUp;
  89428. private _onCanvasFocusObserver;
  89429. private _onCanvasBlurObserver;
  89430. private _useRightHandedSystem;
  89431. /**
  89432. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89433. */
  89434. useRightHandedSystem: boolean;
  89435. /**
  89436. * Sets the step Id used by deterministic lock step
  89437. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89438. * @param newStepId defines the step Id
  89439. */
  89440. setStepId(newStepId: number): void;
  89441. /**
  89442. * Gets the step Id used by deterministic lock step
  89443. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89444. * @returns the step Id
  89445. */
  89446. getStepId(): number;
  89447. /**
  89448. * Gets the internal step used by deterministic lock step
  89449. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89450. * @returns the internal step
  89451. */
  89452. getInternalStep(): number;
  89453. private _fogEnabled;
  89454. /**
  89455. * Gets or sets a boolean indicating if fog is enabled on this scene
  89456. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89457. * (Default is true)
  89458. */
  89459. fogEnabled: boolean;
  89460. private _fogMode;
  89461. /**
  89462. * Gets or sets the fog mode to use
  89463. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89464. * | mode | value |
  89465. * | --- | --- |
  89466. * | FOGMODE_NONE | 0 |
  89467. * | FOGMODE_EXP | 1 |
  89468. * | FOGMODE_EXP2 | 2 |
  89469. * | FOGMODE_LINEAR | 3 |
  89470. */
  89471. fogMode: number;
  89472. /**
  89473. * Gets or sets the fog color to use
  89474. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89475. * (Default is Color3(0.2, 0.2, 0.3))
  89476. */
  89477. fogColor: Color3;
  89478. /**
  89479. * Gets or sets the fog density to use
  89480. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89481. * (Default is 0.1)
  89482. */
  89483. fogDensity: number;
  89484. /**
  89485. * Gets or sets the fog start distance to use
  89486. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89487. * (Default is 0)
  89488. */
  89489. fogStart: number;
  89490. /**
  89491. * Gets or sets the fog end distance to use
  89492. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89493. * (Default is 1000)
  89494. */
  89495. fogEnd: number;
  89496. private _shadowsEnabled;
  89497. /**
  89498. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89499. */
  89500. shadowsEnabled: boolean;
  89501. private _lightsEnabled;
  89502. /**
  89503. * Gets or sets a boolean indicating if lights are enabled on this scene
  89504. */
  89505. lightsEnabled: boolean;
  89506. /** All of the active cameras added to this scene. */
  89507. activeCameras: Camera[];
  89508. private _activeCamera;
  89509. /** Gets or sets the current active camera */
  89510. activeCamera: Nullable<Camera>;
  89511. private _defaultMaterial;
  89512. /** The default material used on meshes when no material is affected */
  89513. /** The default material used on meshes when no material is affected */
  89514. defaultMaterial: Material;
  89515. private _texturesEnabled;
  89516. /**
  89517. * Gets or sets a boolean indicating if textures are enabled on this scene
  89518. */
  89519. texturesEnabled: boolean;
  89520. /**
  89521. * Gets or sets a boolean indicating if particles are enabled on this scene
  89522. */
  89523. particlesEnabled: boolean;
  89524. /**
  89525. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89526. */
  89527. spritesEnabled: boolean;
  89528. private _skeletonsEnabled;
  89529. /**
  89530. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89531. */
  89532. skeletonsEnabled: boolean;
  89533. /**
  89534. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89535. */
  89536. lensFlaresEnabled: boolean;
  89537. /**
  89538. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89540. */
  89541. collisionsEnabled: boolean;
  89542. private _collisionCoordinator;
  89543. /** @hidden */
  89544. readonly collisionCoordinator: ICollisionCoordinator;
  89545. /**
  89546. * Defines the gravity applied to this scene (used only for collisions)
  89547. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89548. */
  89549. gravity: Vector3;
  89550. /**
  89551. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89552. */
  89553. postProcessesEnabled: boolean;
  89554. /**
  89555. * The list of postprocesses added to the scene
  89556. */
  89557. postProcesses: PostProcess[];
  89558. /**
  89559. * Gets the current postprocess manager
  89560. */
  89561. postProcessManager: PostProcessManager;
  89562. /**
  89563. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89564. */
  89565. renderTargetsEnabled: boolean;
  89566. /**
  89567. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89568. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89569. */
  89570. dumpNextRenderTargets: boolean;
  89571. /**
  89572. * The list of user defined render targets added to the scene
  89573. */
  89574. customRenderTargets: RenderTargetTexture[];
  89575. /**
  89576. * Defines if texture loading must be delayed
  89577. * If true, textures will only be loaded when they need to be rendered
  89578. */
  89579. useDelayedTextureLoading: boolean;
  89580. /**
  89581. * Gets the list of meshes imported to the scene through SceneLoader
  89582. */
  89583. importedMeshesFiles: String[];
  89584. /**
  89585. * Gets or sets a boolean indicating if probes are enabled on this scene
  89586. */
  89587. probesEnabled: boolean;
  89588. /**
  89589. * Gets or sets the current offline provider to use to store scene data
  89590. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89591. */
  89592. offlineProvider: IOfflineProvider;
  89593. /**
  89594. * Gets or sets the action manager associated with the scene
  89595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89596. */
  89597. actionManager: AbstractActionManager;
  89598. private _meshesForIntersections;
  89599. /**
  89600. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89601. */
  89602. proceduralTexturesEnabled: boolean;
  89603. private _engine;
  89604. private _totalVertices;
  89605. /** @hidden */
  89606. _activeIndices: PerfCounter;
  89607. /** @hidden */
  89608. _activeParticles: PerfCounter;
  89609. /** @hidden */
  89610. _activeBones: PerfCounter;
  89611. private _animationRatio;
  89612. /** @hidden */
  89613. _animationTimeLast: number;
  89614. /** @hidden */
  89615. _animationTime: number;
  89616. /**
  89617. * Gets or sets a general scale for animation speed
  89618. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89619. */
  89620. animationTimeScale: number;
  89621. /** @hidden */
  89622. _cachedMaterial: Nullable<Material>;
  89623. /** @hidden */
  89624. _cachedEffect: Nullable<Effect>;
  89625. /** @hidden */
  89626. _cachedVisibility: Nullable<number>;
  89627. private _renderId;
  89628. private _frameId;
  89629. private _executeWhenReadyTimeoutId;
  89630. private _intermediateRendering;
  89631. private _viewUpdateFlag;
  89632. private _projectionUpdateFlag;
  89633. private _alternateViewUpdateFlag;
  89634. private _alternateProjectionUpdateFlag;
  89635. /** @hidden */
  89636. _toBeDisposed: Nullable<IDisposable>[];
  89637. private _activeRequests;
  89638. /** @hidden */
  89639. _pendingData: any[];
  89640. private _isDisposed;
  89641. /**
  89642. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89643. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89644. */
  89645. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89646. private _activeMeshes;
  89647. private _processedMaterials;
  89648. private _renderTargets;
  89649. /** @hidden */
  89650. _activeParticleSystems: SmartArray<IParticleSystem>;
  89651. private _activeSkeletons;
  89652. private _softwareSkinnedMeshes;
  89653. private _renderingManager;
  89654. /** @hidden */
  89655. _activeAnimatables: Animatable[];
  89656. private _transformMatrix;
  89657. private _sceneUbo;
  89658. private _alternateSceneUbo;
  89659. private _viewMatrix;
  89660. private _projectionMatrix;
  89661. private _alternateViewMatrix;
  89662. private _alternateProjectionMatrix;
  89663. private _alternateTransformMatrix;
  89664. private _useAlternateCameraConfiguration;
  89665. private _alternateRendering;
  89666. private _wheelEventName;
  89667. /** @hidden */
  89668. _forcedViewPosition: Nullable<Vector3>;
  89669. /** @hidden */
  89670. readonly _isAlternateRenderingEnabled: boolean;
  89671. private _frustumPlanes;
  89672. /**
  89673. * Gets the list of frustum planes (built from the active camera)
  89674. */
  89675. readonly frustumPlanes: Plane[];
  89676. /**
  89677. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89678. * This is useful if there are more lights that the maximum simulteanous authorized
  89679. */
  89680. requireLightSorting: boolean;
  89681. /** @hidden */
  89682. readonly useMaterialMeshMap: boolean;
  89683. /** @hidden */
  89684. readonly useClonedMeshhMap: boolean;
  89685. private _pointerOverMesh;
  89686. private _pickedDownMesh;
  89687. private _pickedUpMesh;
  89688. private _externalData;
  89689. private _uid;
  89690. /**
  89691. * @hidden
  89692. * Backing store of defined scene components.
  89693. */
  89694. _components: ISceneComponent[];
  89695. /**
  89696. * @hidden
  89697. * Backing store of defined scene components.
  89698. */
  89699. _serializableComponents: ISceneSerializableComponent[];
  89700. /**
  89701. * List of components to register on the next registration step.
  89702. */
  89703. private _transientComponents;
  89704. /**
  89705. * Registers the transient components if needed.
  89706. */
  89707. private _registerTransientComponents;
  89708. /**
  89709. * @hidden
  89710. * Add a component to the scene.
  89711. * Note that the ccomponent could be registered on th next frame if this is called after
  89712. * the register component stage.
  89713. * @param component Defines the component to add to the scene
  89714. */
  89715. _addComponent(component: ISceneComponent): void;
  89716. /**
  89717. * @hidden
  89718. * Gets a component from the scene.
  89719. * @param name defines the name of the component to retrieve
  89720. * @returns the component or null if not present
  89721. */
  89722. _getComponent(name: string): Nullable<ISceneComponent>;
  89723. /**
  89724. * @hidden
  89725. * Defines the actions happening before camera updates.
  89726. */
  89727. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89728. /**
  89729. * @hidden
  89730. * Defines the actions happening before clear the canvas.
  89731. */
  89732. _beforeClearStage: Stage<SimpleStageAction>;
  89733. /**
  89734. * @hidden
  89735. * Defines the actions when collecting render targets for the frame.
  89736. */
  89737. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89738. /**
  89739. * @hidden
  89740. * Defines the actions happening for one camera in the frame.
  89741. */
  89742. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89743. /**
  89744. * @hidden
  89745. * Defines the actions happening during the per mesh ready checks.
  89746. */
  89747. _isReadyForMeshStage: Stage<MeshStageAction>;
  89748. /**
  89749. * @hidden
  89750. * Defines the actions happening before evaluate active mesh checks.
  89751. */
  89752. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89753. /**
  89754. * @hidden
  89755. * Defines the actions happening during the evaluate sub mesh checks.
  89756. */
  89757. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89758. /**
  89759. * @hidden
  89760. * Defines the actions happening during the active mesh stage.
  89761. */
  89762. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89763. /**
  89764. * @hidden
  89765. * Defines the actions happening during the per camera render target step.
  89766. */
  89767. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89768. /**
  89769. * @hidden
  89770. * Defines the actions happening just before the active camera is drawing.
  89771. */
  89772. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89773. /**
  89774. * @hidden
  89775. * Defines the actions happening just before a render target is drawing.
  89776. */
  89777. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89778. /**
  89779. * @hidden
  89780. * Defines the actions happening just before a rendering group is drawing.
  89781. */
  89782. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89783. /**
  89784. * @hidden
  89785. * Defines the actions happening just before a mesh is drawing.
  89786. */
  89787. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89788. /**
  89789. * @hidden
  89790. * Defines the actions happening just after a mesh has been drawn.
  89791. */
  89792. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89793. /**
  89794. * @hidden
  89795. * Defines the actions happening just after a rendering group has been drawn.
  89796. */
  89797. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89798. /**
  89799. * @hidden
  89800. * Defines the actions happening just after the active camera has been drawn.
  89801. */
  89802. _afterCameraDrawStage: Stage<CameraStageAction>;
  89803. /**
  89804. * @hidden
  89805. * Defines the actions happening just after a render target has been drawn.
  89806. */
  89807. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89808. /**
  89809. * @hidden
  89810. * Defines the actions happening just after rendering all cameras and computing intersections.
  89811. */
  89812. _afterRenderStage: Stage<SimpleStageAction>;
  89813. /**
  89814. * @hidden
  89815. * Defines the actions happening when a pointer move event happens.
  89816. */
  89817. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89818. /**
  89819. * @hidden
  89820. * Defines the actions happening when a pointer down event happens.
  89821. */
  89822. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89823. /**
  89824. * @hidden
  89825. * Defines the actions happening when a pointer up event happens.
  89826. */
  89827. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89828. /**
  89829. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89830. */
  89831. private geometriesByUniqueId;
  89832. /**
  89833. * Creates a new Scene
  89834. * @param engine defines the engine to use to render this scene
  89835. * @param options defines the scene options
  89836. */
  89837. constructor(engine: Engine, options?: SceneOptions);
  89838. private _defaultMeshCandidates;
  89839. /**
  89840. * @hidden
  89841. */
  89842. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89843. private _defaultSubMeshCandidates;
  89844. /**
  89845. * @hidden
  89846. */
  89847. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89848. /**
  89849. * Sets the default candidate providers for the scene.
  89850. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89851. * and getCollidingSubMeshCandidates to their default function
  89852. */
  89853. setDefaultCandidateProviders(): void;
  89854. /**
  89855. * Gets the mesh that is currently under the pointer
  89856. */
  89857. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89858. /**
  89859. * Gets or sets the current on-screen X position of the pointer
  89860. */
  89861. pointerX: number;
  89862. /**
  89863. * Gets or sets the current on-screen Y position of the pointer
  89864. */
  89865. pointerY: number;
  89866. /**
  89867. * Gets the cached material (ie. the latest rendered one)
  89868. * @returns the cached material
  89869. */
  89870. getCachedMaterial(): Nullable<Material>;
  89871. /**
  89872. * Gets the cached effect (ie. the latest rendered one)
  89873. * @returns the cached effect
  89874. */
  89875. getCachedEffect(): Nullable<Effect>;
  89876. /**
  89877. * Gets the cached visibility state (ie. the latest rendered one)
  89878. * @returns the cached visibility state
  89879. */
  89880. getCachedVisibility(): Nullable<number>;
  89881. /**
  89882. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89883. * @param material defines the current material
  89884. * @param effect defines the current effect
  89885. * @param visibility defines the current visibility state
  89886. * @returns true if one parameter is not cached
  89887. */
  89888. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89889. /**
  89890. * Gets the engine associated with the scene
  89891. * @returns an Engine
  89892. */
  89893. getEngine(): Engine;
  89894. /**
  89895. * Gets the total number of vertices rendered per frame
  89896. * @returns the total number of vertices rendered per frame
  89897. */
  89898. getTotalVertices(): number;
  89899. /**
  89900. * Gets the performance counter for total vertices
  89901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89902. */
  89903. readonly totalVerticesPerfCounter: PerfCounter;
  89904. /**
  89905. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89906. * @returns the total number of active indices rendered per frame
  89907. */
  89908. getActiveIndices(): number;
  89909. /**
  89910. * Gets the performance counter for active indices
  89911. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89912. */
  89913. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89914. /**
  89915. * Gets the total number of active particles rendered per frame
  89916. * @returns the total number of active particles rendered per frame
  89917. */
  89918. getActiveParticles(): number;
  89919. /**
  89920. * Gets the performance counter for active particles
  89921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89922. */
  89923. readonly activeParticlesPerfCounter: PerfCounter;
  89924. /**
  89925. * Gets the total number of active bones rendered per frame
  89926. * @returns the total number of active bones rendered per frame
  89927. */
  89928. getActiveBones(): number;
  89929. /**
  89930. * Gets the performance counter for active bones
  89931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89932. */
  89933. readonly activeBonesPerfCounter: PerfCounter;
  89934. /**
  89935. * Gets the array of active meshes
  89936. * @returns an array of AbstractMesh
  89937. */
  89938. getActiveMeshes(): SmartArray<AbstractMesh>;
  89939. /**
  89940. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89941. * @returns a number
  89942. */
  89943. getAnimationRatio(): number;
  89944. /**
  89945. * Gets an unique Id for the current render phase
  89946. * @returns a number
  89947. */
  89948. getRenderId(): number;
  89949. /**
  89950. * Gets an unique Id for the current frame
  89951. * @returns a number
  89952. */
  89953. getFrameId(): number;
  89954. /** Call this function if you want to manually increment the render Id*/
  89955. incrementRenderId(): void;
  89956. private _updatePointerPosition;
  89957. private _createUbo;
  89958. private _createAlternateUbo;
  89959. private _setRayOnPointerInfo;
  89960. /**
  89961. * Use this method to simulate a pointer move on a mesh
  89962. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89963. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89964. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89965. * @returns the current scene
  89966. */
  89967. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89968. private _processPointerMove;
  89969. private _checkPrePointerObservable;
  89970. /**
  89971. * Use this method to simulate a pointer down on a mesh
  89972. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89973. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89974. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89975. * @returns the current scene
  89976. */
  89977. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89978. private _processPointerDown;
  89979. /**
  89980. * Use this method to simulate a pointer up on a mesh
  89981. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89982. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89983. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89984. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89985. * @returns the current scene
  89986. */
  89987. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89988. private _processPointerUp;
  89989. /**
  89990. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89991. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89992. * @returns true if the pointer was captured
  89993. */
  89994. isPointerCaptured(pointerId?: number): boolean;
  89995. /** @hidden */
  89996. _isPointerSwiping(): boolean;
  89997. /**
  89998. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89999. * @param attachUp defines if you want to attach events to pointerup
  90000. * @param attachDown defines if you want to attach events to pointerdown
  90001. * @param attachMove defines if you want to attach events to pointermove
  90002. */
  90003. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90004. /** Detaches all event handlers*/
  90005. detachControl(): void;
  90006. /**
  90007. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90008. * Delay loaded resources are not taking in account
  90009. * @return true if all required resources are ready
  90010. */
  90011. isReady(): boolean;
  90012. /** Resets all cached information relative to material (including effect and visibility) */
  90013. resetCachedMaterial(): void;
  90014. /**
  90015. * Registers a function to be called before every frame render
  90016. * @param func defines the function to register
  90017. */
  90018. registerBeforeRender(func: () => void): void;
  90019. /**
  90020. * Unregisters a function called before every frame render
  90021. * @param func defines the function to unregister
  90022. */
  90023. unregisterBeforeRender(func: () => void): void;
  90024. /**
  90025. * Registers a function to be called after every frame render
  90026. * @param func defines the function to register
  90027. */
  90028. registerAfterRender(func: () => void): void;
  90029. /**
  90030. * Unregisters a function called after every frame render
  90031. * @param func defines the function to unregister
  90032. */
  90033. unregisterAfterRender(func: () => void): void;
  90034. private _executeOnceBeforeRender;
  90035. /**
  90036. * The provided function will run before render once and will be disposed afterwards.
  90037. * A timeout delay can be provided so that the function will be executed in N ms.
  90038. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90039. * @param func The function to be executed.
  90040. * @param timeout optional delay in ms
  90041. */
  90042. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90043. /** @hidden */
  90044. _addPendingData(data: any): void;
  90045. /** @hidden */
  90046. _removePendingData(data: any): void;
  90047. /**
  90048. * Returns the number of items waiting to be loaded
  90049. * @returns the number of items waiting to be loaded
  90050. */
  90051. getWaitingItemsCount(): number;
  90052. /**
  90053. * Returns a boolean indicating if the scene is still loading data
  90054. */
  90055. readonly isLoading: boolean;
  90056. /**
  90057. * Registers a function to be executed when the scene is ready
  90058. * @param {Function} func - the function to be executed
  90059. */
  90060. executeWhenReady(func: () => void): void;
  90061. /**
  90062. * Returns a promise that resolves when the scene is ready
  90063. * @returns A promise that resolves when the scene is ready
  90064. */
  90065. whenReadyAsync(): Promise<void>;
  90066. /** @hidden */
  90067. _checkIsReady(): void;
  90068. /**
  90069. * Gets all animatable attached to the scene
  90070. */
  90071. readonly animatables: Animatable[];
  90072. /**
  90073. * Resets the last animation time frame.
  90074. * Useful to override when animations start running when loading a scene for the first time.
  90075. */
  90076. resetLastAnimationTimeFrame(): void;
  90077. /** @hidden */
  90078. _switchToAlternateCameraConfiguration(active: boolean): void;
  90079. /**
  90080. * Gets the current view matrix
  90081. * @returns a Matrix
  90082. */
  90083. getViewMatrix(): Matrix;
  90084. /**
  90085. * Gets the current projection matrix
  90086. * @returns a Matrix
  90087. */
  90088. getProjectionMatrix(): Matrix;
  90089. /**
  90090. * Gets the current transform matrix
  90091. * @returns a Matrix made of View * Projection
  90092. */
  90093. getTransformMatrix(): Matrix;
  90094. /**
  90095. * Sets the current transform matrix
  90096. * @param view defines the View matrix to use
  90097. * @param projection defines the Projection matrix to use
  90098. */
  90099. setTransformMatrix(view: Matrix, projection: Matrix): void;
  90100. /** @hidden */
  90101. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  90102. /**
  90103. * Gets the uniform buffer used to store scene data
  90104. * @returns a UniformBuffer
  90105. */
  90106. getSceneUniformBuffer(): UniformBuffer;
  90107. /**
  90108. * Gets an unique (relatively to the current scene) Id
  90109. * @returns an unique number for the scene
  90110. */
  90111. getUniqueId(): number;
  90112. /**
  90113. * Add a mesh to the list of scene's meshes
  90114. * @param newMesh defines the mesh to add
  90115. * @param recursive if all child meshes should also be added to the scene
  90116. */
  90117. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  90118. /**
  90119. * Remove a mesh for the list of scene's meshes
  90120. * @param toRemove defines the mesh to remove
  90121. * @param recursive if all child meshes should also be removed from the scene
  90122. * @returns the index where the mesh was in the mesh list
  90123. */
  90124. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  90125. /**
  90126. * Add a transform node to the list of scene's transform nodes
  90127. * @param newTransformNode defines the transform node to add
  90128. */
  90129. addTransformNode(newTransformNode: TransformNode): void;
  90130. /**
  90131. * Remove a transform node for the list of scene's transform nodes
  90132. * @param toRemove defines the transform node to remove
  90133. * @returns the index where the transform node was in the transform node list
  90134. */
  90135. removeTransformNode(toRemove: TransformNode): number;
  90136. /**
  90137. * Remove a skeleton for the list of scene's skeletons
  90138. * @param toRemove defines the skeleton to remove
  90139. * @returns the index where the skeleton was in the skeleton list
  90140. */
  90141. removeSkeleton(toRemove: Skeleton): number;
  90142. /**
  90143. * Remove a morph target for the list of scene's morph targets
  90144. * @param toRemove defines the morph target to remove
  90145. * @returns the index where the morph target was in the morph target list
  90146. */
  90147. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90148. /**
  90149. * Remove a light for the list of scene's lights
  90150. * @param toRemove defines the light to remove
  90151. * @returns the index where the light was in the light list
  90152. */
  90153. removeLight(toRemove: Light): number;
  90154. /**
  90155. * Remove a camera for the list of scene's cameras
  90156. * @param toRemove defines the camera to remove
  90157. * @returns the index where the camera was in the camera list
  90158. */
  90159. removeCamera(toRemove: Camera): number;
  90160. /**
  90161. * Remove a particle system for the list of scene's particle systems
  90162. * @param toRemove defines the particle system to remove
  90163. * @returns the index where the particle system was in the particle system list
  90164. */
  90165. removeParticleSystem(toRemove: IParticleSystem): number;
  90166. /**
  90167. * Remove a animation for the list of scene's animations
  90168. * @param toRemove defines the animation to remove
  90169. * @returns the index where the animation was in the animation list
  90170. */
  90171. removeAnimation(toRemove: Animation): number;
  90172. /**
  90173. * Removes the given animation group from this scene.
  90174. * @param toRemove The animation group to remove
  90175. * @returns The index of the removed animation group
  90176. */
  90177. removeAnimationGroup(toRemove: AnimationGroup): number;
  90178. /**
  90179. * Removes the given multi-material from this scene.
  90180. * @param toRemove The multi-material to remove
  90181. * @returns The index of the removed multi-material
  90182. */
  90183. removeMultiMaterial(toRemove: MultiMaterial): number;
  90184. /**
  90185. * Removes the given material from this scene.
  90186. * @param toRemove The material to remove
  90187. * @returns The index of the removed material
  90188. */
  90189. removeMaterial(toRemove: Material): number;
  90190. /**
  90191. * Removes the given action manager from this scene.
  90192. * @param toRemove The action manager to remove
  90193. * @returns The index of the removed action manager
  90194. */
  90195. removeActionManager(toRemove: AbstractActionManager): number;
  90196. /**
  90197. * Removes the given texture from this scene.
  90198. * @param toRemove The texture to remove
  90199. * @returns The index of the removed texture
  90200. */
  90201. removeTexture(toRemove: BaseTexture): number;
  90202. /**
  90203. * Adds the given light to this scene
  90204. * @param newLight The light to add
  90205. */
  90206. addLight(newLight: Light): void;
  90207. /**
  90208. * Sorts the list list based on light priorities
  90209. */
  90210. sortLightsByPriority(): void;
  90211. /**
  90212. * Adds the given camera to this scene
  90213. * @param newCamera The camera to add
  90214. */
  90215. addCamera(newCamera: Camera): void;
  90216. /**
  90217. * Adds the given skeleton to this scene
  90218. * @param newSkeleton The skeleton to add
  90219. */
  90220. addSkeleton(newSkeleton: Skeleton): void;
  90221. /**
  90222. * Adds the given particle system to this scene
  90223. * @param newParticleSystem The particle system to add
  90224. */
  90225. addParticleSystem(newParticleSystem: IParticleSystem): void;
  90226. /**
  90227. * Adds the given animation to this scene
  90228. * @param newAnimation The animation to add
  90229. */
  90230. addAnimation(newAnimation: Animation): void;
  90231. /**
  90232. * Adds the given animation group to this scene.
  90233. * @param newAnimationGroup The animation group to add
  90234. */
  90235. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  90236. /**
  90237. * Adds the given multi-material to this scene
  90238. * @param newMultiMaterial The multi-material to add
  90239. */
  90240. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  90241. /**
  90242. * Adds the given material to this scene
  90243. * @param newMaterial The material to add
  90244. */
  90245. addMaterial(newMaterial: Material): void;
  90246. /**
  90247. * Adds the given morph target to this scene
  90248. * @param newMorphTargetManager The morph target to add
  90249. */
  90250. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  90251. /**
  90252. * Adds the given geometry to this scene
  90253. * @param newGeometry The geometry to add
  90254. */
  90255. addGeometry(newGeometry: Geometry): void;
  90256. /**
  90257. * Adds the given action manager to this scene
  90258. * @param newActionManager The action manager to add
  90259. */
  90260. addActionManager(newActionManager: AbstractActionManager): void;
  90261. /**
  90262. * Adds the given texture to this scene.
  90263. * @param newTexture The texture to add
  90264. */
  90265. addTexture(newTexture: BaseTexture): void;
  90266. /**
  90267. * Switch active camera
  90268. * @param newCamera defines the new active camera
  90269. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  90270. */
  90271. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  90272. /**
  90273. * sets the active camera of the scene using its ID
  90274. * @param id defines the camera's ID
  90275. * @return the new active camera or null if none found.
  90276. */
  90277. setActiveCameraByID(id: string): Nullable<Camera>;
  90278. /**
  90279. * sets the active camera of the scene using its name
  90280. * @param name defines the camera's name
  90281. * @returns the new active camera or null if none found.
  90282. */
  90283. setActiveCameraByName(name: string): Nullable<Camera>;
  90284. /**
  90285. * get an animation group using its name
  90286. * @param name defines the material's name
  90287. * @return the animation group or null if none found.
  90288. */
  90289. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  90290. /**
  90291. * get a material using its id
  90292. * @param id defines the material's ID
  90293. * @return the material or null if none found.
  90294. */
  90295. getMaterialByID(id: string): Nullable<Material>;
  90296. /**
  90297. * Gets a material using its name
  90298. * @param name defines the material's name
  90299. * @return the material or null if none found.
  90300. */
  90301. getMaterialByName(name: string): Nullable<Material>;
  90302. /**
  90303. * Gets a camera using its id
  90304. * @param id defines the id to look for
  90305. * @returns the camera or null if not found
  90306. */
  90307. getCameraByID(id: string): Nullable<Camera>;
  90308. /**
  90309. * Gets a camera using its unique id
  90310. * @param uniqueId defines the unique id to look for
  90311. * @returns the camera or null if not found
  90312. */
  90313. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  90314. /**
  90315. * Gets a camera using its name
  90316. * @param name defines the camera's name
  90317. * @return the camera or null if none found.
  90318. */
  90319. getCameraByName(name: string): Nullable<Camera>;
  90320. /**
  90321. * Gets a bone using its id
  90322. * @param id defines the bone's id
  90323. * @return the bone or null if not found
  90324. */
  90325. getBoneByID(id: string): Nullable<Bone>;
  90326. /**
  90327. * Gets a bone using its id
  90328. * @param name defines the bone's name
  90329. * @return the bone or null if not found
  90330. */
  90331. getBoneByName(name: string): Nullable<Bone>;
  90332. /**
  90333. * Gets a light node using its name
  90334. * @param name defines the the light's name
  90335. * @return the light or null if none found.
  90336. */
  90337. getLightByName(name: string): Nullable<Light>;
  90338. /**
  90339. * Gets a light node using its id
  90340. * @param id defines the light's id
  90341. * @return the light or null if none found.
  90342. */
  90343. getLightByID(id: string): Nullable<Light>;
  90344. /**
  90345. * Gets a light node using its scene-generated unique ID
  90346. * @param uniqueId defines the light's unique id
  90347. * @return the light or null if none found.
  90348. */
  90349. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  90350. /**
  90351. * Gets a particle system by id
  90352. * @param id defines the particle system id
  90353. * @return the corresponding system or null if none found
  90354. */
  90355. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90356. /**
  90357. * Gets a geometry using its ID
  90358. * @param id defines the geometry's id
  90359. * @return the geometry or null if none found.
  90360. */
  90361. getGeometryByID(id: string): Nullable<Geometry>;
  90362. private _getGeometryByUniqueID;
  90363. /**
  90364. * Add a new geometry to this scene
  90365. * @param geometry defines the geometry to be added to the scene.
  90366. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90367. * @return a boolean defining if the geometry was added or not
  90368. */
  90369. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90370. /**
  90371. * Removes an existing geometry
  90372. * @param geometry defines the geometry to be removed from the scene
  90373. * @return a boolean defining if the geometry was removed or not
  90374. */
  90375. removeGeometry(geometry: Geometry): boolean;
  90376. /**
  90377. * Gets the list of geometries attached to the scene
  90378. * @returns an array of Geometry
  90379. */
  90380. getGeometries(): Geometry[];
  90381. /**
  90382. * Gets the first added mesh found of a given ID
  90383. * @param id defines the id to search for
  90384. * @return the mesh found or null if not found at all
  90385. */
  90386. getMeshByID(id: string): Nullable<AbstractMesh>;
  90387. /**
  90388. * Gets a list of meshes using their id
  90389. * @param id defines the id to search for
  90390. * @returns a list of meshes
  90391. */
  90392. getMeshesByID(id: string): Array<AbstractMesh>;
  90393. /**
  90394. * Gets the first added transform node found of a given ID
  90395. * @param id defines the id to search for
  90396. * @return the found transform node or null if not found at all.
  90397. */
  90398. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90399. /**
  90400. * Gets a list of transform nodes using their id
  90401. * @param id defines the id to search for
  90402. * @returns a list of transform nodes
  90403. */
  90404. getTransformNodesByID(id: string): Array<TransformNode>;
  90405. /**
  90406. * Gets a mesh with its auto-generated unique id
  90407. * @param uniqueId defines the unique id to search for
  90408. * @return the found mesh or null if not found at all.
  90409. */
  90410. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90411. /**
  90412. * Gets a the last added mesh using a given id
  90413. * @param id defines the id to search for
  90414. * @return the found mesh or null if not found at all.
  90415. */
  90416. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90417. /**
  90418. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90419. * @param id defines the id to search for
  90420. * @return the found node or null if not found at all
  90421. */
  90422. getLastEntryByID(id: string): Nullable<Node>;
  90423. /**
  90424. * Gets a node (Mesh, Camera, Light) using a given id
  90425. * @param id defines the id to search for
  90426. * @return the found node or null if not found at all
  90427. */
  90428. getNodeByID(id: string): Nullable<Node>;
  90429. /**
  90430. * Gets a node (Mesh, Camera, Light) using a given name
  90431. * @param name defines the name to search for
  90432. * @return the found node or null if not found at all.
  90433. */
  90434. getNodeByName(name: string): Nullable<Node>;
  90435. /**
  90436. * Gets a mesh using a given name
  90437. * @param name defines the name to search for
  90438. * @return the found mesh or null if not found at all.
  90439. */
  90440. getMeshByName(name: string): Nullable<AbstractMesh>;
  90441. /**
  90442. * Gets a transform node using a given name
  90443. * @param name defines the name to search for
  90444. * @return the found transform node or null if not found at all.
  90445. */
  90446. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90447. /**
  90448. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90449. * @param id defines the id to search for
  90450. * @return the found skeleton or null if not found at all.
  90451. */
  90452. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90453. /**
  90454. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90455. * @param id defines the id to search for
  90456. * @return the found skeleton or null if not found at all.
  90457. */
  90458. getSkeletonById(id: string): Nullable<Skeleton>;
  90459. /**
  90460. * Gets a skeleton using a given name
  90461. * @param name defines the name to search for
  90462. * @return the found skeleton or null if not found at all.
  90463. */
  90464. getSkeletonByName(name: string): Nullable<Skeleton>;
  90465. /**
  90466. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90467. * @param id defines the id to search for
  90468. * @return the found morph target manager or null if not found at all.
  90469. */
  90470. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90471. /**
  90472. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90473. * @param id defines the id to search for
  90474. * @return the found morph target or null if not found at all.
  90475. */
  90476. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90477. /**
  90478. * Gets a boolean indicating if the given mesh is active
  90479. * @param mesh defines the mesh to look for
  90480. * @returns true if the mesh is in the active list
  90481. */
  90482. isActiveMesh(mesh: AbstractMesh): boolean;
  90483. /**
  90484. * Return a unique id as a string which can serve as an identifier for the scene
  90485. */
  90486. readonly uid: string;
  90487. /**
  90488. * Add an externaly attached data from its key.
  90489. * This method call will fail and return false, if such key already exists.
  90490. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90491. * @param key the unique key that identifies the data
  90492. * @param data the data object to associate to the key for this Engine instance
  90493. * @return true if no such key were already present and the data was added successfully, false otherwise
  90494. */
  90495. addExternalData<T>(key: string, data: T): boolean;
  90496. /**
  90497. * Get an externaly attached data from its key
  90498. * @param key the unique key that identifies the data
  90499. * @return the associated data, if present (can be null), or undefined if not present
  90500. */
  90501. getExternalData<T>(key: string): Nullable<T>;
  90502. /**
  90503. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90504. * @param key the unique key that identifies the data
  90505. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90506. * @return the associated data, can be null if the factory returned null.
  90507. */
  90508. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90509. /**
  90510. * Remove an externaly attached data from the Engine instance
  90511. * @param key the unique key that identifies the data
  90512. * @return true if the data was successfully removed, false if it doesn't exist
  90513. */
  90514. removeExternalData(key: string): boolean;
  90515. private _evaluateSubMesh;
  90516. /**
  90517. * Clear the processed materials smart array preventing retention point in material dispose.
  90518. */
  90519. freeProcessedMaterials(): void;
  90520. private _preventFreeActiveMeshesAndRenderingGroups;
  90521. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90522. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90523. * when disposing several meshes in a row or a hierarchy of meshes.
  90524. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90525. */
  90526. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90527. /**
  90528. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90529. */
  90530. freeActiveMeshes(): void;
  90531. /**
  90532. * Clear the info related to rendering groups preventing retention points during dispose.
  90533. */
  90534. freeRenderingGroups(): void;
  90535. /** @hidden */
  90536. _isInIntermediateRendering(): boolean;
  90537. /**
  90538. * Lambda returning the list of potentially active meshes.
  90539. */
  90540. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90541. /**
  90542. * Lambda returning the list of potentially active sub meshes.
  90543. */
  90544. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90545. /**
  90546. * Lambda returning the list of potentially intersecting sub meshes.
  90547. */
  90548. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90549. /**
  90550. * Lambda returning the list of potentially colliding sub meshes.
  90551. */
  90552. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90553. private _activeMeshesFrozen;
  90554. /**
  90555. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90556. * @returns the current scene
  90557. */
  90558. freezeActiveMeshes(): Scene;
  90559. /**
  90560. * Use this function to restart evaluating active meshes on every frame
  90561. * @returns the current scene
  90562. */
  90563. unfreezeActiveMeshes(): Scene;
  90564. private _evaluateActiveMeshes;
  90565. private _activeMesh;
  90566. /**
  90567. * Update the transform matrix to update from the current active camera
  90568. * @param force defines a boolean used to force the update even if cache is up to date
  90569. */
  90570. updateTransformMatrix(force?: boolean): void;
  90571. /**
  90572. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  90573. * @param alternateCamera defines the camera to use
  90574. */
  90575. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90576. /** @hidden */
  90577. _allowPostProcessClearColor: boolean;
  90578. private _renderForCamera;
  90579. private _processSubCameras;
  90580. private _checkIntersections;
  90581. /** @hidden */
  90582. _advancePhysicsEngineStep(step: number): void;
  90583. /**
  90584. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90585. */
  90586. getDeterministicFrameTime: () => number;
  90587. /** @hidden */
  90588. _animate(): void;
  90589. /**
  90590. * Render the scene
  90591. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90592. */
  90593. render(updateCameras?: boolean): void;
  90594. /**
  90595. * Freeze all materials
  90596. * A frozen material will not be updatable but should be faster to render
  90597. */
  90598. freezeMaterials(): void;
  90599. /**
  90600. * Unfreeze all materials
  90601. * A frozen material will not be updatable but should be faster to render
  90602. */
  90603. unfreezeMaterials(): void;
  90604. /**
  90605. * Releases all held ressources
  90606. */
  90607. dispose(): void;
  90608. /**
  90609. * Gets if the scene is already disposed
  90610. */
  90611. readonly isDisposed: boolean;
  90612. /**
  90613. * Call this function to reduce memory footprint of the scene.
  90614. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90615. */
  90616. clearCachedVertexData(): void;
  90617. /**
  90618. * This function will remove the local cached buffer data from texture.
  90619. * It will save memory but will prevent the texture from being rebuilt
  90620. */
  90621. cleanCachedTextureBuffer(): void;
  90622. /**
  90623. * Get the world extend vectors with an optional filter
  90624. *
  90625. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90626. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90627. */
  90628. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90629. min: Vector3;
  90630. max: Vector3;
  90631. };
  90632. /**
  90633. * Creates a ray that can be used to pick in the scene
  90634. * @param x defines the x coordinate of the origin (on-screen)
  90635. * @param y defines the y coordinate of the origin (on-screen)
  90636. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90637. * @param camera defines the camera to use for the picking
  90638. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90639. * @returns a Ray
  90640. */
  90641. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90642. /**
  90643. * Creates a ray that can be used to pick in the scene
  90644. * @param x defines the x coordinate of the origin (on-screen)
  90645. * @param y defines the y coordinate of the origin (on-screen)
  90646. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90647. * @param result defines the ray where to store the picking ray
  90648. * @param camera defines the camera to use for the picking
  90649. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90650. * @returns the current scene
  90651. */
  90652. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90653. /**
  90654. * Creates a ray that can be used to pick in the scene
  90655. * @param x defines the x coordinate of the origin (on-screen)
  90656. * @param y defines the y coordinate of the origin (on-screen)
  90657. * @param camera defines the camera to use for the picking
  90658. * @returns a Ray
  90659. */
  90660. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90661. /**
  90662. * Creates a ray that can be used to pick in the scene
  90663. * @param x defines the x coordinate of the origin (on-screen)
  90664. * @param y defines the y coordinate of the origin (on-screen)
  90665. * @param result defines the ray where to store the picking ray
  90666. * @param camera defines the camera to use for the picking
  90667. * @returns the current scene
  90668. */
  90669. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90670. /** Launch a ray to try to pick a mesh in the scene
  90671. * @param x position on screen
  90672. * @param y position on screen
  90673. * @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
  90674. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90675. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90677. * @returns a PickingInfo
  90678. */
  90679. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90680. /** Use the given ray to pick a mesh in the scene
  90681. * @param ray The ray to use to pick meshes
  90682. * @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
  90683. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90684. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90685. * @returns a PickingInfo
  90686. */
  90687. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90688. /**
  90689. * Launch a ray to try to pick a mesh in the scene
  90690. * @param x X position on screen
  90691. * @param y Y position on screen
  90692. * @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
  90693. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90695. * @returns an array of PickingInfo
  90696. */
  90697. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90698. /**
  90699. * Launch a ray to try to pick a mesh in the scene
  90700. * @param ray Ray to use
  90701. * @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
  90702. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90703. * @returns an array of PickingInfo
  90704. */
  90705. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90706. /**
  90707. * Force the value of meshUnderPointer
  90708. * @param mesh defines the mesh to use
  90709. */
  90710. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90711. /**
  90712. * Gets the mesh under the pointer
  90713. * @returns a Mesh or null if no mesh is under the pointer
  90714. */
  90715. getPointerOverMesh(): Nullable<AbstractMesh>;
  90716. /** @hidden */
  90717. _rebuildGeometries(): void;
  90718. /** @hidden */
  90719. _rebuildTextures(): void;
  90720. private _getByTags;
  90721. /**
  90722. * Get a list of meshes by tags
  90723. * @param tagsQuery defines the tags query to use
  90724. * @param forEach defines a predicate used to filter results
  90725. * @returns an array of Mesh
  90726. */
  90727. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90728. /**
  90729. * Get a list of cameras by tags
  90730. * @param tagsQuery defines the tags query to use
  90731. * @param forEach defines a predicate used to filter results
  90732. * @returns an array of Camera
  90733. */
  90734. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90735. /**
  90736. * Get a list of lights by tags
  90737. * @param tagsQuery defines the tags query to use
  90738. * @param forEach defines a predicate used to filter results
  90739. * @returns an array of Light
  90740. */
  90741. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90742. /**
  90743. * Get a list of materials by tags
  90744. * @param tagsQuery defines the tags query to use
  90745. * @param forEach defines a predicate used to filter results
  90746. * @returns an array of Material
  90747. */
  90748. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90749. /**
  90750. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90751. * This allowed control for front to back rendering or reversly depending of the special needs.
  90752. *
  90753. * @param renderingGroupId The rendering group id corresponding to its index
  90754. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90755. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90756. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90757. */
  90758. 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;
  90759. /**
  90760. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90761. *
  90762. * @param renderingGroupId The rendering group id corresponding to its index
  90763. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90764. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90765. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90766. */
  90767. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90768. /**
  90769. * Gets the current auto clear configuration for one rendering group of the rendering
  90770. * manager.
  90771. * @param index the rendering group index to get the information for
  90772. * @returns The auto clear setup for the requested rendering group
  90773. */
  90774. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90775. private _blockMaterialDirtyMechanism;
  90776. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90777. blockMaterialDirtyMechanism: boolean;
  90778. /**
  90779. * Will flag all materials as dirty to trigger new shader compilation
  90780. * @param flag defines the flag used to specify which material part must be marked as dirty
  90781. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90782. */
  90783. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90784. /** @hidden */
  90785. _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;
  90786. /** @hidden */
  90787. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90788. }
  90789. }
  90790. declare module BABYLON {
  90791. /**
  90792. * Set of assets to keep when moving a scene into an asset container.
  90793. */
  90794. export class KeepAssets extends AbstractScene {
  90795. }
  90796. /**
  90797. * Container with a set of assets that can be added or removed from a scene.
  90798. */
  90799. export class AssetContainer extends AbstractScene {
  90800. /**
  90801. * The scene the AssetContainer belongs to.
  90802. */
  90803. scene: Scene;
  90804. /**
  90805. * Instantiates an AssetContainer.
  90806. * @param scene The scene the AssetContainer belongs to.
  90807. */
  90808. constructor(scene: Scene);
  90809. /**
  90810. * Adds all the assets from the container to the scene.
  90811. */
  90812. addAllToScene(): void;
  90813. /**
  90814. * Removes all the assets in the container from the scene
  90815. */
  90816. removeAllFromScene(): void;
  90817. /**
  90818. * Disposes all the assets in the container
  90819. */
  90820. dispose(): void;
  90821. private _moveAssets;
  90822. /**
  90823. * Removes all the assets contained in the scene and adds them to the container.
  90824. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90825. */
  90826. moveAllFromScene(keepAssets?: KeepAssets): void;
  90827. /**
  90828. * 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.
  90829. * @returns the root mesh
  90830. */
  90831. createRootMesh(): Mesh;
  90832. }
  90833. }
  90834. declare module BABYLON {
  90835. /**
  90836. * Defines how the parser contract is defined.
  90837. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90838. */
  90839. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90840. /**
  90841. * Defines how the individual parser contract is defined.
  90842. * These parser can parse an individual asset
  90843. */
  90844. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90845. /**
  90846. * Base class of the scene acting as a container for the different elements composing a scene.
  90847. * This class is dynamically extended by the different components of the scene increasing
  90848. * flexibility and reducing coupling
  90849. */
  90850. export abstract class AbstractScene {
  90851. /**
  90852. * Stores the list of available parsers in the application.
  90853. */
  90854. private static _BabylonFileParsers;
  90855. /**
  90856. * Stores the list of available individual parsers in the application.
  90857. */
  90858. private static _IndividualBabylonFileParsers;
  90859. /**
  90860. * Adds a parser in the list of available ones
  90861. * @param name Defines the name of the parser
  90862. * @param parser Defines the parser to add
  90863. */
  90864. static AddParser(name: string, parser: BabylonFileParser): void;
  90865. /**
  90866. * Gets a general parser from the list of avaialble ones
  90867. * @param name Defines the name of the parser
  90868. * @returns the requested parser or null
  90869. */
  90870. static GetParser(name: string): Nullable<BabylonFileParser>;
  90871. /**
  90872. * Adds n individual parser in the list of available ones
  90873. * @param name Defines the name of the parser
  90874. * @param parser Defines the parser to add
  90875. */
  90876. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90877. /**
  90878. * Gets an individual parser from the list of avaialble ones
  90879. * @param name Defines the name of the parser
  90880. * @returns the requested parser or null
  90881. */
  90882. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90883. /**
  90884. * Parser json data and populate both a scene and its associated container object
  90885. * @param jsonData Defines the data to parse
  90886. * @param scene Defines the scene to parse the data for
  90887. * @param container Defines the container attached to the parsing sequence
  90888. * @param rootUrl Defines the root url of the data
  90889. */
  90890. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90891. /**
  90892. * Gets the list of root nodes (ie. nodes with no parent)
  90893. */
  90894. rootNodes: Node[];
  90895. /** All of the cameras added to this scene
  90896. * @see http://doc.babylonjs.com/babylon101/cameras
  90897. */
  90898. cameras: Camera[];
  90899. /**
  90900. * All of the lights added to this scene
  90901. * @see http://doc.babylonjs.com/babylon101/lights
  90902. */
  90903. lights: Light[];
  90904. /**
  90905. * All of the (abstract) meshes added to this scene
  90906. */
  90907. meshes: AbstractMesh[];
  90908. /**
  90909. * The list of skeletons added to the scene
  90910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90911. */
  90912. skeletons: Skeleton[];
  90913. /**
  90914. * All of the particle systems added to this scene
  90915. * @see http://doc.babylonjs.com/babylon101/particles
  90916. */
  90917. particleSystems: IParticleSystem[];
  90918. /**
  90919. * Gets a list of Animations associated with the scene
  90920. */
  90921. animations: Animation[];
  90922. /**
  90923. * All of the animation groups added to this scene
  90924. * @see http://doc.babylonjs.com/how_to/group
  90925. */
  90926. animationGroups: AnimationGroup[];
  90927. /**
  90928. * All of the multi-materials added to this scene
  90929. * @see http://doc.babylonjs.com/how_to/multi_materials
  90930. */
  90931. multiMaterials: MultiMaterial[];
  90932. /**
  90933. * All of the materials added to this scene
  90934. * In the context of a Scene, it is not supposed to be modified manually.
  90935. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90936. * Note also that the order of the Material wihin the array is not significant and might change.
  90937. * @see http://doc.babylonjs.com/babylon101/materials
  90938. */
  90939. materials: Material[];
  90940. /**
  90941. * The list of morph target managers added to the scene
  90942. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90943. */
  90944. morphTargetManagers: MorphTargetManager[];
  90945. /**
  90946. * The list of geometries used in the scene.
  90947. */
  90948. geometries: Geometry[];
  90949. /**
  90950. * All of the tranform nodes added to this scene
  90951. * In the context of a Scene, it is not supposed to be modified manually.
  90952. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90953. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90954. * @see http://doc.babylonjs.com/how_to/transformnode
  90955. */
  90956. transformNodes: TransformNode[];
  90957. /**
  90958. * ActionManagers available on the scene.
  90959. */
  90960. actionManagers: AbstractActionManager[];
  90961. /**
  90962. * Textures to keep.
  90963. */
  90964. textures: BaseTexture[];
  90965. }
  90966. }
  90967. declare module BABYLON {
  90968. /**
  90969. * Defines a sound that can be played in the application.
  90970. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90972. */
  90973. export class Sound {
  90974. /**
  90975. * The name of the sound in the scene.
  90976. */
  90977. name: string;
  90978. /**
  90979. * Does the sound autoplay once loaded.
  90980. */
  90981. autoplay: boolean;
  90982. /**
  90983. * Does the sound loop after it finishes playing once.
  90984. */
  90985. loop: boolean;
  90986. /**
  90987. * Does the sound use a custom attenuation curve to simulate the falloff
  90988. * happening when the source gets further away from the camera.
  90989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90990. */
  90991. useCustomAttenuation: boolean;
  90992. /**
  90993. * The sound track id this sound belongs to.
  90994. */
  90995. soundTrackId: number;
  90996. /**
  90997. * Is this sound currently played.
  90998. */
  90999. isPlaying: boolean;
  91000. /**
  91001. * Is this sound currently paused.
  91002. */
  91003. isPaused: boolean;
  91004. /**
  91005. * Does this sound enables spatial sound.
  91006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91007. */
  91008. spatialSound: boolean;
  91009. /**
  91010. * Define the reference distance the sound should be heard perfectly.
  91011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91012. */
  91013. refDistance: number;
  91014. /**
  91015. * Define the roll off factor of spatial sounds.
  91016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91017. */
  91018. rolloffFactor: number;
  91019. /**
  91020. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91022. */
  91023. maxDistance: number;
  91024. /**
  91025. * Define the distance attenuation model the sound will follow.
  91026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91027. */
  91028. distanceModel: string;
  91029. /**
  91030. * @hidden
  91031. * Back Compat
  91032. **/
  91033. onended: () => any;
  91034. /**
  91035. * Observable event when the current playing sound finishes.
  91036. */
  91037. onEndedObservable: Observable<Sound>;
  91038. private _panningModel;
  91039. private _playbackRate;
  91040. private _streaming;
  91041. private _startTime;
  91042. private _startOffset;
  91043. private _position;
  91044. /** @hidden */
  91045. _positionInEmitterSpace: boolean;
  91046. private _localDirection;
  91047. private _volume;
  91048. private _isReadyToPlay;
  91049. private _isDirectional;
  91050. private _readyToPlayCallback;
  91051. private _audioBuffer;
  91052. private _soundSource;
  91053. private _streamingSource;
  91054. private _soundPanner;
  91055. private _soundGain;
  91056. private _inputAudioNode;
  91057. private _outputAudioNode;
  91058. private _coneInnerAngle;
  91059. private _coneOuterAngle;
  91060. private _coneOuterGain;
  91061. private _scene;
  91062. private _connectedTransformNode;
  91063. private _customAttenuationFunction;
  91064. private _registerFunc;
  91065. private _isOutputConnected;
  91066. private _htmlAudioElement;
  91067. private _urlType;
  91068. /** @hidden */
  91069. static _SceneComponentInitialization: (scene: Scene) => void;
  91070. /**
  91071. * Create a sound and attach it to a scene
  91072. * @param name Name of your sound
  91073. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  91074. * @param scene defines the scene the sound belongs to
  91075. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  91076. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  91077. */
  91078. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  91079. /**
  91080. * Release the sound and its associated resources
  91081. */
  91082. dispose(): void;
  91083. /**
  91084. * Gets if the sounds is ready to be played or not.
  91085. * @returns true if ready, otherwise false
  91086. */
  91087. isReady(): boolean;
  91088. private _soundLoaded;
  91089. /**
  91090. * Sets the data of the sound from an audiobuffer
  91091. * @param audioBuffer The audioBuffer containing the data
  91092. */
  91093. setAudioBuffer(audioBuffer: AudioBuffer): void;
  91094. /**
  91095. * Updates the current sounds options such as maxdistance, loop...
  91096. * @param options A JSON object containing values named as the object properties
  91097. */
  91098. updateOptions(options: any): void;
  91099. private _createSpatialParameters;
  91100. private _updateSpatialParameters;
  91101. /**
  91102. * Switch the panning model to HRTF:
  91103. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91105. */
  91106. switchPanningModelToHRTF(): void;
  91107. /**
  91108. * Switch the panning model to Equal Power:
  91109. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91111. */
  91112. switchPanningModelToEqualPower(): void;
  91113. private _switchPanningModel;
  91114. /**
  91115. * Connect this sound to a sound track audio node like gain...
  91116. * @param soundTrackAudioNode the sound track audio node to connect to
  91117. */
  91118. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  91119. /**
  91120. * Transform this sound into a directional source
  91121. * @param coneInnerAngle Size of the inner cone in degree
  91122. * @param coneOuterAngle Size of the outer cone in degree
  91123. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  91124. */
  91125. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  91126. /**
  91127. * Gets or sets the inner angle for the directional cone.
  91128. */
  91129. /**
  91130. * Gets or sets the inner angle for the directional cone.
  91131. */
  91132. directionalConeInnerAngle: number;
  91133. /**
  91134. * Gets or sets the outer angle for the directional cone.
  91135. */
  91136. /**
  91137. * Gets or sets the outer angle for the directional cone.
  91138. */
  91139. directionalConeOuterAngle: number;
  91140. /**
  91141. * Sets the position of the emitter if spatial sound is enabled
  91142. * @param newPosition Defines the new posisiton
  91143. */
  91144. setPosition(newPosition: Vector3): void;
  91145. /**
  91146. * Sets the local direction of the emitter if spatial sound is enabled
  91147. * @param newLocalDirection Defines the new local direction
  91148. */
  91149. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91150. private _updateDirection;
  91151. /** @hidden */
  91152. updateDistanceFromListener(): void;
  91153. /**
  91154. * Sets a new custom attenuation function for the sound.
  91155. * @param callback Defines the function used for the attenuation
  91156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91157. */
  91158. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91159. /**
  91160. * Play the sound
  91161. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91162. * @param offset (optional) Start the sound setting it at a specific time
  91163. */
  91164. play(time?: number, offset?: number): void;
  91165. private _onended;
  91166. /**
  91167. * Stop the sound
  91168. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91169. */
  91170. stop(time?: number): void;
  91171. /**
  91172. * Put the sound in pause
  91173. */
  91174. pause(): void;
  91175. /**
  91176. * Sets a dedicated volume for this sounds
  91177. * @param newVolume Define the new volume of the sound
  91178. * @param time Define in how long the sound should be at this value
  91179. */
  91180. setVolume(newVolume: number, time?: number): void;
  91181. /**
  91182. * Set the sound play back rate
  91183. * @param newPlaybackRate Define the playback rate the sound should be played at
  91184. */
  91185. setPlaybackRate(newPlaybackRate: number): void;
  91186. /**
  91187. * Gets the volume of the sound.
  91188. * @returns the volume of the sound
  91189. */
  91190. getVolume(): number;
  91191. /**
  91192. * Attach the sound to a dedicated mesh
  91193. * @param transformNode The transform node to connect the sound with
  91194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91195. */
  91196. attachToMesh(transformNode: TransformNode): void;
  91197. /**
  91198. * Detach the sound from the previously attached mesh
  91199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91200. */
  91201. detachFromMesh(): void;
  91202. private _onRegisterAfterWorldMatrixUpdate;
  91203. /**
  91204. * Clone the current sound in the scene.
  91205. * @returns the new sound clone
  91206. */
  91207. clone(): Nullable<Sound>;
  91208. /**
  91209. * Gets the current underlying audio buffer containing the data
  91210. * @returns the audio buffer
  91211. */
  91212. getAudioBuffer(): Nullable<AudioBuffer>;
  91213. /**
  91214. * Serializes the Sound in a JSON representation
  91215. * @returns the JSON representation of the sound
  91216. */
  91217. serialize(): any;
  91218. /**
  91219. * Parse a JSON representation of a sound to innstantiate in a given scene
  91220. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  91221. * @param scene Define the scene the new parsed sound should be created in
  91222. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  91223. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  91224. * @returns the newly parsed sound
  91225. */
  91226. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  91227. }
  91228. }
  91229. declare module BABYLON {
  91230. /**
  91231. * This defines an action helpful to play a defined sound on a triggered action.
  91232. */
  91233. export class PlaySoundAction extends Action {
  91234. private _sound;
  91235. /**
  91236. * Instantiate the action
  91237. * @param triggerOptions defines the trigger options
  91238. * @param sound defines the sound to play
  91239. * @param condition defines the trigger related conditions
  91240. */
  91241. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91242. /** @hidden */
  91243. _prepare(): void;
  91244. /**
  91245. * Execute the action and play the sound.
  91246. */
  91247. execute(): void;
  91248. /**
  91249. * Serializes the actions and its related information.
  91250. * @param parent defines the object to serialize in
  91251. * @returns the serialized object
  91252. */
  91253. serialize(parent: any): any;
  91254. }
  91255. /**
  91256. * This defines an action helpful to stop a defined sound on a triggered action.
  91257. */
  91258. export class StopSoundAction extends Action {
  91259. private _sound;
  91260. /**
  91261. * Instantiate the action
  91262. * @param triggerOptions defines the trigger options
  91263. * @param sound defines the sound to stop
  91264. * @param condition defines the trigger related conditions
  91265. */
  91266. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91267. /** @hidden */
  91268. _prepare(): void;
  91269. /**
  91270. * Execute the action and stop the sound.
  91271. */
  91272. execute(): void;
  91273. /**
  91274. * Serializes the actions and its related information.
  91275. * @param parent defines the object to serialize in
  91276. * @returns the serialized object
  91277. */
  91278. serialize(parent: any): any;
  91279. }
  91280. }
  91281. declare module BABYLON {
  91282. /**
  91283. * This defines an action responsible to change the value of a property
  91284. * by interpolating between its current value and the newly set one once triggered.
  91285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91286. */
  91287. export class InterpolateValueAction extends Action {
  91288. /**
  91289. * Defines the path of the property where the value should be interpolated
  91290. */
  91291. propertyPath: string;
  91292. /**
  91293. * Defines the target value at the end of the interpolation.
  91294. */
  91295. value: any;
  91296. /**
  91297. * Defines the time it will take for the property to interpolate to the value.
  91298. */
  91299. duration: number;
  91300. /**
  91301. * Defines if the other scene animations should be stopped when the action has been triggered
  91302. */
  91303. stopOtherAnimations?: boolean;
  91304. /**
  91305. * Defines a callback raised once the interpolation animation has been done.
  91306. */
  91307. onInterpolationDone?: () => void;
  91308. /**
  91309. * Observable triggered once the interpolation animation has been done.
  91310. */
  91311. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  91312. private _target;
  91313. private _effectiveTarget;
  91314. private _property;
  91315. /**
  91316. * Instantiate the action
  91317. * @param triggerOptions defines the trigger options
  91318. * @param target defines the object containing the value to interpolate
  91319. * @param propertyPath defines the path to the property in the target object
  91320. * @param value defines the target value at the end of the interpolation
  91321. * @param duration deines the time it will take for the property to interpolate to the value.
  91322. * @param condition defines the trigger related conditions
  91323. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  91324. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  91325. */
  91326. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  91327. /** @hidden */
  91328. _prepare(): void;
  91329. /**
  91330. * Execute the action starts the value interpolation.
  91331. */
  91332. execute(): void;
  91333. /**
  91334. * Serializes the actions and its related information.
  91335. * @param parent defines the object to serialize in
  91336. * @returns the serialized object
  91337. */
  91338. serialize(parent: any): any;
  91339. }
  91340. }
  91341. declare module BABYLON {
  91342. /**
  91343. * Options allowed during the creation of a sound track.
  91344. */
  91345. export interface ISoundTrackOptions {
  91346. /**
  91347. * The volume the sound track should take during creation
  91348. */
  91349. volume?: number;
  91350. /**
  91351. * Define if the sound track is the main sound track of the scene
  91352. */
  91353. mainTrack?: boolean;
  91354. }
  91355. /**
  91356. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91357. * It will be also used in a future release to apply effects on a specific track.
  91358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91359. */
  91360. export class SoundTrack {
  91361. /**
  91362. * The unique identifier of the sound track in the scene.
  91363. */
  91364. id: number;
  91365. /**
  91366. * The list of sounds included in the sound track.
  91367. */
  91368. soundCollection: Array<Sound>;
  91369. private _outputAudioNode;
  91370. private _scene;
  91371. private _isMainTrack;
  91372. private _connectedAnalyser;
  91373. private _options;
  91374. private _isInitialized;
  91375. /**
  91376. * Creates a new sound track.
  91377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91378. * @param scene Define the scene the sound track belongs to
  91379. * @param options
  91380. */
  91381. constructor(scene: Scene, options?: ISoundTrackOptions);
  91382. private _initializeSoundTrackAudioGraph;
  91383. /**
  91384. * Release the sound track and its associated resources
  91385. */
  91386. dispose(): void;
  91387. /**
  91388. * Adds a sound to this sound track
  91389. * @param sound define the cound to add
  91390. * @ignoreNaming
  91391. */
  91392. AddSound(sound: Sound): void;
  91393. /**
  91394. * Removes a sound to this sound track
  91395. * @param sound define the cound to remove
  91396. * @ignoreNaming
  91397. */
  91398. RemoveSound(sound: Sound): void;
  91399. /**
  91400. * Set a global volume for the full sound track.
  91401. * @param newVolume Define the new volume of the sound track
  91402. */
  91403. setVolume(newVolume: number): void;
  91404. /**
  91405. * Switch the panning model to HRTF:
  91406. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91408. */
  91409. switchPanningModelToHRTF(): void;
  91410. /**
  91411. * Switch the panning model to Equal Power:
  91412. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91414. */
  91415. switchPanningModelToEqualPower(): void;
  91416. /**
  91417. * Connect the sound track to an audio analyser allowing some amazing
  91418. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91420. * @param analyser The analyser to connect to the engine
  91421. */
  91422. connectToAnalyser(analyser: Analyser): void;
  91423. }
  91424. }
  91425. declare module BABYLON {
  91426. interface AbstractScene {
  91427. /**
  91428. * The list of sounds used in the scene.
  91429. */
  91430. sounds: Nullable<Array<Sound>>;
  91431. }
  91432. interface Scene {
  91433. /**
  91434. * @hidden
  91435. * Backing field
  91436. */
  91437. _mainSoundTrack: SoundTrack;
  91438. /**
  91439. * The main sound track played by the scene.
  91440. * It cotains your primary collection of sounds.
  91441. */
  91442. mainSoundTrack: SoundTrack;
  91443. /**
  91444. * The list of sound tracks added to the scene
  91445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91446. */
  91447. soundTracks: Nullable<Array<SoundTrack>>;
  91448. /**
  91449. * Gets a sound using a given name
  91450. * @param name defines the name to search for
  91451. * @return the found sound or null if not found at all.
  91452. */
  91453. getSoundByName(name: string): Nullable<Sound>;
  91454. /**
  91455. * Gets or sets if audio support is enabled
  91456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91457. */
  91458. audioEnabled: boolean;
  91459. /**
  91460. * Gets or sets if audio will be output to headphones
  91461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91462. */
  91463. headphone: boolean;
  91464. }
  91465. /**
  91466. * Defines the sound scene component responsible to manage any sounds
  91467. * in a given scene.
  91468. */
  91469. export class AudioSceneComponent implements ISceneSerializableComponent {
  91470. /**
  91471. * The component name helpfull to identify the component in the list of scene components.
  91472. */
  91473. readonly name: string;
  91474. /**
  91475. * The scene the component belongs to.
  91476. */
  91477. scene: Scene;
  91478. private _audioEnabled;
  91479. /**
  91480. * Gets whether audio is enabled or not.
  91481. * Please use related enable/disable method to switch state.
  91482. */
  91483. readonly audioEnabled: boolean;
  91484. private _headphone;
  91485. /**
  91486. * Gets whether audio is outputing to headphone or not.
  91487. * Please use the according Switch methods to change output.
  91488. */
  91489. readonly headphone: boolean;
  91490. /**
  91491. * Creates a new instance of the component for the given scene
  91492. * @param scene Defines the scene to register the component in
  91493. */
  91494. constructor(scene: Scene);
  91495. /**
  91496. * Registers the component in a given scene
  91497. */
  91498. register(): void;
  91499. /**
  91500. * Rebuilds the elements related to this component in case of
  91501. * context lost for instance.
  91502. */
  91503. rebuild(): void;
  91504. /**
  91505. * Serializes the component data to the specified json object
  91506. * @param serializationObject The object to serialize to
  91507. */
  91508. serialize(serializationObject: any): void;
  91509. /**
  91510. * Adds all the element from the container to the scene
  91511. * @param container the container holding the elements
  91512. */
  91513. addFromContainer(container: AbstractScene): void;
  91514. /**
  91515. * Removes all the elements in the container from the scene
  91516. * @param container contains the elements to remove
  91517. */
  91518. removeFromContainer(container: AbstractScene): void;
  91519. /**
  91520. * Disposes the component and the associated ressources.
  91521. */
  91522. dispose(): void;
  91523. /**
  91524. * Disables audio in the associated scene.
  91525. */
  91526. disableAudio(): void;
  91527. /**
  91528. * Enables audio in the associated scene.
  91529. */
  91530. enableAudio(): void;
  91531. /**
  91532. * Switch audio to headphone output.
  91533. */
  91534. switchAudioModeForHeadphones(): void;
  91535. /**
  91536. * Switch audio to normal speakers.
  91537. */
  91538. switchAudioModeForNormalSpeakers(): void;
  91539. private _afterRender;
  91540. }
  91541. }
  91542. declare module BABYLON {
  91543. /**
  91544. * Wraps one or more Sound objects and selects one with random weight for playback.
  91545. */
  91546. export class WeightedSound {
  91547. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91548. loop: boolean;
  91549. private _coneInnerAngle;
  91550. private _coneOuterAngle;
  91551. private _volume;
  91552. /** A Sound is currently playing. */
  91553. isPlaying: boolean;
  91554. /** A Sound is currently paused. */
  91555. isPaused: boolean;
  91556. private _sounds;
  91557. private _weights;
  91558. private _currentIndex?;
  91559. /**
  91560. * Creates a new WeightedSound from the list of sounds given.
  91561. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91562. * @param sounds Array of Sounds that will be selected from.
  91563. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91564. */
  91565. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91566. /**
  91567. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91568. */
  91569. /**
  91570. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91571. */
  91572. directionalConeInnerAngle: number;
  91573. /**
  91574. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91575. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91576. */
  91577. /**
  91578. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91579. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91580. */
  91581. directionalConeOuterAngle: number;
  91582. /**
  91583. * Playback volume.
  91584. */
  91585. /**
  91586. * Playback volume.
  91587. */
  91588. volume: number;
  91589. private _onended;
  91590. /**
  91591. * Suspend playback
  91592. */
  91593. pause(): void;
  91594. /**
  91595. * Stop playback
  91596. */
  91597. stop(): void;
  91598. /**
  91599. * Start playback.
  91600. * @param startOffset Position the clip head at a specific time in seconds.
  91601. */
  91602. play(startOffset?: number): void;
  91603. }
  91604. }
  91605. declare module BABYLON {
  91606. /**
  91607. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91608. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91609. */
  91610. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91611. /**
  91612. * Gets the name of the behavior.
  91613. */
  91614. readonly name: string;
  91615. /**
  91616. * The easing function used by animations
  91617. */
  91618. static EasingFunction: BackEase;
  91619. /**
  91620. * The easing mode used by animations
  91621. */
  91622. static EasingMode: number;
  91623. /**
  91624. * The duration of the animation, in milliseconds
  91625. */
  91626. transitionDuration: number;
  91627. /**
  91628. * Length of the distance animated by the transition when lower radius is reached
  91629. */
  91630. lowerRadiusTransitionRange: number;
  91631. /**
  91632. * Length of the distance animated by the transition when upper radius is reached
  91633. */
  91634. upperRadiusTransitionRange: number;
  91635. private _autoTransitionRange;
  91636. /**
  91637. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91638. */
  91639. /**
  91640. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91641. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91642. */
  91643. autoTransitionRange: boolean;
  91644. private _attachedCamera;
  91645. private _onAfterCheckInputsObserver;
  91646. private _onMeshTargetChangedObserver;
  91647. /**
  91648. * Initializes the behavior.
  91649. */
  91650. init(): void;
  91651. /**
  91652. * Attaches the behavior to its arc rotate camera.
  91653. * @param camera Defines the camera to attach the behavior to
  91654. */
  91655. attach(camera: ArcRotateCamera): void;
  91656. /**
  91657. * Detaches the behavior from its current arc rotate camera.
  91658. */
  91659. detach(): void;
  91660. private _radiusIsAnimating;
  91661. private _radiusBounceTransition;
  91662. private _animatables;
  91663. private _cachedWheelPrecision;
  91664. /**
  91665. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91666. * @param radiusLimit The limit to check against.
  91667. * @return Bool to indicate if at limit.
  91668. */
  91669. private _isRadiusAtLimit;
  91670. /**
  91671. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91672. * @param radiusDelta The delta by which to animate to. Can be negative.
  91673. */
  91674. private _applyBoundRadiusAnimation;
  91675. /**
  91676. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91677. */
  91678. protected _clearAnimationLocks(): void;
  91679. /**
  91680. * Stops and removes all animations that have been applied to the camera
  91681. */
  91682. stopAllAnimations(): void;
  91683. }
  91684. }
  91685. declare module BABYLON {
  91686. /**
  91687. * 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.
  91688. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91689. */
  91690. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91691. /**
  91692. * Gets the name of the behavior.
  91693. */
  91694. readonly name: string;
  91695. private _mode;
  91696. private _radiusScale;
  91697. private _positionScale;
  91698. private _defaultElevation;
  91699. private _elevationReturnTime;
  91700. private _elevationReturnWaitTime;
  91701. private _zoomStopsAnimation;
  91702. private _framingTime;
  91703. /**
  91704. * The easing function used by animations
  91705. */
  91706. static EasingFunction: ExponentialEase;
  91707. /**
  91708. * The easing mode used by animations
  91709. */
  91710. static EasingMode: number;
  91711. /**
  91712. * Sets the current mode used by the behavior
  91713. */
  91714. /**
  91715. * Gets current mode used by the behavior.
  91716. */
  91717. mode: number;
  91718. /**
  91719. * Sets the scale applied to the radius (1 by default)
  91720. */
  91721. /**
  91722. * Gets the scale applied to the radius
  91723. */
  91724. radiusScale: number;
  91725. /**
  91726. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91727. */
  91728. /**
  91729. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91730. */
  91731. positionScale: number;
  91732. /**
  91733. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91734. * behaviour is triggered, in radians.
  91735. */
  91736. /**
  91737. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91738. * behaviour is triggered, in radians.
  91739. */
  91740. defaultElevation: number;
  91741. /**
  91742. * Sets the time (in milliseconds) taken to return to the default beta position.
  91743. * Negative value indicates camera should not return to default.
  91744. */
  91745. /**
  91746. * Gets the time (in milliseconds) taken to return to the default beta position.
  91747. * Negative value indicates camera should not return to default.
  91748. */
  91749. elevationReturnTime: number;
  91750. /**
  91751. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91752. */
  91753. /**
  91754. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91755. */
  91756. elevationReturnWaitTime: number;
  91757. /**
  91758. * Sets the flag that indicates if user zooming should stop animation.
  91759. */
  91760. /**
  91761. * Gets the flag that indicates if user zooming should stop animation.
  91762. */
  91763. zoomStopsAnimation: boolean;
  91764. /**
  91765. * Sets the transition time when framing the mesh, in milliseconds
  91766. */
  91767. /**
  91768. * Gets the transition time when framing the mesh, in milliseconds
  91769. */
  91770. framingTime: number;
  91771. /**
  91772. * Define if the behavior should automatically change the configured
  91773. * camera limits and sensibilities.
  91774. */
  91775. autoCorrectCameraLimitsAndSensibility: boolean;
  91776. private _onPrePointerObservableObserver;
  91777. private _onAfterCheckInputsObserver;
  91778. private _onMeshTargetChangedObserver;
  91779. private _attachedCamera;
  91780. private _isPointerDown;
  91781. private _lastInteractionTime;
  91782. /**
  91783. * Initializes the behavior.
  91784. */
  91785. init(): void;
  91786. /**
  91787. * Attaches the behavior to its arc rotate camera.
  91788. * @param camera Defines the camera to attach the behavior to
  91789. */
  91790. attach(camera: ArcRotateCamera): void;
  91791. /**
  91792. * Detaches the behavior from its current arc rotate camera.
  91793. */
  91794. detach(): void;
  91795. private _animatables;
  91796. private _betaIsAnimating;
  91797. private _betaTransition;
  91798. private _radiusTransition;
  91799. private _vectorTransition;
  91800. /**
  91801. * Targets the given mesh and updates zoom level accordingly.
  91802. * @param mesh The mesh to target.
  91803. * @param radius Optional. If a cached radius position already exists, overrides default.
  91804. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91807. */
  91808. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91809. /**
  91810. * Targets the given mesh with its children and updates zoom level accordingly.
  91811. * @param mesh The mesh to target.
  91812. * @param radius Optional. If a cached radius position already exists, overrides default.
  91813. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91816. */
  91817. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91818. /**
  91819. * Targets the given meshes with their children and updates zoom level accordingly.
  91820. * @param meshes The mesh to target.
  91821. * @param radius Optional. If a cached radius position already exists, overrides default.
  91822. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91823. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91824. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91825. */
  91826. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91827. /**
  91828. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91829. * @param minimumWorld Determines the smaller position of the bounding box extend
  91830. * @param maximumWorld Determines the bigger position of the bounding box extend
  91831. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91832. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91833. */
  91834. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91835. /**
  91836. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91837. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91838. * frustum width.
  91839. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91840. * to fully enclose the mesh in the viewing frustum.
  91841. */
  91842. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91843. /**
  91844. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91845. * is automatically returned to its default position (expected to be above ground plane).
  91846. */
  91847. private _maintainCameraAboveGround;
  91848. /**
  91849. * Returns the frustum slope based on the canvas ratio and camera FOV
  91850. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91851. */
  91852. private _getFrustumSlope;
  91853. /**
  91854. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91855. */
  91856. private _clearAnimationLocks;
  91857. /**
  91858. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91859. */
  91860. private _applyUserInteraction;
  91861. /**
  91862. * Stops and removes all animations that have been applied to the camera
  91863. */
  91864. stopAllAnimations(): void;
  91865. /**
  91866. * Gets a value indicating if the user is moving the camera
  91867. */
  91868. readonly isUserIsMoving: boolean;
  91869. /**
  91870. * The camera can move all the way towards the mesh.
  91871. */
  91872. static IgnoreBoundsSizeMode: number;
  91873. /**
  91874. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91875. */
  91876. static FitFrustumSidesMode: number;
  91877. }
  91878. }
  91879. declare module BABYLON {
  91880. /**
  91881. * Base class for Camera Pointer Inputs.
  91882. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91883. * for example usage.
  91884. */
  91885. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91886. /**
  91887. * Defines the camera the input is attached to.
  91888. */
  91889. abstract camera: Camera;
  91890. /**
  91891. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91892. */
  91893. protected _altKey: boolean;
  91894. protected _ctrlKey: boolean;
  91895. protected _metaKey: boolean;
  91896. protected _shiftKey: boolean;
  91897. /**
  91898. * Which mouse buttons were pressed at time of last mouse event.
  91899. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91900. */
  91901. protected _buttonsPressed: number;
  91902. /**
  91903. * Defines the buttons associated with the input to handle camera move.
  91904. */
  91905. buttons: number[];
  91906. /**
  91907. * Attach the input controls to a specific dom element to get the input from.
  91908. * @param element Defines the element the controls should be listened from
  91909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91910. */
  91911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91912. /**
  91913. * Detach the current controls from the specified dom element.
  91914. * @param element Defines the element to stop listening the inputs from
  91915. */
  91916. detachControl(element: Nullable<HTMLElement>): void;
  91917. /**
  91918. * Gets the class name of the current input.
  91919. * @returns the class name
  91920. */
  91921. getClassName(): string;
  91922. /**
  91923. * Get the friendly name associated with the input class.
  91924. * @returns the input friendly name
  91925. */
  91926. getSimpleName(): string;
  91927. /**
  91928. * Called on pointer POINTERDOUBLETAP event.
  91929. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91930. */
  91931. protected onDoubleTap(type: string): void;
  91932. /**
  91933. * Called on pointer POINTERMOVE event if only a single touch is active.
  91934. * Override this method to provide functionality.
  91935. */
  91936. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91937. /**
  91938. * Called on pointer POINTERMOVE event if multiple touches are active.
  91939. * Override this method to provide functionality.
  91940. */
  91941. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91942. /**
  91943. * Called on JS contextmenu event.
  91944. * Override this method to provide functionality.
  91945. */
  91946. protected onContextMenu(evt: PointerEvent): void;
  91947. /**
  91948. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91949. * press.
  91950. * Override this method to provide functionality.
  91951. */
  91952. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91953. /**
  91954. * Called each time a new POINTERUP event occurs. Ie, for each button
  91955. * release.
  91956. * Override this method to provide functionality.
  91957. */
  91958. protected onButtonUp(evt: PointerEvent): void;
  91959. /**
  91960. * Called when window becomes inactive.
  91961. * Override this method to provide functionality.
  91962. */
  91963. protected onLostFocus(): void;
  91964. private _pointerInput;
  91965. private _observer;
  91966. private _onLostFocus;
  91967. }
  91968. }
  91969. declare module BABYLON {
  91970. /**
  91971. * Manage the pointers inputs to control an arc rotate camera.
  91972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91973. */
  91974. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91975. /**
  91976. * Defines the camera the input is attached to.
  91977. */
  91978. camera: ArcRotateCamera;
  91979. /**
  91980. * Gets the class name of the current input.
  91981. * @returns the class name
  91982. */
  91983. getClassName(): string;
  91984. /**
  91985. * Defines the buttons associated with the input to handle camera move.
  91986. */
  91987. buttons: number[];
  91988. /**
  91989. * Defines the pointer angular sensibility along the X axis or how fast is
  91990. * the camera rotating.
  91991. */
  91992. angularSensibilityX: number;
  91993. /**
  91994. * Defines the pointer angular sensibility along the Y axis or how fast is
  91995. * the camera rotating.
  91996. */
  91997. angularSensibilityY: number;
  91998. /**
  91999. * Defines the pointer pinch precision or how fast is the camera zooming.
  92000. */
  92001. pinchPrecision: number;
  92002. /**
  92003. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92004. * from 0.
  92005. * It defines the percentage of current camera.radius to use as delta when
  92006. * pinch zoom is used.
  92007. */
  92008. pinchDeltaPercentage: number;
  92009. /**
  92010. * Defines the pointer panning sensibility or how fast is the camera moving.
  92011. */
  92012. panningSensibility: number;
  92013. /**
  92014. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92015. */
  92016. multiTouchPanning: boolean;
  92017. /**
  92018. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92019. * zoom (pinch) through multitouch.
  92020. */
  92021. multiTouchPanAndZoom: boolean;
  92022. /**
  92023. * Revers pinch action direction.
  92024. */
  92025. pinchInwards: boolean;
  92026. private _isPanClick;
  92027. private _twoFingerActivityCount;
  92028. private _isPinching;
  92029. /**
  92030. * Called on pointer POINTERMOVE event if only a single touch is active.
  92031. */
  92032. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92033. /**
  92034. * Called on pointer POINTERDOUBLETAP event.
  92035. */
  92036. protected onDoubleTap(type: string): void;
  92037. /**
  92038. * Called on pointer POINTERMOVE event if multiple touches are active.
  92039. */
  92040. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92041. /**
  92042. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92043. * press.
  92044. */
  92045. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  92046. /**
  92047. * Called each time a new POINTERUP event occurs. Ie, for each button
  92048. * release.
  92049. */
  92050. protected onButtonUp(evt: PointerEvent): void;
  92051. /**
  92052. * Called when window becomes inactive.
  92053. */
  92054. protected onLostFocus(): void;
  92055. }
  92056. }
  92057. declare module BABYLON {
  92058. /**
  92059. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92061. */
  92062. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  92063. /**
  92064. * Defines the camera the input is attached to.
  92065. */
  92066. camera: ArcRotateCamera;
  92067. /**
  92068. * Defines the list of key codes associated with the up action (increase alpha)
  92069. */
  92070. keysUp: number[];
  92071. /**
  92072. * Defines the list of key codes associated with the down action (decrease alpha)
  92073. */
  92074. keysDown: number[];
  92075. /**
  92076. * Defines the list of key codes associated with the left action (increase beta)
  92077. */
  92078. keysLeft: number[];
  92079. /**
  92080. * Defines the list of key codes associated with the right action (decrease beta)
  92081. */
  92082. keysRight: number[];
  92083. /**
  92084. * Defines the list of key codes associated with the reset action.
  92085. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  92086. */
  92087. keysReset: number[];
  92088. /**
  92089. * Defines the panning sensibility of the inputs.
  92090. * (How fast is the camera paning)
  92091. */
  92092. panningSensibility: number;
  92093. /**
  92094. * Defines the zooming sensibility of the inputs.
  92095. * (How fast is the camera zooming)
  92096. */
  92097. zoomingSensibility: number;
  92098. /**
  92099. * Defines wether maintaining the alt key down switch the movement mode from
  92100. * orientation to zoom.
  92101. */
  92102. useAltToZoom: boolean;
  92103. /**
  92104. * Rotation speed of the camera
  92105. */
  92106. angularSpeed: number;
  92107. private _keys;
  92108. private _ctrlPressed;
  92109. private _altPressed;
  92110. private _onCanvasBlurObserver;
  92111. private _onKeyboardObserver;
  92112. private _engine;
  92113. private _scene;
  92114. /**
  92115. * Attach the input controls to a specific dom element to get the input from.
  92116. * @param element Defines the element the controls should be listened from
  92117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92118. */
  92119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92120. /**
  92121. * Detach the current controls from the specified dom element.
  92122. * @param element Defines the element to stop listening the inputs from
  92123. */
  92124. detachControl(element: Nullable<HTMLElement>): void;
  92125. /**
  92126. * Update the current camera state depending on the inputs that have been used this frame.
  92127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92128. */
  92129. checkInputs(): void;
  92130. /**
  92131. * Gets the class name of the current intput.
  92132. * @returns the class name
  92133. */
  92134. getClassName(): string;
  92135. /**
  92136. * Get the friendly name associated with the input class.
  92137. * @returns the input friendly name
  92138. */
  92139. getSimpleName(): string;
  92140. }
  92141. }
  92142. declare module BABYLON {
  92143. /**
  92144. * Manage the mouse wheel inputs to control an arc rotate camera.
  92145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92146. */
  92147. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92148. /**
  92149. * Defines the camera the input is attached to.
  92150. */
  92151. camera: ArcRotateCamera;
  92152. /**
  92153. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92154. */
  92155. wheelPrecision: number;
  92156. /**
  92157. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92158. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92159. */
  92160. wheelDeltaPercentage: number;
  92161. private _wheel;
  92162. private _observer;
  92163. /**
  92164. * Attach the input controls to a specific dom element to get the input from.
  92165. * @param element Defines the element the controls should be listened from
  92166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92167. */
  92168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92169. /**
  92170. * Detach the current controls from the specified dom element.
  92171. * @param element Defines the element to stop listening the inputs from
  92172. */
  92173. detachControl(element: Nullable<HTMLElement>): void;
  92174. /**
  92175. * Gets the class name of the current intput.
  92176. * @returns the class name
  92177. */
  92178. getClassName(): string;
  92179. /**
  92180. * Get the friendly name associated with the input class.
  92181. * @returns the input friendly name
  92182. */
  92183. getSimpleName(): string;
  92184. }
  92185. }
  92186. declare module BABYLON {
  92187. /**
  92188. * Default Inputs manager for the ArcRotateCamera.
  92189. * It groups all the default supported inputs for ease of use.
  92190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92191. */
  92192. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  92193. /**
  92194. * Instantiates a new ArcRotateCameraInputsManager.
  92195. * @param camera Defines the camera the inputs belong to
  92196. */
  92197. constructor(camera: ArcRotateCamera);
  92198. /**
  92199. * Add mouse wheel input support to the input manager.
  92200. * @returns the current input manager
  92201. */
  92202. addMouseWheel(): ArcRotateCameraInputsManager;
  92203. /**
  92204. * Add pointers input support to the input manager.
  92205. * @returns the current input manager
  92206. */
  92207. addPointers(): ArcRotateCameraInputsManager;
  92208. /**
  92209. * Add keyboard input support to the input manager.
  92210. * @returns the current input manager
  92211. */
  92212. addKeyboard(): ArcRotateCameraInputsManager;
  92213. }
  92214. }
  92215. declare module BABYLON {
  92216. /**
  92217. * This represents an orbital type of camera.
  92218. *
  92219. * 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.
  92220. * 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.
  92221. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  92222. */
  92223. export class ArcRotateCamera extends TargetCamera {
  92224. /**
  92225. * Defines the rotation angle of the camera along the longitudinal axis.
  92226. */
  92227. alpha: number;
  92228. /**
  92229. * Defines the rotation angle of the camera along the latitudinal axis.
  92230. */
  92231. beta: number;
  92232. /**
  92233. * Defines the radius of the camera from it s target point.
  92234. */
  92235. radius: number;
  92236. protected _target: Vector3;
  92237. protected _targetHost: Nullable<AbstractMesh>;
  92238. /**
  92239. * Defines the target point of the camera.
  92240. * The camera looks towards it form the radius distance.
  92241. */
  92242. target: Vector3;
  92243. /**
  92244. * Define the current local position of the camera in the scene
  92245. */
  92246. position: Vector3;
  92247. /**
  92248. * Current inertia value on the longitudinal axis.
  92249. * The bigger this number the longer it will take for the camera to stop.
  92250. */
  92251. inertialAlphaOffset: number;
  92252. /**
  92253. * Current inertia value on the latitudinal axis.
  92254. * The bigger this number the longer it will take for the camera to stop.
  92255. */
  92256. inertialBetaOffset: number;
  92257. /**
  92258. * Current inertia value on the radius axis.
  92259. * The bigger this number the longer it will take for the camera to stop.
  92260. */
  92261. inertialRadiusOffset: number;
  92262. /**
  92263. * Minimum allowed angle on the longitudinal axis.
  92264. * This can help limiting how the Camera is able to move in the scene.
  92265. */
  92266. lowerAlphaLimit: Nullable<number>;
  92267. /**
  92268. * Maximum allowed angle on the longitudinal axis.
  92269. * This can help limiting how the Camera is able to move in the scene.
  92270. */
  92271. upperAlphaLimit: Nullable<number>;
  92272. /**
  92273. * Minimum allowed angle on the latitudinal axis.
  92274. * This can help limiting how the Camera is able to move in the scene.
  92275. */
  92276. lowerBetaLimit: number;
  92277. /**
  92278. * Maximum allowed angle on the latitudinal axis.
  92279. * This can help limiting how the Camera is able to move in the scene.
  92280. */
  92281. upperBetaLimit: number;
  92282. /**
  92283. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  92284. * This can help limiting how the Camera is able to move in the scene.
  92285. */
  92286. lowerRadiusLimit: Nullable<number>;
  92287. /**
  92288. * Maximum allowed distance of the camera to the target (The camera can not get further).
  92289. * This can help limiting how the Camera is able to move in the scene.
  92290. */
  92291. upperRadiusLimit: Nullable<number>;
  92292. /**
  92293. * Defines the current inertia value used during panning of the camera along the X axis.
  92294. */
  92295. inertialPanningX: number;
  92296. /**
  92297. * Defines the current inertia value used during panning of the camera along the Y axis.
  92298. */
  92299. inertialPanningY: number;
  92300. /**
  92301. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  92302. * Basically if your fingers moves away from more than this distance you will be considered
  92303. * in pinch mode.
  92304. */
  92305. pinchToPanMaxDistance: number;
  92306. /**
  92307. * Defines the maximum distance the camera can pan.
  92308. * This could help keeping the cammera always in your scene.
  92309. */
  92310. panningDistanceLimit: Nullable<number>;
  92311. /**
  92312. * Defines the target of the camera before paning.
  92313. */
  92314. panningOriginTarget: Vector3;
  92315. /**
  92316. * Defines the value of the inertia used during panning.
  92317. * 0 would mean stop inertia and one would mean no decelleration at all.
  92318. */
  92319. panningInertia: number;
  92320. /**
  92321. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  92322. */
  92323. angularSensibilityX: number;
  92324. /**
  92325. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  92326. */
  92327. angularSensibilityY: number;
  92328. /**
  92329. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  92330. */
  92331. pinchPrecision: number;
  92332. /**
  92333. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  92334. * It will be used instead of pinchDeltaPrecision if different from 0.
  92335. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92336. */
  92337. pinchDeltaPercentage: number;
  92338. /**
  92339. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  92340. */
  92341. panningSensibility: number;
  92342. /**
  92343. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  92344. */
  92345. keysUp: number[];
  92346. /**
  92347. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  92348. */
  92349. keysDown: number[];
  92350. /**
  92351. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  92352. */
  92353. keysLeft: number[];
  92354. /**
  92355. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92356. */
  92357. keysRight: number[];
  92358. /**
  92359. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92360. */
  92361. wheelPrecision: number;
  92362. /**
  92363. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92364. * It will be used instead of pinchDeltaPrecision if different from 0.
  92365. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92366. */
  92367. wheelDeltaPercentage: number;
  92368. /**
  92369. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92370. */
  92371. zoomOnFactor: number;
  92372. /**
  92373. * Defines a screen offset for the camera position.
  92374. */
  92375. targetScreenOffset: Vector2;
  92376. /**
  92377. * Allows the camera to be completely reversed.
  92378. * If false the camera can not arrive upside down.
  92379. */
  92380. allowUpsideDown: boolean;
  92381. /**
  92382. * Define if double tap/click is used to restore the previously saved state of the camera.
  92383. */
  92384. useInputToRestoreState: boolean;
  92385. /** @hidden */
  92386. _viewMatrix: Matrix;
  92387. /** @hidden */
  92388. _useCtrlForPanning: boolean;
  92389. /** @hidden */
  92390. _panningMouseButton: number;
  92391. /**
  92392. * Defines the input associated to the camera.
  92393. */
  92394. inputs: ArcRotateCameraInputsManager;
  92395. /** @hidden */
  92396. _reset: () => void;
  92397. /**
  92398. * Defines the allowed panning axis.
  92399. */
  92400. panningAxis: Vector3;
  92401. protected _localDirection: Vector3;
  92402. protected _transformedDirection: Vector3;
  92403. private _bouncingBehavior;
  92404. /**
  92405. * Gets the bouncing behavior of the camera if it has been enabled.
  92406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92407. */
  92408. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92409. /**
  92410. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92412. */
  92413. useBouncingBehavior: boolean;
  92414. private _framingBehavior;
  92415. /**
  92416. * Gets the framing behavior of the camera if it has been enabled.
  92417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92418. */
  92419. readonly framingBehavior: Nullable<FramingBehavior>;
  92420. /**
  92421. * Defines if the framing behavior of the camera is enabled on the camera.
  92422. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92423. */
  92424. useFramingBehavior: boolean;
  92425. private _autoRotationBehavior;
  92426. /**
  92427. * Gets the auto rotation behavior of the camera if it has been enabled.
  92428. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92429. */
  92430. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92431. /**
  92432. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92433. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92434. */
  92435. useAutoRotationBehavior: boolean;
  92436. /**
  92437. * Observable triggered when the mesh target has been changed on the camera.
  92438. */
  92439. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92440. /**
  92441. * Event raised when the camera is colliding with a mesh.
  92442. */
  92443. onCollide: (collidedMesh: AbstractMesh) => void;
  92444. /**
  92445. * Defines whether the camera should check collision with the objects oh the scene.
  92446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92447. */
  92448. checkCollisions: boolean;
  92449. /**
  92450. * Defines the collision radius of the camera.
  92451. * This simulates a sphere around the camera.
  92452. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92453. */
  92454. collisionRadius: Vector3;
  92455. protected _collider: Collider;
  92456. protected _previousPosition: Vector3;
  92457. protected _collisionVelocity: Vector3;
  92458. protected _newPosition: Vector3;
  92459. protected _previousAlpha: number;
  92460. protected _previousBeta: number;
  92461. protected _previousRadius: number;
  92462. protected _collisionTriggered: boolean;
  92463. protected _targetBoundingCenter: Nullable<Vector3>;
  92464. private _computationVector;
  92465. private _tempAxisVector;
  92466. private _tempAxisRotationMatrix;
  92467. /**
  92468. * Instantiates a new ArcRotateCamera in a given scene
  92469. * @param name Defines the name of the camera
  92470. * @param alpha Defines the camera rotation along the logitudinal axis
  92471. * @param beta Defines the camera rotation along the latitudinal axis
  92472. * @param radius Defines the camera distance from its target
  92473. * @param target Defines the camera target
  92474. * @param scene Defines the scene the camera belongs to
  92475. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92476. */
  92477. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92478. /** @hidden */
  92479. _initCache(): void;
  92480. /** @hidden */
  92481. _updateCache(ignoreParentClass?: boolean): void;
  92482. protected _getTargetPosition(): Vector3;
  92483. private _storedAlpha;
  92484. private _storedBeta;
  92485. private _storedRadius;
  92486. private _storedTarget;
  92487. /**
  92488. * Stores the current state of the camera (alpha, beta, radius and target)
  92489. * @returns the camera itself
  92490. */
  92491. storeState(): Camera;
  92492. /**
  92493. * @hidden
  92494. * Restored camera state. You must call storeState() first
  92495. */
  92496. _restoreStateValues(): boolean;
  92497. /** @hidden */
  92498. _isSynchronizedViewMatrix(): boolean;
  92499. /**
  92500. * Attached controls to the current camera.
  92501. * @param element Defines the element the controls should be listened from
  92502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92503. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92504. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92505. */
  92506. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92507. /**
  92508. * Detach the current controls from the camera.
  92509. * The camera will stop reacting to inputs.
  92510. * @param element Defines the element to stop listening the inputs from
  92511. */
  92512. detachControl(element: HTMLElement): void;
  92513. /** @hidden */
  92514. _checkInputs(): void;
  92515. protected _checkLimits(): void;
  92516. /**
  92517. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92518. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92519. */
  92520. rebuildAnglesAndRadius(updateView?: boolean): void;
  92521. /**
  92522. * Use a position to define the current camera related information like aplha, beta and radius
  92523. * @param position Defines the position to set the camera at
  92524. */
  92525. setPosition(position: Vector3): void;
  92526. /**
  92527. * Defines the target the camera should look at.
  92528. * This will automatically adapt alpha beta and radius to fit within the new target.
  92529. * @param target Defines the new target as a Vector or a mesh
  92530. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92531. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92532. */
  92533. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92534. /** @hidden */
  92535. _getViewMatrix(): Matrix;
  92536. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92537. /**
  92538. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92539. * @param meshes Defines the mesh to zoom on
  92540. * @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)
  92541. */
  92542. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92543. /**
  92544. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92545. * The target will be changed but the radius
  92546. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92547. * @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)
  92548. */
  92549. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92550. min: Vector3;
  92551. max: Vector3;
  92552. distance: number;
  92553. }, doNotUpdateMaxZ?: boolean): void;
  92554. /**
  92555. * @override
  92556. * Override Camera.createRigCamera
  92557. */
  92558. createRigCamera(name: string, cameraIndex: number): Camera;
  92559. /**
  92560. * @hidden
  92561. * @override
  92562. * Override Camera._updateRigCameras
  92563. */
  92564. _updateRigCameras(): void;
  92565. /**
  92566. * Destroy the camera and release the current resources hold by it.
  92567. */
  92568. dispose(): void;
  92569. /**
  92570. * Gets the current object class name.
  92571. * @return the class name
  92572. */
  92573. getClassName(): string;
  92574. }
  92575. }
  92576. declare module BABYLON {
  92577. /**
  92578. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92579. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92580. */
  92581. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92582. /**
  92583. * Gets the name of the behavior.
  92584. */
  92585. readonly name: string;
  92586. private _zoomStopsAnimation;
  92587. private _idleRotationSpeed;
  92588. private _idleRotationWaitTime;
  92589. private _idleRotationSpinupTime;
  92590. /**
  92591. * Sets the flag that indicates if user zooming should stop animation.
  92592. */
  92593. /**
  92594. * Gets the flag that indicates if user zooming should stop animation.
  92595. */
  92596. zoomStopsAnimation: boolean;
  92597. /**
  92598. * Sets the default speed at which the camera rotates around the model.
  92599. */
  92600. /**
  92601. * Gets the default speed at which the camera rotates around the model.
  92602. */
  92603. idleRotationSpeed: number;
  92604. /**
  92605. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92606. */
  92607. /**
  92608. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92609. */
  92610. idleRotationWaitTime: number;
  92611. /**
  92612. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92613. */
  92614. /**
  92615. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92616. */
  92617. idleRotationSpinupTime: number;
  92618. /**
  92619. * Gets a value indicating if the camera is currently rotating because of this behavior
  92620. */
  92621. readonly rotationInProgress: boolean;
  92622. private _onPrePointerObservableObserver;
  92623. private _onAfterCheckInputsObserver;
  92624. private _attachedCamera;
  92625. private _isPointerDown;
  92626. private _lastFrameTime;
  92627. private _lastInteractionTime;
  92628. private _cameraRotationSpeed;
  92629. /**
  92630. * Initializes the behavior.
  92631. */
  92632. init(): void;
  92633. /**
  92634. * Attaches the behavior to its arc rotate camera.
  92635. * @param camera Defines the camera to attach the behavior to
  92636. */
  92637. attach(camera: ArcRotateCamera): void;
  92638. /**
  92639. * Detaches the behavior from its current arc rotate camera.
  92640. */
  92641. detach(): void;
  92642. /**
  92643. * Returns true if user is scrolling.
  92644. * @return true if user is scrolling.
  92645. */
  92646. private _userIsZooming;
  92647. private _lastFrameRadius;
  92648. private _shouldAnimationStopForInteraction;
  92649. /**
  92650. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92651. */
  92652. private _applyUserInteraction;
  92653. private _userIsMoving;
  92654. }
  92655. }
  92656. declare module BABYLON {
  92657. /**
  92658. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92659. */
  92660. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92661. private ui;
  92662. /**
  92663. * The name of the behavior
  92664. */
  92665. name: string;
  92666. /**
  92667. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92668. */
  92669. distanceAwayFromFace: number;
  92670. /**
  92671. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92672. */
  92673. distanceAwayFromBottomOfFace: number;
  92674. private _faceVectors;
  92675. private _target;
  92676. private _scene;
  92677. private _onRenderObserver;
  92678. private _tmpMatrix;
  92679. private _tmpVector;
  92680. /**
  92681. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92682. * @param ui The transform node that should be attched to the mesh
  92683. */
  92684. constructor(ui: TransformNode);
  92685. /**
  92686. * Initializes the behavior
  92687. */
  92688. init(): void;
  92689. private _closestFace;
  92690. private _zeroVector;
  92691. private _lookAtTmpMatrix;
  92692. private _lookAtToRef;
  92693. /**
  92694. * Attaches the AttachToBoxBehavior to the passed in mesh
  92695. * @param target The mesh that the specified node will be attached to
  92696. */
  92697. attach(target: Mesh): void;
  92698. /**
  92699. * Detaches the behavior from the mesh
  92700. */
  92701. detach(): void;
  92702. }
  92703. }
  92704. declare module BABYLON {
  92705. /**
  92706. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92707. */
  92708. export class FadeInOutBehavior implements Behavior<Mesh> {
  92709. /**
  92710. * Time in milliseconds to delay before fading in (Default: 0)
  92711. */
  92712. delay: number;
  92713. /**
  92714. * Time in milliseconds for the mesh to fade in (Default: 300)
  92715. */
  92716. fadeInTime: number;
  92717. private _millisecondsPerFrame;
  92718. private _hovered;
  92719. private _hoverValue;
  92720. private _ownerNode;
  92721. /**
  92722. * Instatiates the FadeInOutBehavior
  92723. */
  92724. constructor();
  92725. /**
  92726. * The name of the behavior
  92727. */
  92728. readonly name: string;
  92729. /**
  92730. * Initializes the behavior
  92731. */
  92732. init(): void;
  92733. /**
  92734. * Attaches the fade behavior on the passed in mesh
  92735. * @param ownerNode The mesh that will be faded in/out once attached
  92736. */
  92737. attach(ownerNode: Mesh): void;
  92738. /**
  92739. * Detaches the behavior from the mesh
  92740. */
  92741. detach(): void;
  92742. /**
  92743. * Triggers the mesh to begin fading in or out
  92744. * @param value if the object should fade in or out (true to fade in)
  92745. */
  92746. fadeIn(value: boolean): void;
  92747. private _update;
  92748. private _setAllVisibility;
  92749. }
  92750. }
  92751. declare module BABYLON {
  92752. /**
  92753. * Class containing a set of static utilities functions for managing Pivots
  92754. * @hidden
  92755. */
  92756. export class PivotTools {
  92757. private static _PivotCached;
  92758. private static _OldPivotPoint;
  92759. private static _PivotTranslation;
  92760. private static _PivotTmpVector;
  92761. /** @hidden */
  92762. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92763. /** @hidden */
  92764. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92765. }
  92766. }
  92767. declare module BABYLON {
  92768. /**
  92769. * Class containing static functions to help procedurally build meshes
  92770. */
  92771. export class PlaneBuilder {
  92772. /**
  92773. * Creates a plane mesh
  92774. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92775. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92776. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92780. * @param name defines the name of the mesh
  92781. * @param options defines the options used to create the mesh
  92782. * @param scene defines the hosting scene
  92783. * @returns the plane mesh
  92784. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92785. */
  92786. static CreatePlane(name: string, options: {
  92787. size?: number;
  92788. width?: number;
  92789. height?: number;
  92790. sideOrientation?: number;
  92791. frontUVs?: Vector4;
  92792. backUVs?: Vector4;
  92793. updatable?: boolean;
  92794. sourcePlane?: Plane;
  92795. }, scene: Scene): Mesh;
  92796. }
  92797. }
  92798. declare module BABYLON {
  92799. /**
  92800. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92801. */
  92802. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92803. private static _AnyMouseID;
  92804. private _attachedNode;
  92805. private _dragPlane;
  92806. private _scene;
  92807. private _pointerObserver;
  92808. private _beforeRenderObserver;
  92809. private static _planeScene;
  92810. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92811. /**
  92812. * 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)
  92813. */
  92814. maxDragAngle: number;
  92815. /**
  92816. * @hidden
  92817. */
  92818. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92819. /**
  92820. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92821. */
  92822. currentDraggingPointerID: number;
  92823. /**
  92824. * The last position where the pointer hit the drag plane in world space
  92825. */
  92826. lastDragPosition: Vector3;
  92827. /**
  92828. * If the behavior is currently in a dragging state
  92829. */
  92830. dragging: boolean;
  92831. /**
  92832. * 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)
  92833. */
  92834. dragDeltaRatio: number;
  92835. /**
  92836. * If the drag plane orientation should be updated during the dragging (Default: true)
  92837. */
  92838. updateDragPlane: boolean;
  92839. private _debugMode;
  92840. private _moving;
  92841. /**
  92842. * Fires each time the attached mesh is dragged with the pointer
  92843. * * delta between last drag position and current drag position in world space
  92844. * * dragDistance along the drag axis
  92845. * * dragPlaneNormal normal of the current drag plane used during the drag
  92846. * * dragPlanePoint in world space where the drag intersects the drag plane
  92847. */
  92848. onDragObservable: Observable<{
  92849. delta: Vector3;
  92850. dragPlanePoint: Vector3;
  92851. dragPlaneNormal: Vector3;
  92852. dragDistance: number;
  92853. pointerId: number;
  92854. }>;
  92855. /**
  92856. * Fires each time a drag begins (eg. mouse down on mesh)
  92857. */
  92858. onDragStartObservable: Observable<{
  92859. dragPlanePoint: Vector3;
  92860. pointerId: number;
  92861. }>;
  92862. /**
  92863. * Fires each time a drag ends (eg. mouse release after drag)
  92864. */
  92865. onDragEndObservable: Observable<{
  92866. dragPlanePoint: Vector3;
  92867. pointerId: number;
  92868. }>;
  92869. /**
  92870. * If the attached mesh should be moved when dragged
  92871. */
  92872. moveAttached: boolean;
  92873. /**
  92874. * If the drag behavior will react to drag events (Default: true)
  92875. */
  92876. enabled: boolean;
  92877. /**
  92878. * If camera controls should be detached during the drag
  92879. */
  92880. detachCameraControls: boolean;
  92881. /**
  92882. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92883. */
  92884. useObjectOrienationForDragging: boolean;
  92885. private _options;
  92886. /**
  92887. * Creates a pointer drag behavior that can be attached to a mesh
  92888. * @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)
  92889. */
  92890. constructor(options?: {
  92891. dragAxis?: Vector3;
  92892. dragPlaneNormal?: Vector3;
  92893. });
  92894. /**
  92895. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92896. */
  92897. validateDrag: (targetPosition: Vector3) => boolean;
  92898. /**
  92899. * The name of the behavior
  92900. */
  92901. readonly name: string;
  92902. /**
  92903. * Initializes the behavior
  92904. */
  92905. init(): void;
  92906. private _tmpVector;
  92907. private _alternatePickedPoint;
  92908. private _worldDragAxis;
  92909. private _targetPosition;
  92910. private _attachedElement;
  92911. /**
  92912. * Attaches the drag behavior the passed in mesh
  92913. * @param ownerNode The mesh that will be dragged around once attached
  92914. */
  92915. attach(ownerNode: AbstractMesh): void;
  92916. /**
  92917. * Force relase the drag action by code.
  92918. */
  92919. releaseDrag(): void;
  92920. private _startDragRay;
  92921. private _lastPointerRay;
  92922. /**
  92923. * Simulates the start of a pointer drag event on the behavior
  92924. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92925. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92926. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92927. */
  92928. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92929. private _startDrag;
  92930. private _dragDelta;
  92931. private _moveDrag;
  92932. private _pickWithRayOnDragPlane;
  92933. private _pointA;
  92934. private _pointB;
  92935. private _pointC;
  92936. private _lineA;
  92937. private _lineB;
  92938. private _localAxis;
  92939. private _lookAt;
  92940. private _updateDragPlanePosition;
  92941. /**
  92942. * Detaches the behavior from the mesh
  92943. */
  92944. detach(): void;
  92945. }
  92946. }
  92947. declare module BABYLON {
  92948. /**
  92949. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92950. */
  92951. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92952. private _dragBehaviorA;
  92953. private _dragBehaviorB;
  92954. private _startDistance;
  92955. private _initialScale;
  92956. private _targetScale;
  92957. private _ownerNode;
  92958. private _sceneRenderObserver;
  92959. /**
  92960. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92961. */
  92962. constructor();
  92963. /**
  92964. * The name of the behavior
  92965. */
  92966. readonly name: string;
  92967. /**
  92968. * Initializes the behavior
  92969. */
  92970. init(): void;
  92971. private _getCurrentDistance;
  92972. /**
  92973. * Attaches the scale behavior the passed in mesh
  92974. * @param ownerNode The mesh that will be scaled around once attached
  92975. */
  92976. attach(ownerNode: Mesh): void;
  92977. /**
  92978. * Detaches the behavior from the mesh
  92979. */
  92980. detach(): void;
  92981. }
  92982. }
  92983. declare module BABYLON {
  92984. /**
  92985. * 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
  92986. */
  92987. export class SixDofDragBehavior implements Behavior<Mesh> {
  92988. private static _virtualScene;
  92989. private _ownerNode;
  92990. private _sceneRenderObserver;
  92991. private _scene;
  92992. private _targetPosition;
  92993. private _virtualOriginMesh;
  92994. private _virtualDragMesh;
  92995. private _pointerObserver;
  92996. private _moving;
  92997. private _startingOrientation;
  92998. /**
  92999. * 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)
  93000. */
  93001. private zDragFactor;
  93002. /**
  93003. * If the object should rotate to face the drag origin
  93004. */
  93005. rotateDraggedObject: boolean;
  93006. /**
  93007. * If the behavior is currently in a dragging state
  93008. */
  93009. dragging: boolean;
  93010. /**
  93011. * 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)
  93012. */
  93013. dragDeltaRatio: number;
  93014. /**
  93015. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93016. */
  93017. currentDraggingPointerID: number;
  93018. /**
  93019. * If camera controls should be detached during the drag
  93020. */
  93021. detachCameraControls: boolean;
  93022. /**
  93023. * Fires each time a drag starts
  93024. */
  93025. onDragStartObservable: Observable<{}>;
  93026. /**
  93027. * Fires each time a drag ends (eg. mouse release after drag)
  93028. */
  93029. onDragEndObservable: Observable<{}>;
  93030. /**
  93031. * 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
  93032. */
  93033. constructor();
  93034. /**
  93035. * The name of the behavior
  93036. */
  93037. readonly name: string;
  93038. /**
  93039. * Initializes the behavior
  93040. */
  93041. init(): void;
  93042. /**
  93043. * Attaches the scale behavior the passed in mesh
  93044. * @param ownerNode The mesh that will be scaled around once attached
  93045. */
  93046. attach(ownerNode: Mesh): void;
  93047. /**
  93048. * Detaches the behavior from the mesh
  93049. */
  93050. detach(): void;
  93051. }
  93052. }
  93053. declare module BABYLON {
  93054. /**
  93055. * Class used to apply inverse kinematics to bones
  93056. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  93057. */
  93058. export class BoneIKController {
  93059. private static _tmpVecs;
  93060. private static _tmpQuat;
  93061. private static _tmpMats;
  93062. /**
  93063. * Gets or sets the target mesh
  93064. */
  93065. targetMesh: AbstractMesh;
  93066. /** Gets or sets the mesh used as pole */
  93067. poleTargetMesh: AbstractMesh;
  93068. /**
  93069. * Gets or sets the bone used as pole
  93070. */
  93071. poleTargetBone: Nullable<Bone>;
  93072. /**
  93073. * Gets or sets the target position
  93074. */
  93075. targetPosition: Vector3;
  93076. /**
  93077. * Gets or sets the pole target position
  93078. */
  93079. poleTargetPosition: Vector3;
  93080. /**
  93081. * Gets or sets the pole target local offset
  93082. */
  93083. poleTargetLocalOffset: Vector3;
  93084. /**
  93085. * Gets or sets the pole angle
  93086. */
  93087. poleAngle: number;
  93088. /**
  93089. * Gets or sets the mesh associated with the controller
  93090. */
  93091. mesh: AbstractMesh;
  93092. /**
  93093. * 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)
  93094. */
  93095. slerpAmount: number;
  93096. private _bone1Quat;
  93097. private _bone1Mat;
  93098. private _bone2Ang;
  93099. private _bone1;
  93100. private _bone2;
  93101. private _bone1Length;
  93102. private _bone2Length;
  93103. private _maxAngle;
  93104. private _maxReach;
  93105. private _rightHandedSystem;
  93106. private _bendAxis;
  93107. private _slerping;
  93108. private _adjustRoll;
  93109. /**
  93110. * Gets or sets maximum allowed angle
  93111. */
  93112. maxAngle: number;
  93113. /**
  93114. * Creates a new BoneIKController
  93115. * @param mesh defines the mesh to control
  93116. * @param bone defines the bone to control
  93117. * @param options defines options to set up the controller
  93118. */
  93119. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  93120. targetMesh?: AbstractMesh;
  93121. poleTargetMesh?: AbstractMesh;
  93122. poleTargetBone?: Bone;
  93123. poleTargetLocalOffset?: Vector3;
  93124. poleAngle?: number;
  93125. bendAxis?: Vector3;
  93126. maxAngle?: number;
  93127. slerpAmount?: number;
  93128. });
  93129. private _setMaxAngle;
  93130. /**
  93131. * Force the controller to update the bones
  93132. */
  93133. update(): void;
  93134. }
  93135. }
  93136. declare module BABYLON {
  93137. /**
  93138. * Class used to make a bone look toward a point in space
  93139. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  93140. */
  93141. export class BoneLookController {
  93142. private static _tmpVecs;
  93143. private static _tmpQuat;
  93144. private static _tmpMats;
  93145. /**
  93146. * The target Vector3 that the bone will look at
  93147. */
  93148. target: Vector3;
  93149. /**
  93150. * The mesh that the bone is attached to
  93151. */
  93152. mesh: AbstractMesh;
  93153. /**
  93154. * The bone that will be looking to the target
  93155. */
  93156. bone: Bone;
  93157. /**
  93158. * The up axis of the coordinate system that is used when the bone is rotated
  93159. */
  93160. upAxis: Vector3;
  93161. /**
  93162. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93163. */
  93164. upAxisSpace: Space;
  93165. /**
  93166. * Used to make an adjustment to the yaw of the bone
  93167. */
  93168. adjustYaw: number;
  93169. /**
  93170. * Used to make an adjustment to the pitch of the bone
  93171. */
  93172. adjustPitch: number;
  93173. /**
  93174. * Used to make an adjustment to the roll of the bone
  93175. */
  93176. adjustRoll: number;
  93177. /**
  93178. * 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)
  93179. */
  93180. slerpAmount: number;
  93181. private _minYaw;
  93182. private _maxYaw;
  93183. private _minPitch;
  93184. private _maxPitch;
  93185. private _minYawSin;
  93186. private _minYawCos;
  93187. private _maxYawSin;
  93188. private _maxYawCos;
  93189. private _midYawConstraint;
  93190. private _minPitchTan;
  93191. private _maxPitchTan;
  93192. private _boneQuat;
  93193. private _slerping;
  93194. private _transformYawPitch;
  93195. private _transformYawPitchInv;
  93196. private _firstFrameSkipped;
  93197. private _yawRange;
  93198. private _fowardAxis;
  93199. /**
  93200. * Gets or sets the minimum yaw angle that the bone can look to
  93201. */
  93202. minYaw: number;
  93203. /**
  93204. * Gets or sets the maximum yaw angle that the bone can look to
  93205. */
  93206. maxYaw: number;
  93207. /**
  93208. * Gets or sets the minimum pitch angle that the bone can look to
  93209. */
  93210. minPitch: number;
  93211. /**
  93212. * Gets or sets the maximum pitch angle that the bone can look to
  93213. */
  93214. maxPitch: number;
  93215. /**
  93216. * Create a BoneLookController
  93217. * @param mesh the mesh that the bone belongs to
  93218. * @param bone the bone that will be looking to the target
  93219. * @param target the target Vector3 to look at
  93220. * @param options optional settings:
  93221. * * maxYaw: the maximum angle the bone will yaw to
  93222. * * minYaw: the minimum angle the bone will yaw to
  93223. * * maxPitch: the maximum angle the bone will pitch to
  93224. * * minPitch: the minimum angle the bone will yaw to
  93225. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  93226. * * upAxis: the up axis of the coordinate system
  93227. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  93228. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  93229. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  93230. * * adjustYaw: used to make an adjustment to the yaw of the bone
  93231. * * adjustPitch: used to make an adjustment to the pitch of the bone
  93232. * * adjustRoll: used to make an adjustment to the roll of the bone
  93233. **/
  93234. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  93235. maxYaw?: number;
  93236. minYaw?: number;
  93237. maxPitch?: number;
  93238. minPitch?: number;
  93239. slerpAmount?: number;
  93240. upAxis?: Vector3;
  93241. upAxisSpace?: Space;
  93242. yawAxis?: Vector3;
  93243. pitchAxis?: Vector3;
  93244. adjustYaw?: number;
  93245. adjustPitch?: number;
  93246. adjustRoll?: number;
  93247. });
  93248. /**
  93249. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  93250. */
  93251. update(): void;
  93252. private _getAngleDiff;
  93253. private _getAngleBetween;
  93254. private _isAngleBetween;
  93255. }
  93256. }
  93257. declare module BABYLON {
  93258. /**
  93259. * Manage the gamepad inputs to control an arc rotate camera.
  93260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93261. */
  93262. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  93263. /**
  93264. * Defines the camera the input is attached to.
  93265. */
  93266. camera: ArcRotateCamera;
  93267. /**
  93268. * Defines the gamepad the input is gathering event from.
  93269. */
  93270. gamepad: Nullable<Gamepad>;
  93271. /**
  93272. * Defines the gamepad rotation sensiblity.
  93273. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93274. */
  93275. gamepadRotationSensibility: number;
  93276. /**
  93277. * Defines the gamepad move sensiblity.
  93278. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93279. */
  93280. gamepadMoveSensibility: number;
  93281. private _onGamepadConnectedObserver;
  93282. private _onGamepadDisconnectedObserver;
  93283. /**
  93284. * Attach the input controls to a specific dom element to get the input from.
  93285. * @param element Defines the element the controls should be listened from
  93286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93287. */
  93288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93289. /**
  93290. * Detach the current controls from the specified dom element.
  93291. * @param element Defines the element to stop listening the inputs from
  93292. */
  93293. detachControl(element: Nullable<HTMLElement>): void;
  93294. /**
  93295. * Update the current camera state depending on the inputs that have been used this frame.
  93296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93297. */
  93298. checkInputs(): void;
  93299. /**
  93300. * Gets the class name of the current intput.
  93301. * @returns the class name
  93302. */
  93303. getClassName(): string;
  93304. /**
  93305. * Get the friendly name associated with the input class.
  93306. * @returns the input friendly name
  93307. */
  93308. getSimpleName(): string;
  93309. }
  93310. }
  93311. declare module BABYLON {
  93312. interface ArcRotateCameraInputsManager {
  93313. /**
  93314. * Add orientation input support to the input manager.
  93315. * @returns the current input manager
  93316. */
  93317. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  93318. }
  93319. /**
  93320. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  93321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93322. */
  93323. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  93324. /**
  93325. * Defines the camera the input is attached to.
  93326. */
  93327. camera: ArcRotateCamera;
  93328. /**
  93329. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  93330. */
  93331. alphaCorrection: number;
  93332. /**
  93333. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  93334. */
  93335. gammaCorrection: number;
  93336. private _alpha;
  93337. private _gamma;
  93338. private _dirty;
  93339. private _deviceOrientationHandler;
  93340. /**
  93341. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  93342. */
  93343. constructor();
  93344. /**
  93345. * Attach the input controls to a specific dom element to get the input from.
  93346. * @param element Defines the element the controls should be listened from
  93347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93348. */
  93349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93350. /** @hidden */
  93351. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  93352. /**
  93353. * Update the current camera state depending on the inputs that have been used this frame.
  93354. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93355. */
  93356. checkInputs(): void;
  93357. /**
  93358. * Detach the current controls from the specified dom element.
  93359. * @param element Defines the element to stop listening the inputs from
  93360. */
  93361. detachControl(element: Nullable<HTMLElement>): void;
  93362. /**
  93363. * Gets the class name of the current intput.
  93364. * @returns the class name
  93365. */
  93366. getClassName(): string;
  93367. /**
  93368. * Get the friendly name associated with the input class.
  93369. * @returns the input friendly name
  93370. */
  93371. getSimpleName(): string;
  93372. }
  93373. }
  93374. declare module BABYLON {
  93375. /**
  93376. * Listen to mouse events to control the camera.
  93377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93378. */
  93379. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93380. /**
  93381. * Defines the camera the input is attached to.
  93382. */
  93383. camera: FlyCamera;
  93384. /**
  93385. * Defines if touch is enabled. (Default is true.)
  93386. */
  93387. touchEnabled: boolean;
  93388. /**
  93389. * Defines the buttons associated with the input to handle camera rotation.
  93390. */
  93391. buttons: number[];
  93392. /**
  93393. * Assign buttons for Yaw control.
  93394. */
  93395. buttonsYaw: number[];
  93396. /**
  93397. * Assign buttons for Pitch control.
  93398. */
  93399. buttonsPitch: number[];
  93400. /**
  93401. * Assign buttons for Roll control.
  93402. */
  93403. buttonsRoll: number[];
  93404. /**
  93405. * Detect if any button is being pressed while mouse is moved.
  93406. * -1 = Mouse locked.
  93407. * 0 = Left button.
  93408. * 1 = Middle Button.
  93409. * 2 = Right Button.
  93410. */
  93411. activeButton: number;
  93412. /**
  93413. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93414. * Higher values reduce its sensitivity.
  93415. */
  93416. angularSensibility: number;
  93417. private _mousemoveCallback;
  93418. private _observer;
  93419. private _rollObserver;
  93420. private previousPosition;
  93421. private noPreventDefault;
  93422. private element;
  93423. /**
  93424. * Listen to mouse events to control the camera.
  93425. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93427. */
  93428. constructor(touchEnabled?: boolean);
  93429. /**
  93430. * Attach the mouse control to the HTML DOM element.
  93431. * @param element Defines the element that listens to the input events.
  93432. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93433. */
  93434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93435. /**
  93436. * Detach the current controls from the specified dom element.
  93437. * @param element Defines the element to stop listening the inputs from
  93438. */
  93439. detachControl(element: Nullable<HTMLElement>): void;
  93440. /**
  93441. * Gets the class name of the current input.
  93442. * @returns the class name.
  93443. */
  93444. getClassName(): string;
  93445. /**
  93446. * Get the friendly name associated with the input class.
  93447. * @returns the input's friendly name.
  93448. */
  93449. getSimpleName(): string;
  93450. private _pointerInput;
  93451. private _onMouseMove;
  93452. /**
  93453. * Rotate camera by mouse offset.
  93454. */
  93455. private rotateCamera;
  93456. }
  93457. }
  93458. declare module BABYLON {
  93459. /**
  93460. * Default Inputs manager for the FlyCamera.
  93461. * It groups all the default supported inputs for ease of use.
  93462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93463. */
  93464. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93465. /**
  93466. * Instantiates a new FlyCameraInputsManager.
  93467. * @param camera Defines the camera the inputs belong to.
  93468. */
  93469. constructor(camera: FlyCamera);
  93470. /**
  93471. * Add keyboard input support to the input manager.
  93472. * @returns the new FlyCameraKeyboardMoveInput().
  93473. */
  93474. addKeyboard(): FlyCameraInputsManager;
  93475. /**
  93476. * Add mouse input support to the input manager.
  93477. * @param touchEnabled Enable touch screen support.
  93478. * @returns the new FlyCameraMouseInput().
  93479. */
  93480. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93481. }
  93482. }
  93483. declare module BABYLON {
  93484. /**
  93485. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93486. * such as in a 3D Space Shooter or a Flight Simulator.
  93487. */
  93488. export class FlyCamera extends TargetCamera {
  93489. /**
  93490. * Define the collision ellipsoid of the camera.
  93491. * This is helpful for simulating a camera body, like a player's body.
  93492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93493. */
  93494. ellipsoid: Vector3;
  93495. /**
  93496. * Define an offset for the position of the ellipsoid around the camera.
  93497. * This can be helpful if the camera is attached away from the player's body center,
  93498. * such as at its head.
  93499. */
  93500. ellipsoidOffset: Vector3;
  93501. /**
  93502. * Enable or disable collisions of the camera with the rest of the scene objects.
  93503. */
  93504. checkCollisions: boolean;
  93505. /**
  93506. * Enable or disable gravity on the camera.
  93507. */
  93508. applyGravity: boolean;
  93509. /**
  93510. * Define the current direction the camera is moving to.
  93511. */
  93512. cameraDirection: Vector3;
  93513. /**
  93514. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93515. * This overrides and empties cameraRotation.
  93516. */
  93517. rotationQuaternion: Quaternion;
  93518. /**
  93519. * Track Roll to maintain the wanted Rolling when looking around.
  93520. */
  93521. _trackRoll: number;
  93522. /**
  93523. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93524. */
  93525. rollCorrect: number;
  93526. /**
  93527. * Mimic a banked turn, Rolling the camera when Yawing.
  93528. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93529. */
  93530. bankedTurn: boolean;
  93531. /**
  93532. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93533. */
  93534. bankedTurnLimit: number;
  93535. /**
  93536. * Value of 0 disables the banked Roll.
  93537. * Value of 1 is equal to the Yaw angle in radians.
  93538. */
  93539. bankedTurnMultiplier: number;
  93540. /**
  93541. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93542. */
  93543. inputs: FlyCameraInputsManager;
  93544. /**
  93545. * Gets the input sensibility for mouse input.
  93546. * Higher values reduce sensitivity.
  93547. */
  93548. /**
  93549. * Sets the input sensibility for a mouse input.
  93550. * Higher values reduce sensitivity.
  93551. */
  93552. angularSensibility: number;
  93553. /**
  93554. * Get the keys for camera movement forward.
  93555. */
  93556. /**
  93557. * Set the keys for camera movement forward.
  93558. */
  93559. keysForward: number[];
  93560. /**
  93561. * Get the keys for camera movement backward.
  93562. */
  93563. keysBackward: number[];
  93564. /**
  93565. * Get the keys for camera movement up.
  93566. */
  93567. /**
  93568. * Set the keys for camera movement up.
  93569. */
  93570. keysUp: number[];
  93571. /**
  93572. * Get the keys for camera movement down.
  93573. */
  93574. /**
  93575. * Set the keys for camera movement down.
  93576. */
  93577. keysDown: number[];
  93578. /**
  93579. * Get the keys for camera movement left.
  93580. */
  93581. /**
  93582. * Set the keys for camera movement left.
  93583. */
  93584. keysLeft: number[];
  93585. /**
  93586. * Set the keys for camera movement right.
  93587. */
  93588. /**
  93589. * Set the keys for camera movement right.
  93590. */
  93591. keysRight: number[];
  93592. /**
  93593. * Event raised when the camera collides with a mesh in the scene.
  93594. */
  93595. onCollide: (collidedMesh: AbstractMesh) => void;
  93596. private _collider;
  93597. private _needMoveForGravity;
  93598. private _oldPosition;
  93599. private _diffPosition;
  93600. private _newPosition;
  93601. /** @hidden */
  93602. _localDirection: Vector3;
  93603. /** @hidden */
  93604. _transformedDirection: Vector3;
  93605. /**
  93606. * Instantiates a FlyCamera.
  93607. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93608. * such as in a 3D Space Shooter or a Flight Simulator.
  93609. * @param name Define the name of the camera in the scene.
  93610. * @param position Define the starting position of the camera in the scene.
  93611. * @param scene Define the scene the camera belongs to.
  93612. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93613. */
  93614. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93615. /**
  93616. * Attach a control to the HTML DOM element.
  93617. * @param element Defines the element that listens to the input events.
  93618. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93619. */
  93620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93621. /**
  93622. * Detach a control from the HTML DOM element.
  93623. * The camera will stop reacting to that input.
  93624. * @param element Defines the element that listens to the input events.
  93625. */
  93626. detachControl(element: HTMLElement): void;
  93627. private _collisionMask;
  93628. /**
  93629. * Get the mask that the camera ignores in collision events.
  93630. */
  93631. /**
  93632. * Set the mask that the camera ignores in collision events.
  93633. */
  93634. collisionMask: number;
  93635. /** @hidden */
  93636. _collideWithWorld(displacement: Vector3): void;
  93637. /** @hidden */
  93638. private _onCollisionPositionChange;
  93639. /** @hidden */
  93640. _checkInputs(): void;
  93641. /** @hidden */
  93642. _decideIfNeedsToMove(): boolean;
  93643. /** @hidden */
  93644. _updatePosition(): void;
  93645. /**
  93646. * Restore the Roll to its target value at the rate specified.
  93647. * @param rate - Higher means slower restoring.
  93648. * @hidden
  93649. */
  93650. restoreRoll(rate: number): void;
  93651. /**
  93652. * Destroy the camera and release the current resources held by it.
  93653. */
  93654. dispose(): void;
  93655. /**
  93656. * Get the current object class name.
  93657. * @returns the class name.
  93658. */
  93659. getClassName(): string;
  93660. }
  93661. }
  93662. declare module BABYLON {
  93663. /**
  93664. * Listen to keyboard events to control the camera.
  93665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93666. */
  93667. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93668. /**
  93669. * Defines the camera the input is attached to.
  93670. */
  93671. camera: FlyCamera;
  93672. /**
  93673. * The list of keyboard keys used to control the forward move of the camera.
  93674. */
  93675. keysForward: number[];
  93676. /**
  93677. * The list of keyboard keys used to control the backward move of the camera.
  93678. */
  93679. keysBackward: number[];
  93680. /**
  93681. * The list of keyboard keys used to control the forward move of the camera.
  93682. */
  93683. keysUp: number[];
  93684. /**
  93685. * The list of keyboard keys used to control the backward move of the camera.
  93686. */
  93687. keysDown: number[];
  93688. /**
  93689. * The list of keyboard keys used to control the right strafe move of the camera.
  93690. */
  93691. keysRight: number[];
  93692. /**
  93693. * The list of keyboard keys used to control the left strafe move of the camera.
  93694. */
  93695. keysLeft: number[];
  93696. private _keys;
  93697. private _onCanvasBlurObserver;
  93698. private _onKeyboardObserver;
  93699. private _engine;
  93700. private _scene;
  93701. /**
  93702. * Attach the input controls to a specific dom element to get the input from.
  93703. * @param element Defines the element the controls should be listened from
  93704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93705. */
  93706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93707. /**
  93708. * Detach the current controls from the specified dom element.
  93709. * @param element Defines the element to stop listening the inputs from
  93710. */
  93711. detachControl(element: Nullable<HTMLElement>): void;
  93712. /**
  93713. * Gets the class name of the current intput.
  93714. * @returns the class name
  93715. */
  93716. getClassName(): string;
  93717. /** @hidden */
  93718. _onLostFocus(e: FocusEvent): void;
  93719. /**
  93720. * Get the friendly name associated with the input class.
  93721. * @returns the input friendly name
  93722. */
  93723. getSimpleName(): string;
  93724. /**
  93725. * Update the current camera state depending on the inputs that have been used this frame.
  93726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93727. */
  93728. checkInputs(): void;
  93729. }
  93730. }
  93731. declare module BABYLON {
  93732. /**
  93733. * Manage the mouse wheel inputs to control a follow camera.
  93734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93735. */
  93736. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93737. /**
  93738. * Defines the camera the input is attached to.
  93739. */
  93740. camera: FollowCamera;
  93741. /**
  93742. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93743. */
  93744. axisControlRadius: boolean;
  93745. /**
  93746. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93747. */
  93748. axisControlHeight: boolean;
  93749. /**
  93750. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93751. */
  93752. axisControlRotation: boolean;
  93753. /**
  93754. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93755. * relation to mouseWheel events.
  93756. */
  93757. wheelPrecision: number;
  93758. /**
  93759. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93760. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93761. */
  93762. wheelDeltaPercentage: number;
  93763. private _wheel;
  93764. private _observer;
  93765. /**
  93766. * Attach the input controls to a specific dom element to get the input from.
  93767. * @param element Defines the element the controls should be listened from
  93768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93769. */
  93770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93771. /**
  93772. * Detach the current controls from the specified dom element.
  93773. * @param element Defines the element to stop listening the inputs from
  93774. */
  93775. detachControl(element: Nullable<HTMLElement>): void;
  93776. /**
  93777. * Gets the class name of the current intput.
  93778. * @returns the class name
  93779. */
  93780. getClassName(): string;
  93781. /**
  93782. * Get the friendly name associated with the input class.
  93783. * @returns the input friendly name
  93784. */
  93785. getSimpleName(): string;
  93786. }
  93787. }
  93788. declare module BABYLON {
  93789. /**
  93790. * Manage the pointers inputs to control an follow camera.
  93791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93792. */
  93793. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93794. /**
  93795. * Defines the camera the input is attached to.
  93796. */
  93797. camera: FollowCamera;
  93798. /**
  93799. * Gets the class name of the current input.
  93800. * @returns the class name
  93801. */
  93802. getClassName(): string;
  93803. /**
  93804. * Defines the pointer angular sensibility along the X axis or how fast is
  93805. * the camera rotating.
  93806. * A negative number will reverse the axis direction.
  93807. */
  93808. angularSensibilityX: number;
  93809. /**
  93810. * Defines the pointer angular sensibility along the Y axis or how fast is
  93811. * the camera rotating.
  93812. * A negative number will reverse the axis direction.
  93813. */
  93814. angularSensibilityY: number;
  93815. /**
  93816. * Defines the pointer pinch precision or how fast is the camera zooming.
  93817. * A negative number will reverse the axis direction.
  93818. */
  93819. pinchPrecision: number;
  93820. /**
  93821. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93822. * from 0.
  93823. * It defines the percentage of current camera.radius to use as delta when
  93824. * pinch zoom is used.
  93825. */
  93826. pinchDeltaPercentage: number;
  93827. /**
  93828. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93829. */
  93830. axisXControlRadius: boolean;
  93831. /**
  93832. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93833. */
  93834. axisXControlHeight: boolean;
  93835. /**
  93836. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93837. */
  93838. axisXControlRotation: boolean;
  93839. /**
  93840. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93841. */
  93842. axisYControlRadius: boolean;
  93843. /**
  93844. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93845. */
  93846. axisYControlHeight: boolean;
  93847. /**
  93848. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93849. */
  93850. axisYControlRotation: boolean;
  93851. /**
  93852. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93853. */
  93854. axisPinchControlRadius: boolean;
  93855. /**
  93856. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93857. */
  93858. axisPinchControlHeight: boolean;
  93859. /**
  93860. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93861. */
  93862. axisPinchControlRotation: boolean;
  93863. /**
  93864. * Log error messages if basic misconfiguration has occurred.
  93865. */
  93866. warningEnable: boolean;
  93867. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93868. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93869. private _warningCounter;
  93870. private _warning;
  93871. }
  93872. }
  93873. declare module BABYLON {
  93874. /**
  93875. * Default Inputs manager for the FollowCamera.
  93876. * It groups all the default supported inputs for ease of use.
  93877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93878. */
  93879. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93880. /**
  93881. * Instantiates a new FollowCameraInputsManager.
  93882. * @param camera Defines the camera the inputs belong to
  93883. */
  93884. constructor(camera: FollowCamera);
  93885. /**
  93886. * Add keyboard input support to the input manager.
  93887. * @returns the current input manager
  93888. */
  93889. addKeyboard(): FollowCameraInputsManager;
  93890. /**
  93891. * Add mouse wheel input support to the input manager.
  93892. * @returns the current input manager
  93893. */
  93894. addMouseWheel(): FollowCameraInputsManager;
  93895. /**
  93896. * Add pointers input support to the input manager.
  93897. * @returns the current input manager
  93898. */
  93899. addPointers(): FollowCameraInputsManager;
  93900. /**
  93901. * Add orientation input support to the input manager.
  93902. * @returns the current input manager
  93903. */
  93904. addVRDeviceOrientation(): FollowCameraInputsManager;
  93905. }
  93906. }
  93907. declare module BABYLON {
  93908. /**
  93909. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93910. * an arc rotate version arcFollowCamera are available.
  93911. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93912. */
  93913. export class FollowCamera extends TargetCamera {
  93914. /**
  93915. * Distance the follow camera should follow an object at
  93916. */
  93917. radius: number;
  93918. /**
  93919. * Minimum allowed distance of the camera to the axis of rotation
  93920. * (The camera can not get closer).
  93921. * This can help limiting how the Camera is able to move in the scene.
  93922. */
  93923. lowerRadiusLimit: Nullable<number>;
  93924. /**
  93925. * Maximum allowed distance of the camera to the axis of rotation
  93926. * (The camera can not get further).
  93927. * This can help limiting how the Camera is able to move in the scene.
  93928. */
  93929. upperRadiusLimit: Nullable<number>;
  93930. /**
  93931. * Define a rotation offset between the camera and the object it follows
  93932. */
  93933. rotationOffset: number;
  93934. /**
  93935. * Minimum allowed angle to camera position relative to target object.
  93936. * This can help limiting how the Camera is able to move in the scene.
  93937. */
  93938. lowerRotationOffsetLimit: Nullable<number>;
  93939. /**
  93940. * Maximum allowed angle to camera position relative to target object.
  93941. * This can help limiting how the Camera is able to move in the scene.
  93942. */
  93943. upperRotationOffsetLimit: Nullable<number>;
  93944. /**
  93945. * Define a height offset between the camera and the object it follows.
  93946. * It can help following an object from the top (like a car chaing a plane)
  93947. */
  93948. heightOffset: number;
  93949. /**
  93950. * Minimum allowed height of camera position relative to target object.
  93951. * This can help limiting how the Camera is able to move in the scene.
  93952. */
  93953. lowerHeightOffsetLimit: Nullable<number>;
  93954. /**
  93955. * Maximum allowed height of camera position relative to target object.
  93956. * This can help limiting how the Camera is able to move in the scene.
  93957. */
  93958. upperHeightOffsetLimit: Nullable<number>;
  93959. /**
  93960. * Define how fast the camera can accelerate to follow it s target.
  93961. */
  93962. cameraAcceleration: number;
  93963. /**
  93964. * Define the speed limit of the camera following an object.
  93965. */
  93966. maxCameraSpeed: number;
  93967. /**
  93968. * Define the target of the camera.
  93969. */
  93970. lockedTarget: Nullable<AbstractMesh>;
  93971. /**
  93972. * Defines the input associated with the camera.
  93973. */
  93974. inputs: FollowCameraInputsManager;
  93975. /**
  93976. * Instantiates the follow camera.
  93977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93978. * @param name Define the name of the camera in the scene
  93979. * @param position Define the position of the camera
  93980. * @param scene Define the scene the camera belong to
  93981. * @param lockedTarget Define the target of the camera
  93982. */
  93983. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93984. private _follow;
  93985. /**
  93986. * Attached controls to the current camera.
  93987. * @param element Defines the element the controls should be listened from
  93988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93989. */
  93990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93991. /**
  93992. * Detach the current controls from the camera.
  93993. * The camera will stop reacting to inputs.
  93994. * @param element Defines the element to stop listening the inputs from
  93995. */
  93996. detachControl(element: HTMLElement): void;
  93997. /** @hidden */
  93998. _checkInputs(): void;
  93999. private _checkLimits;
  94000. /**
  94001. * Gets the camera class name.
  94002. * @returns the class name
  94003. */
  94004. getClassName(): string;
  94005. }
  94006. /**
  94007. * Arc Rotate version of the follow camera.
  94008. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94009. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94010. */
  94011. export class ArcFollowCamera extends TargetCamera {
  94012. /** The longitudinal angle of the camera */
  94013. alpha: number;
  94014. /** The latitudinal angle of the camera */
  94015. beta: number;
  94016. /** The radius of the camera from its target */
  94017. radius: number;
  94018. /** Define the camera target (the messh it should follow) */
  94019. target: Nullable<AbstractMesh>;
  94020. private _cartesianCoordinates;
  94021. /**
  94022. * Instantiates a new ArcFollowCamera
  94023. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94024. * @param name Define the name of the camera
  94025. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94026. * @param beta Define the rotation angle of the camera around the elevation axis
  94027. * @param radius Define the radius of the camera from its target point
  94028. * @param target Define the target of the camera
  94029. * @param scene Define the scene the camera belongs to
  94030. */
  94031. constructor(name: string,
  94032. /** The longitudinal angle of the camera */
  94033. alpha: number,
  94034. /** The latitudinal angle of the camera */
  94035. beta: number,
  94036. /** The radius of the camera from its target */
  94037. radius: number,
  94038. /** Define the camera target (the messh it should follow) */
  94039. target: Nullable<AbstractMesh>, scene: Scene);
  94040. private _follow;
  94041. /** @hidden */
  94042. _checkInputs(): void;
  94043. /**
  94044. * Returns the class name of the object.
  94045. * It is mostly used internally for serialization purposes.
  94046. */
  94047. getClassName(): string;
  94048. }
  94049. }
  94050. declare module BABYLON {
  94051. /**
  94052. * Manage the keyboard inputs to control the movement of a follow camera.
  94053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94054. */
  94055. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  94056. /**
  94057. * Defines the camera the input is attached to.
  94058. */
  94059. camera: FollowCamera;
  94060. /**
  94061. * Defines the list of key codes associated with the up action (increase heightOffset)
  94062. */
  94063. keysHeightOffsetIncr: number[];
  94064. /**
  94065. * Defines the list of key codes associated with the down action (decrease heightOffset)
  94066. */
  94067. keysHeightOffsetDecr: number[];
  94068. /**
  94069. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  94070. */
  94071. keysHeightOffsetModifierAlt: boolean;
  94072. /**
  94073. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  94074. */
  94075. keysHeightOffsetModifierCtrl: boolean;
  94076. /**
  94077. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  94078. */
  94079. keysHeightOffsetModifierShift: boolean;
  94080. /**
  94081. * Defines the list of key codes associated with the left action (increase rotationOffset)
  94082. */
  94083. keysRotationOffsetIncr: number[];
  94084. /**
  94085. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  94086. */
  94087. keysRotationOffsetDecr: number[];
  94088. /**
  94089. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  94090. */
  94091. keysRotationOffsetModifierAlt: boolean;
  94092. /**
  94093. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  94094. */
  94095. keysRotationOffsetModifierCtrl: boolean;
  94096. /**
  94097. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  94098. */
  94099. keysRotationOffsetModifierShift: boolean;
  94100. /**
  94101. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  94102. */
  94103. keysRadiusIncr: number[];
  94104. /**
  94105. * Defines the list of key codes associated with the zoom-out action (increase radius)
  94106. */
  94107. keysRadiusDecr: number[];
  94108. /**
  94109. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  94110. */
  94111. keysRadiusModifierAlt: boolean;
  94112. /**
  94113. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  94114. */
  94115. keysRadiusModifierCtrl: boolean;
  94116. /**
  94117. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  94118. */
  94119. keysRadiusModifierShift: boolean;
  94120. /**
  94121. * Defines the rate of change of heightOffset.
  94122. */
  94123. heightSensibility: number;
  94124. /**
  94125. * Defines the rate of change of rotationOffset.
  94126. */
  94127. rotationSensibility: number;
  94128. /**
  94129. * Defines the rate of change of radius.
  94130. */
  94131. radiusSensibility: number;
  94132. private _keys;
  94133. private _ctrlPressed;
  94134. private _altPressed;
  94135. private _shiftPressed;
  94136. private _onCanvasBlurObserver;
  94137. private _onKeyboardObserver;
  94138. private _engine;
  94139. private _scene;
  94140. /**
  94141. * Attach the input controls to a specific dom element to get the input from.
  94142. * @param element Defines the element the controls should be listened from
  94143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94144. */
  94145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94146. /**
  94147. * Detach the current controls from the specified dom element.
  94148. * @param element Defines the element to stop listening the inputs from
  94149. */
  94150. detachControl(element: Nullable<HTMLElement>): void;
  94151. /**
  94152. * Update the current camera state depending on the inputs that have been used this frame.
  94153. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94154. */
  94155. checkInputs(): void;
  94156. /**
  94157. * Gets the class name of the current input.
  94158. * @returns the class name
  94159. */
  94160. getClassName(): string;
  94161. /**
  94162. * Get the friendly name associated with the input class.
  94163. * @returns the input friendly name
  94164. */
  94165. getSimpleName(): string;
  94166. /**
  94167. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94168. * allow modification of the heightOffset value.
  94169. */
  94170. private _modifierHeightOffset;
  94171. /**
  94172. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94173. * allow modification of the rotationOffset value.
  94174. */
  94175. private _modifierRotationOffset;
  94176. /**
  94177. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94178. * allow modification of the radius value.
  94179. */
  94180. private _modifierRadius;
  94181. }
  94182. }
  94183. declare module BABYLON {
  94184. interface FreeCameraInputsManager {
  94185. /**
  94186. * Add orientation input support to the input manager.
  94187. * @returns the current input manager
  94188. */
  94189. addDeviceOrientation(): FreeCameraInputsManager;
  94190. }
  94191. /**
  94192. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  94193. * Screen rotation is taken into account.
  94194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94195. */
  94196. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  94197. private _camera;
  94198. private _screenOrientationAngle;
  94199. private _constantTranform;
  94200. private _screenQuaternion;
  94201. private _alpha;
  94202. private _beta;
  94203. private _gamma;
  94204. /**
  94205. * Instantiates a new input
  94206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94207. */
  94208. constructor();
  94209. /**
  94210. * Define the camera controlled by the input.
  94211. */
  94212. camera: FreeCamera;
  94213. /**
  94214. * Attach the input controls to a specific dom element to get the input from.
  94215. * @param element Defines the element the controls should be listened from
  94216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94217. */
  94218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94219. private _orientationChanged;
  94220. private _deviceOrientation;
  94221. /**
  94222. * Detach the current controls from the specified dom element.
  94223. * @param element Defines the element to stop listening the inputs from
  94224. */
  94225. detachControl(element: Nullable<HTMLElement>): void;
  94226. /**
  94227. * Update the current camera state depending on the inputs that have been used this frame.
  94228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94229. */
  94230. checkInputs(): void;
  94231. /**
  94232. * Gets the class name of the current intput.
  94233. * @returns the class name
  94234. */
  94235. getClassName(): string;
  94236. /**
  94237. * Get the friendly name associated with the input class.
  94238. * @returns the input friendly name
  94239. */
  94240. getSimpleName(): string;
  94241. }
  94242. }
  94243. declare module BABYLON {
  94244. /**
  94245. * Manage the gamepad inputs to control a free camera.
  94246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94247. */
  94248. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  94249. /**
  94250. * Define the camera the input is attached to.
  94251. */
  94252. camera: FreeCamera;
  94253. /**
  94254. * Define the Gamepad controlling the input
  94255. */
  94256. gamepad: Nullable<Gamepad>;
  94257. /**
  94258. * Defines the gamepad rotation sensiblity.
  94259. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94260. */
  94261. gamepadAngularSensibility: number;
  94262. /**
  94263. * Defines the gamepad move sensiblity.
  94264. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94265. */
  94266. gamepadMoveSensibility: number;
  94267. private _onGamepadConnectedObserver;
  94268. private _onGamepadDisconnectedObserver;
  94269. private _cameraTransform;
  94270. private _deltaTransform;
  94271. private _vector3;
  94272. private _vector2;
  94273. /**
  94274. * Attach the input controls to a specific dom element to get the input from.
  94275. * @param element Defines the element the controls should be listened from
  94276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94277. */
  94278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94279. /**
  94280. * Detach the current controls from the specified dom element.
  94281. * @param element Defines the element to stop listening the inputs from
  94282. */
  94283. detachControl(element: Nullable<HTMLElement>): void;
  94284. /**
  94285. * Update the current camera state depending on the inputs that have been used this frame.
  94286. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94287. */
  94288. checkInputs(): void;
  94289. /**
  94290. * Gets the class name of the current intput.
  94291. * @returns the class name
  94292. */
  94293. getClassName(): string;
  94294. /**
  94295. * Get the friendly name associated with the input class.
  94296. * @returns the input friendly name
  94297. */
  94298. getSimpleName(): string;
  94299. }
  94300. }
  94301. declare module BABYLON {
  94302. /**
  94303. * Defines the potential axis of a Joystick
  94304. */
  94305. export enum JoystickAxis {
  94306. /** X axis */
  94307. X = 0,
  94308. /** Y axis */
  94309. Y = 1,
  94310. /** Z axis */
  94311. Z = 2
  94312. }
  94313. /**
  94314. * Class used to define virtual joystick (used in touch mode)
  94315. */
  94316. export class VirtualJoystick {
  94317. /**
  94318. * Gets or sets a boolean indicating that left and right values must be inverted
  94319. */
  94320. reverseLeftRight: boolean;
  94321. /**
  94322. * Gets or sets a boolean indicating that up and down values must be inverted
  94323. */
  94324. reverseUpDown: boolean;
  94325. /**
  94326. * Gets the offset value for the position (ie. the change of the position value)
  94327. */
  94328. deltaPosition: Vector3;
  94329. /**
  94330. * Gets a boolean indicating if the virtual joystick was pressed
  94331. */
  94332. pressed: boolean;
  94333. /**
  94334. * Canvas the virtual joystick will render onto, default z-index of this is 5
  94335. */
  94336. static Canvas: Nullable<HTMLCanvasElement>;
  94337. private static _globalJoystickIndex;
  94338. private static vjCanvasContext;
  94339. private static vjCanvasWidth;
  94340. private static vjCanvasHeight;
  94341. private static halfWidth;
  94342. private _action;
  94343. private _axisTargetedByLeftAndRight;
  94344. private _axisTargetedByUpAndDown;
  94345. private _joystickSensibility;
  94346. private _inversedSensibility;
  94347. private _joystickPointerID;
  94348. private _joystickColor;
  94349. private _joystickPointerPos;
  94350. private _joystickPreviousPointerPos;
  94351. private _joystickPointerStartPos;
  94352. private _deltaJoystickVector;
  94353. private _leftJoystick;
  94354. private _touches;
  94355. private _onPointerDownHandlerRef;
  94356. private _onPointerMoveHandlerRef;
  94357. private _onPointerUpHandlerRef;
  94358. private _onResize;
  94359. /**
  94360. * Creates a new virtual joystick
  94361. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94362. */
  94363. constructor(leftJoystick?: boolean);
  94364. /**
  94365. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94366. * @param newJoystickSensibility defines the new sensibility
  94367. */
  94368. setJoystickSensibility(newJoystickSensibility: number): void;
  94369. private _onPointerDown;
  94370. private _onPointerMove;
  94371. private _onPointerUp;
  94372. /**
  94373. * Change the color of the virtual joystick
  94374. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94375. */
  94376. setJoystickColor(newColor: string): void;
  94377. /**
  94378. * Defines a callback to call when the joystick is touched
  94379. * @param action defines the callback
  94380. */
  94381. setActionOnTouch(action: () => any): void;
  94382. /**
  94383. * Defines which axis you'd like to control for left & right
  94384. * @param axis defines the axis to use
  94385. */
  94386. setAxisForLeftRight(axis: JoystickAxis): void;
  94387. /**
  94388. * Defines which axis you'd like to control for up & down
  94389. * @param axis defines the axis to use
  94390. */
  94391. setAxisForUpDown(axis: JoystickAxis): void;
  94392. private _drawVirtualJoystick;
  94393. /**
  94394. * Release internal HTML canvas
  94395. */
  94396. releaseCanvas(): void;
  94397. }
  94398. }
  94399. declare module BABYLON {
  94400. interface FreeCameraInputsManager {
  94401. /**
  94402. * Add virtual joystick input support to the input manager.
  94403. * @returns the current input manager
  94404. */
  94405. addVirtualJoystick(): FreeCameraInputsManager;
  94406. }
  94407. /**
  94408. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94410. */
  94411. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94412. /**
  94413. * Defines the camera the input is attached to.
  94414. */
  94415. camera: FreeCamera;
  94416. private _leftjoystick;
  94417. private _rightjoystick;
  94418. /**
  94419. * Gets the left stick of the virtual joystick.
  94420. * @returns The virtual Joystick
  94421. */
  94422. getLeftJoystick(): VirtualJoystick;
  94423. /**
  94424. * Gets the right stick of the virtual joystick.
  94425. * @returns The virtual Joystick
  94426. */
  94427. getRightJoystick(): VirtualJoystick;
  94428. /**
  94429. * Update the current camera state depending on the inputs that have been used this frame.
  94430. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94431. */
  94432. checkInputs(): void;
  94433. /**
  94434. * Attach the input controls to a specific dom element to get the input from.
  94435. * @param element Defines the element the controls should be listened from
  94436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94437. */
  94438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94439. /**
  94440. * Detach the current controls from the specified dom element.
  94441. * @param element Defines the element to stop listening the inputs from
  94442. */
  94443. detachControl(element: Nullable<HTMLElement>): void;
  94444. /**
  94445. * Gets the class name of the current intput.
  94446. * @returns the class name
  94447. */
  94448. getClassName(): string;
  94449. /**
  94450. * Get the friendly name associated with the input class.
  94451. * @returns the input friendly name
  94452. */
  94453. getSimpleName(): string;
  94454. }
  94455. }
  94456. declare module BABYLON {
  94457. /**
  94458. * This represents a FPS type of camera controlled by touch.
  94459. * This is like a universal camera minus the Gamepad controls.
  94460. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94461. */
  94462. export class TouchCamera extends FreeCamera {
  94463. /**
  94464. * Defines the touch sensibility for rotation.
  94465. * The higher the faster.
  94466. */
  94467. touchAngularSensibility: number;
  94468. /**
  94469. * Defines the touch sensibility for move.
  94470. * The higher the faster.
  94471. */
  94472. touchMoveSensibility: number;
  94473. /**
  94474. * Instantiates a new touch camera.
  94475. * This represents a FPS type of camera controlled by touch.
  94476. * This is like a universal camera minus the Gamepad controls.
  94477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94478. * @param name Define the name of the camera in the scene
  94479. * @param position Define the start position of the camera in the scene
  94480. * @param scene Define the scene the camera belongs to
  94481. */
  94482. constructor(name: string, position: Vector3, scene: Scene);
  94483. /**
  94484. * Gets the current object class name.
  94485. * @return the class name
  94486. */
  94487. getClassName(): string;
  94488. /** @hidden */
  94489. _setupInputs(): void;
  94490. }
  94491. }
  94492. declare module BABYLON {
  94493. /**
  94494. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94495. * being tilted forward or back and left or right.
  94496. */
  94497. export class DeviceOrientationCamera extends FreeCamera {
  94498. private _initialQuaternion;
  94499. private _quaternionCache;
  94500. /**
  94501. * Creates a new device orientation camera
  94502. * @param name The name of the camera
  94503. * @param position The start position camera
  94504. * @param scene The scene the camera belongs to
  94505. */
  94506. constructor(name: string, position: Vector3, scene: Scene);
  94507. /**
  94508. * Gets the current instance class name ("DeviceOrientationCamera").
  94509. * This helps avoiding instanceof at run time.
  94510. * @returns the class name
  94511. */
  94512. getClassName(): string;
  94513. /**
  94514. * @hidden
  94515. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94516. */
  94517. _checkInputs(): void;
  94518. /**
  94519. * Reset the camera to its default orientation on the specified axis only.
  94520. * @param axis The axis to reset
  94521. */
  94522. resetToCurrentRotation(axis?: Axis): void;
  94523. }
  94524. }
  94525. declare module BABYLON {
  94526. /**
  94527. * 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,
  94528. * which still works and will still be found in many Playgrounds.
  94529. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94530. */
  94531. export class UniversalCamera extends TouchCamera {
  94532. /**
  94533. * Defines the gamepad rotation sensiblity.
  94534. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94535. */
  94536. gamepadAngularSensibility: number;
  94537. /**
  94538. * Defines the gamepad move sensiblity.
  94539. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94540. */
  94541. gamepadMoveSensibility: number;
  94542. /**
  94543. * 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,
  94544. * which still works and will still be found in many Playgrounds.
  94545. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94546. * @param name Define the name of the camera in the scene
  94547. * @param position Define the start position of the camera in the scene
  94548. * @param scene Define the scene the camera belongs to
  94549. */
  94550. constructor(name: string, position: Vector3, scene: Scene);
  94551. /**
  94552. * Gets the current object class name.
  94553. * @return the class name
  94554. */
  94555. getClassName(): string;
  94556. }
  94557. }
  94558. declare module BABYLON {
  94559. /**
  94560. * This represents a FPS type of camera. This is only here for back compat purpose.
  94561. * Please use the UniversalCamera instead as both are identical.
  94562. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94563. */
  94564. export class GamepadCamera extends UniversalCamera {
  94565. /**
  94566. * Instantiates a new Gamepad Camera
  94567. * This represents a FPS type of camera. This is only here for back compat purpose.
  94568. * Please use the UniversalCamera instead as both are identical.
  94569. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94570. * @param name Define the name of the camera in the scene
  94571. * @param position Define the start position of the camera in the scene
  94572. * @param scene Define the scene the camera belongs to
  94573. */
  94574. constructor(name: string, position: Vector3, scene: Scene);
  94575. /**
  94576. * Gets the current object class name.
  94577. * @return the class name
  94578. */
  94579. getClassName(): string;
  94580. }
  94581. }
  94582. declare module BABYLON {
  94583. /** @hidden */
  94584. export var passPixelShader: {
  94585. name: string;
  94586. shader: string;
  94587. };
  94588. }
  94589. declare module BABYLON {
  94590. /** @hidden */
  94591. export var passCubePixelShader: {
  94592. name: string;
  94593. shader: string;
  94594. };
  94595. }
  94596. declare module BABYLON {
  94597. /**
  94598. * PassPostProcess which produces an output the same as it's input
  94599. */
  94600. export class PassPostProcess extends PostProcess {
  94601. /**
  94602. * Creates the PassPostProcess
  94603. * @param name The name of the effect.
  94604. * @param options The required width/height ratio to downsize to before computing the render pass.
  94605. * @param camera The camera to apply the render pass to.
  94606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94607. * @param engine The engine which the post process will be applied. (default: current engine)
  94608. * @param reusable If the post process can be reused on the same frame. (default: false)
  94609. * @param textureType The type of texture to be used when performing the post processing.
  94610. * @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)
  94611. */
  94612. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94613. }
  94614. /**
  94615. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94616. */
  94617. export class PassCubePostProcess extends PostProcess {
  94618. private _face;
  94619. /**
  94620. * Gets or sets the cube face to display.
  94621. * * 0 is +X
  94622. * * 1 is -X
  94623. * * 2 is +Y
  94624. * * 3 is -Y
  94625. * * 4 is +Z
  94626. * * 5 is -Z
  94627. */
  94628. face: number;
  94629. /**
  94630. * Creates the PassCubePostProcess
  94631. * @param name The name of the effect.
  94632. * @param options The required width/height ratio to downsize to before computing the render pass.
  94633. * @param camera The camera to apply the render pass to.
  94634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94635. * @param engine The engine which the post process will be applied. (default: current engine)
  94636. * @param reusable If the post process can be reused on the same frame. (default: false)
  94637. * @param textureType The type of texture to be used when performing the post processing.
  94638. * @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)
  94639. */
  94640. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94641. }
  94642. }
  94643. declare module BABYLON {
  94644. /** @hidden */
  94645. export var anaglyphPixelShader: {
  94646. name: string;
  94647. shader: string;
  94648. };
  94649. }
  94650. declare module BABYLON {
  94651. /**
  94652. * Postprocess used to generate anaglyphic rendering
  94653. */
  94654. export class AnaglyphPostProcess extends PostProcess {
  94655. private _passedProcess;
  94656. /**
  94657. * Creates a new AnaglyphPostProcess
  94658. * @param name defines postprocess name
  94659. * @param options defines creation options or target ratio scale
  94660. * @param rigCameras defines cameras using this postprocess
  94661. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94662. * @param engine defines hosting engine
  94663. * @param reusable defines if the postprocess will be reused multiple times per frame
  94664. */
  94665. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94666. }
  94667. }
  94668. declare module BABYLON {
  94669. /**
  94670. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94671. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94672. */
  94673. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94674. /**
  94675. * Creates a new AnaglyphArcRotateCamera
  94676. * @param name defines camera name
  94677. * @param alpha defines alpha angle (in radians)
  94678. * @param beta defines beta angle (in radians)
  94679. * @param radius defines radius
  94680. * @param target defines camera target
  94681. * @param interaxialDistance defines distance between each color axis
  94682. * @param scene defines the hosting scene
  94683. */
  94684. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94685. /**
  94686. * Gets camera class name
  94687. * @returns AnaglyphArcRotateCamera
  94688. */
  94689. getClassName(): string;
  94690. }
  94691. }
  94692. declare module BABYLON {
  94693. /**
  94694. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94695. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94696. */
  94697. export class AnaglyphFreeCamera extends FreeCamera {
  94698. /**
  94699. * Creates a new AnaglyphFreeCamera
  94700. * @param name defines camera name
  94701. * @param position defines initial position
  94702. * @param interaxialDistance defines distance between each color axis
  94703. * @param scene defines the hosting scene
  94704. */
  94705. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94706. /**
  94707. * Gets camera class name
  94708. * @returns AnaglyphFreeCamera
  94709. */
  94710. getClassName(): string;
  94711. }
  94712. }
  94713. declare module BABYLON {
  94714. /**
  94715. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94716. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94717. */
  94718. export class AnaglyphGamepadCamera extends GamepadCamera {
  94719. /**
  94720. * Creates a new AnaglyphGamepadCamera
  94721. * @param name defines camera name
  94722. * @param position defines initial position
  94723. * @param interaxialDistance defines distance between each color axis
  94724. * @param scene defines the hosting scene
  94725. */
  94726. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94727. /**
  94728. * Gets camera class name
  94729. * @returns AnaglyphGamepadCamera
  94730. */
  94731. getClassName(): string;
  94732. }
  94733. }
  94734. declare module BABYLON {
  94735. /**
  94736. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94737. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94738. */
  94739. export class AnaglyphUniversalCamera extends UniversalCamera {
  94740. /**
  94741. * Creates a new AnaglyphUniversalCamera
  94742. * @param name defines camera name
  94743. * @param position defines initial position
  94744. * @param interaxialDistance defines distance between each color axis
  94745. * @param scene defines the hosting scene
  94746. */
  94747. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94748. /**
  94749. * Gets camera class name
  94750. * @returns AnaglyphUniversalCamera
  94751. */
  94752. getClassName(): string;
  94753. }
  94754. }
  94755. declare module BABYLON {
  94756. /** @hidden */
  94757. export var stereoscopicInterlacePixelShader: {
  94758. name: string;
  94759. shader: string;
  94760. };
  94761. }
  94762. declare module BABYLON {
  94763. /**
  94764. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94765. */
  94766. export class StereoscopicInterlacePostProcess extends PostProcess {
  94767. private _stepSize;
  94768. private _passedProcess;
  94769. /**
  94770. * Initializes a StereoscopicInterlacePostProcess
  94771. * @param name The name of the effect.
  94772. * @param rigCameras The rig cameras to be appled to the post process
  94773. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94775. * @param engine The engine which the post process will be applied. (default: current engine)
  94776. * @param reusable If the post process can be reused on the same frame. (default: false)
  94777. */
  94778. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94779. }
  94780. }
  94781. declare module BABYLON {
  94782. /**
  94783. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94784. * @see http://doc.babylonjs.com/features/cameras
  94785. */
  94786. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94787. /**
  94788. * Creates a new StereoscopicArcRotateCamera
  94789. * @param name defines camera name
  94790. * @param alpha defines alpha angle (in radians)
  94791. * @param beta defines beta angle (in radians)
  94792. * @param radius defines radius
  94793. * @param target defines camera target
  94794. * @param interaxialDistance defines distance between each color axis
  94795. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94796. * @param scene defines the hosting scene
  94797. */
  94798. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94799. /**
  94800. * Gets camera class name
  94801. * @returns StereoscopicArcRotateCamera
  94802. */
  94803. getClassName(): string;
  94804. }
  94805. }
  94806. declare module BABYLON {
  94807. /**
  94808. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94809. * @see http://doc.babylonjs.com/features/cameras
  94810. */
  94811. export class StereoscopicFreeCamera extends FreeCamera {
  94812. /**
  94813. * Creates a new StereoscopicFreeCamera
  94814. * @param name defines camera name
  94815. * @param position defines initial position
  94816. * @param interaxialDistance defines distance between each color axis
  94817. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94818. * @param scene defines the hosting scene
  94819. */
  94820. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94821. /**
  94822. * Gets camera class name
  94823. * @returns StereoscopicFreeCamera
  94824. */
  94825. getClassName(): string;
  94826. }
  94827. }
  94828. declare module BABYLON {
  94829. /**
  94830. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94831. * @see http://doc.babylonjs.com/features/cameras
  94832. */
  94833. export class StereoscopicGamepadCamera extends GamepadCamera {
  94834. /**
  94835. * Creates a new StereoscopicGamepadCamera
  94836. * @param name defines camera name
  94837. * @param position defines initial position
  94838. * @param interaxialDistance defines distance between each color axis
  94839. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94840. * @param scene defines the hosting scene
  94841. */
  94842. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94843. /**
  94844. * Gets camera class name
  94845. * @returns StereoscopicGamepadCamera
  94846. */
  94847. getClassName(): string;
  94848. }
  94849. }
  94850. declare module BABYLON {
  94851. /**
  94852. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94853. * @see http://doc.babylonjs.com/features/cameras
  94854. */
  94855. export class StereoscopicUniversalCamera extends UniversalCamera {
  94856. /**
  94857. * Creates a new StereoscopicUniversalCamera
  94858. * @param name defines camera name
  94859. * @param position defines initial position
  94860. * @param interaxialDistance defines distance between each color axis
  94861. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94862. * @param scene defines the hosting scene
  94863. */
  94864. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94865. /**
  94866. * Gets camera class name
  94867. * @returns StereoscopicUniversalCamera
  94868. */
  94869. getClassName(): string;
  94870. }
  94871. }
  94872. declare module BABYLON {
  94873. /**
  94874. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94875. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94876. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94877. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94878. */
  94879. export class VirtualJoysticksCamera extends FreeCamera {
  94880. /**
  94881. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94882. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94883. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94884. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94885. * @param name Define the name of the camera in the scene
  94886. * @param position Define the start position of the camera in the scene
  94887. * @param scene Define the scene the camera belongs to
  94888. */
  94889. constructor(name: string, position: Vector3, scene: Scene);
  94890. /**
  94891. * Gets the current object class name.
  94892. * @return the class name
  94893. */
  94894. getClassName(): string;
  94895. }
  94896. }
  94897. declare module BABYLON {
  94898. /**
  94899. * This represents all the required metrics to create a VR camera.
  94900. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94901. */
  94902. export class VRCameraMetrics {
  94903. /**
  94904. * Define the horizontal resolution off the screen.
  94905. */
  94906. hResolution: number;
  94907. /**
  94908. * Define the vertical resolution off the screen.
  94909. */
  94910. vResolution: number;
  94911. /**
  94912. * Define the horizontal screen size.
  94913. */
  94914. hScreenSize: number;
  94915. /**
  94916. * Define the vertical screen size.
  94917. */
  94918. vScreenSize: number;
  94919. /**
  94920. * Define the vertical screen center position.
  94921. */
  94922. vScreenCenter: number;
  94923. /**
  94924. * Define the distance of the eyes to the screen.
  94925. */
  94926. eyeToScreenDistance: number;
  94927. /**
  94928. * Define the distance between both lenses
  94929. */
  94930. lensSeparationDistance: number;
  94931. /**
  94932. * Define the distance between both viewer's eyes.
  94933. */
  94934. interpupillaryDistance: number;
  94935. /**
  94936. * Define the distortion factor of the VR postprocess.
  94937. * Please, touch with care.
  94938. */
  94939. distortionK: number[];
  94940. /**
  94941. * Define the chromatic aberration correction factors for the VR post process.
  94942. */
  94943. chromaAbCorrection: number[];
  94944. /**
  94945. * Define the scale factor of the post process.
  94946. * The smaller the better but the slower.
  94947. */
  94948. postProcessScaleFactor: number;
  94949. /**
  94950. * Define an offset for the lens center.
  94951. */
  94952. lensCenterOffset: number;
  94953. /**
  94954. * Define if the current vr camera should compensate the distortion of the lense or not.
  94955. */
  94956. compensateDistortion: boolean;
  94957. /**
  94958. * Gets the rendering aspect ratio based on the provided resolutions.
  94959. */
  94960. readonly aspectRatio: number;
  94961. /**
  94962. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94963. */
  94964. readonly aspectRatioFov: number;
  94965. /**
  94966. * @hidden
  94967. */
  94968. readonly leftHMatrix: Matrix;
  94969. /**
  94970. * @hidden
  94971. */
  94972. readonly rightHMatrix: Matrix;
  94973. /**
  94974. * @hidden
  94975. */
  94976. readonly leftPreViewMatrix: Matrix;
  94977. /**
  94978. * @hidden
  94979. */
  94980. readonly rightPreViewMatrix: Matrix;
  94981. /**
  94982. * Get the default VRMetrics based on the most generic setup.
  94983. * @returns the default vr metrics
  94984. */
  94985. static GetDefault(): VRCameraMetrics;
  94986. }
  94987. }
  94988. declare module BABYLON {
  94989. /** @hidden */
  94990. export var vrDistortionCorrectionPixelShader: {
  94991. name: string;
  94992. shader: string;
  94993. };
  94994. }
  94995. declare module BABYLON {
  94996. /**
  94997. * VRDistortionCorrectionPostProcess used for mobile VR
  94998. */
  94999. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95000. private _isRightEye;
  95001. private _distortionFactors;
  95002. private _postProcessScaleFactor;
  95003. private _lensCenterOffset;
  95004. private _scaleIn;
  95005. private _scaleFactor;
  95006. private _lensCenter;
  95007. /**
  95008. * Initializes the VRDistortionCorrectionPostProcess
  95009. * @param name The name of the effect.
  95010. * @param camera The camera to apply the render pass to.
  95011. * @param isRightEye If this is for the right eye distortion
  95012. * @param vrMetrics All the required metrics for the VR camera
  95013. */
  95014. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95015. }
  95016. }
  95017. declare module BABYLON {
  95018. /**
  95019. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95020. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95021. */
  95022. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95023. /**
  95024. * Creates a new VRDeviceOrientationArcRotateCamera
  95025. * @param name defines camera name
  95026. * @param alpha defines the camera rotation along the logitudinal axis
  95027. * @param beta defines the camera rotation along the latitudinal axis
  95028. * @param radius defines the camera distance from its target
  95029. * @param target defines the camera target
  95030. * @param scene defines the scene the camera belongs to
  95031. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95032. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95033. */
  95034. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95035. /**
  95036. * Gets camera class name
  95037. * @returns VRDeviceOrientationArcRotateCamera
  95038. */
  95039. getClassName(): string;
  95040. }
  95041. }
  95042. declare module BABYLON {
  95043. /**
  95044. * Camera used to simulate VR rendering (based on FreeCamera)
  95045. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95046. */
  95047. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  95048. /**
  95049. * Creates a new VRDeviceOrientationFreeCamera
  95050. * @param name defines camera name
  95051. * @param position defines the start position of the camera
  95052. * @param scene defines the scene the camera belongs to
  95053. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95054. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95055. */
  95056. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95057. /**
  95058. * Gets camera class name
  95059. * @returns VRDeviceOrientationFreeCamera
  95060. */
  95061. getClassName(): string;
  95062. }
  95063. }
  95064. declare module BABYLON {
  95065. /**
  95066. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  95067. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95068. */
  95069. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  95070. /**
  95071. * Creates a new VRDeviceOrientationGamepadCamera
  95072. * @param name defines camera name
  95073. * @param position defines the start position of the camera
  95074. * @param scene defines the scene the camera belongs to
  95075. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95076. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95077. */
  95078. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95079. /**
  95080. * Gets camera class name
  95081. * @returns VRDeviceOrientationGamepadCamera
  95082. */
  95083. getClassName(): string;
  95084. }
  95085. }
  95086. declare module BABYLON {
  95087. /**
  95088. * Defines supported buttons for XBox360 compatible gamepads
  95089. */
  95090. export enum Xbox360Button {
  95091. /** A */
  95092. A = 0,
  95093. /** B */
  95094. B = 1,
  95095. /** X */
  95096. X = 2,
  95097. /** Y */
  95098. Y = 3,
  95099. /** Start */
  95100. Start = 4,
  95101. /** Back */
  95102. Back = 5,
  95103. /** Left button */
  95104. LB = 6,
  95105. /** Right button */
  95106. RB = 7,
  95107. /** Left stick */
  95108. LeftStick = 8,
  95109. /** Right stick */
  95110. RightStick = 9
  95111. }
  95112. /** Defines values for XBox360 DPad */
  95113. export enum Xbox360Dpad {
  95114. /** Up */
  95115. Up = 0,
  95116. /** Down */
  95117. Down = 1,
  95118. /** Left */
  95119. Left = 2,
  95120. /** Right */
  95121. Right = 3
  95122. }
  95123. /**
  95124. * Defines a XBox360 gamepad
  95125. */
  95126. export class Xbox360Pad extends Gamepad {
  95127. private _leftTrigger;
  95128. private _rightTrigger;
  95129. private _onlefttriggerchanged;
  95130. private _onrighttriggerchanged;
  95131. private _onbuttondown;
  95132. private _onbuttonup;
  95133. private _ondpaddown;
  95134. private _ondpadup;
  95135. /** Observable raised when a button is pressed */
  95136. onButtonDownObservable: Observable<Xbox360Button>;
  95137. /** Observable raised when a button is released */
  95138. onButtonUpObservable: Observable<Xbox360Button>;
  95139. /** Observable raised when a pad is pressed */
  95140. onPadDownObservable: Observable<Xbox360Dpad>;
  95141. /** Observable raised when a pad is released */
  95142. onPadUpObservable: Observable<Xbox360Dpad>;
  95143. private _buttonA;
  95144. private _buttonB;
  95145. private _buttonX;
  95146. private _buttonY;
  95147. private _buttonBack;
  95148. private _buttonStart;
  95149. private _buttonLB;
  95150. private _buttonRB;
  95151. private _buttonLeftStick;
  95152. private _buttonRightStick;
  95153. private _dPadUp;
  95154. private _dPadDown;
  95155. private _dPadLeft;
  95156. private _dPadRight;
  95157. private _isXboxOnePad;
  95158. /**
  95159. * Creates a new XBox360 gamepad object
  95160. * @param id defines the id of this gamepad
  95161. * @param index defines its index
  95162. * @param gamepad defines the internal HTML gamepad object
  95163. * @param xboxOne defines if it is a XBox One gamepad
  95164. */
  95165. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95166. /**
  95167. * Defines the callback to call when left trigger is pressed
  95168. * @param callback defines the callback to use
  95169. */
  95170. onlefttriggerchanged(callback: (value: number) => void): void;
  95171. /**
  95172. * Defines the callback to call when right trigger is pressed
  95173. * @param callback defines the callback to use
  95174. */
  95175. onrighttriggerchanged(callback: (value: number) => void): void;
  95176. /**
  95177. * Gets the left trigger value
  95178. */
  95179. /**
  95180. * Sets the left trigger value
  95181. */
  95182. leftTrigger: number;
  95183. /**
  95184. * Gets the right trigger value
  95185. */
  95186. /**
  95187. * Sets the right trigger value
  95188. */
  95189. rightTrigger: number;
  95190. /**
  95191. * Defines the callback to call when a button is pressed
  95192. * @param callback defines the callback to use
  95193. */
  95194. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  95195. /**
  95196. * Defines the callback to call when a button is released
  95197. * @param callback defines the callback to use
  95198. */
  95199. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  95200. /**
  95201. * Defines the callback to call when a pad is pressed
  95202. * @param callback defines the callback to use
  95203. */
  95204. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  95205. /**
  95206. * Defines the callback to call when a pad is released
  95207. * @param callback defines the callback to use
  95208. */
  95209. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  95210. private _setButtonValue;
  95211. private _setDPadValue;
  95212. /**
  95213. * Gets the value of the `A` button
  95214. */
  95215. /**
  95216. * Sets the value of the `A` button
  95217. */
  95218. buttonA: number;
  95219. /**
  95220. * Gets the value of the `B` button
  95221. */
  95222. /**
  95223. * Sets the value of the `B` button
  95224. */
  95225. buttonB: number;
  95226. /**
  95227. * Gets the value of the `X` button
  95228. */
  95229. /**
  95230. * Sets the value of the `X` button
  95231. */
  95232. buttonX: number;
  95233. /**
  95234. * Gets the value of the `Y` button
  95235. */
  95236. /**
  95237. * Sets the value of the `Y` button
  95238. */
  95239. buttonY: number;
  95240. /**
  95241. * Gets the value of the `Start` button
  95242. */
  95243. /**
  95244. * Sets the value of the `Start` button
  95245. */
  95246. buttonStart: number;
  95247. /**
  95248. * Gets the value of the `Back` button
  95249. */
  95250. /**
  95251. * Sets the value of the `Back` button
  95252. */
  95253. buttonBack: number;
  95254. /**
  95255. * Gets the value of the `Left` button
  95256. */
  95257. /**
  95258. * Sets the value of the `Left` button
  95259. */
  95260. buttonLB: number;
  95261. /**
  95262. * Gets the value of the `Right` button
  95263. */
  95264. /**
  95265. * Sets the value of the `Right` button
  95266. */
  95267. buttonRB: number;
  95268. /**
  95269. * Gets the value of the Left joystick
  95270. */
  95271. /**
  95272. * Sets the value of the Left joystick
  95273. */
  95274. buttonLeftStick: number;
  95275. /**
  95276. * Gets the value of the Right joystick
  95277. */
  95278. /**
  95279. * Sets the value of the Right joystick
  95280. */
  95281. buttonRightStick: number;
  95282. /**
  95283. * Gets the value of D-pad up
  95284. */
  95285. /**
  95286. * Sets the value of D-pad up
  95287. */
  95288. dPadUp: number;
  95289. /**
  95290. * Gets the value of D-pad down
  95291. */
  95292. /**
  95293. * Sets the value of D-pad down
  95294. */
  95295. dPadDown: number;
  95296. /**
  95297. * Gets the value of D-pad left
  95298. */
  95299. /**
  95300. * Sets the value of D-pad left
  95301. */
  95302. dPadLeft: number;
  95303. /**
  95304. * Gets the value of D-pad right
  95305. */
  95306. /**
  95307. * Sets the value of D-pad right
  95308. */
  95309. dPadRight: number;
  95310. /**
  95311. * Force the gamepad to synchronize with device values
  95312. */
  95313. update(): void;
  95314. /**
  95315. * Disposes the gamepad
  95316. */
  95317. dispose(): void;
  95318. }
  95319. }
  95320. declare module BABYLON {
  95321. /**
  95322. * Base class of materials working in push mode in babylon JS
  95323. * @hidden
  95324. */
  95325. export class PushMaterial extends Material {
  95326. protected _activeEffect: Effect;
  95327. protected _normalMatrix: Matrix;
  95328. /**
  95329. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  95330. * This means that the material can keep using a previous shader while a new one is being compiled.
  95331. * This is mostly used when shader parallel compilation is supported (true by default)
  95332. */
  95333. allowShaderHotSwapping: boolean;
  95334. constructor(name: string, scene: Scene);
  95335. getEffect(): Effect;
  95336. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95337. /**
  95338. * Binds the given world matrix to the active effect
  95339. *
  95340. * @param world the matrix to bind
  95341. */
  95342. bindOnlyWorldMatrix(world: Matrix): void;
  95343. /**
  95344. * Binds the given normal matrix to the active effect
  95345. *
  95346. * @param normalMatrix the matrix to bind
  95347. */
  95348. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95349. bind(world: Matrix, mesh?: Mesh): void;
  95350. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95351. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95352. }
  95353. }
  95354. declare module BABYLON {
  95355. /**
  95356. * This groups all the flags used to control the materials channel.
  95357. */
  95358. export class MaterialFlags {
  95359. private static _DiffuseTextureEnabled;
  95360. /**
  95361. * Are diffuse textures enabled in the application.
  95362. */
  95363. static DiffuseTextureEnabled: boolean;
  95364. private static _AmbientTextureEnabled;
  95365. /**
  95366. * Are ambient textures enabled in the application.
  95367. */
  95368. static AmbientTextureEnabled: boolean;
  95369. private static _OpacityTextureEnabled;
  95370. /**
  95371. * Are opacity textures enabled in the application.
  95372. */
  95373. static OpacityTextureEnabled: boolean;
  95374. private static _ReflectionTextureEnabled;
  95375. /**
  95376. * Are reflection textures enabled in the application.
  95377. */
  95378. static ReflectionTextureEnabled: boolean;
  95379. private static _EmissiveTextureEnabled;
  95380. /**
  95381. * Are emissive textures enabled in the application.
  95382. */
  95383. static EmissiveTextureEnabled: boolean;
  95384. private static _SpecularTextureEnabled;
  95385. /**
  95386. * Are specular textures enabled in the application.
  95387. */
  95388. static SpecularTextureEnabled: boolean;
  95389. private static _BumpTextureEnabled;
  95390. /**
  95391. * Are bump textures enabled in the application.
  95392. */
  95393. static BumpTextureEnabled: boolean;
  95394. private static _LightmapTextureEnabled;
  95395. /**
  95396. * Are lightmap textures enabled in the application.
  95397. */
  95398. static LightmapTextureEnabled: boolean;
  95399. private static _RefractionTextureEnabled;
  95400. /**
  95401. * Are refraction textures enabled in the application.
  95402. */
  95403. static RefractionTextureEnabled: boolean;
  95404. private static _ColorGradingTextureEnabled;
  95405. /**
  95406. * Are color grading textures enabled in the application.
  95407. */
  95408. static ColorGradingTextureEnabled: boolean;
  95409. private static _FresnelEnabled;
  95410. /**
  95411. * Are fresnels enabled in the application.
  95412. */
  95413. static FresnelEnabled: boolean;
  95414. private static _ClearCoatTextureEnabled;
  95415. /**
  95416. * Are clear coat textures enabled in the application.
  95417. */
  95418. static ClearCoatTextureEnabled: boolean;
  95419. private static _ClearCoatBumpTextureEnabled;
  95420. /**
  95421. * Are clear coat bump textures enabled in the application.
  95422. */
  95423. static ClearCoatBumpTextureEnabled: boolean;
  95424. private static _ClearCoatTintTextureEnabled;
  95425. /**
  95426. * Are clear coat tint textures enabled in the application.
  95427. */
  95428. static ClearCoatTintTextureEnabled: boolean;
  95429. private static _SheenTextureEnabled;
  95430. /**
  95431. * Are sheen textures enabled in the application.
  95432. */
  95433. static SheenTextureEnabled: boolean;
  95434. private static _AnisotropicTextureEnabled;
  95435. /**
  95436. * Are anisotropic textures enabled in the application.
  95437. */
  95438. static AnisotropicTextureEnabled: boolean;
  95439. }
  95440. }
  95441. declare module BABYLON {
  95442. /** @hidden */
  95443. export var defaultFragmentDeclaration: {
  95444. name: string;
  95445. shader: string;
  95446. };
  95447. }
  95448. declare module BABYLON {
  95449. /** @hidden */
  95450. export var defaultUboDeclaration: {
  95451. name: string;
  95452. shader: string;
  95453. };
  95454. }
  95455. declare module BABYLON {
  95456. /** @hidden */
  95457. export var lightFragmentDeclaration: {
  95458. name: string;
  95459. shader: string;
  95460. };
  95461. }
  95462. declare module BABYLON {
  95463. /** @hidden */
  95464. export var lightUboDeclaration: {
  95465. name: string;
  95466. shader: string;
  95467. };
  95468. }
  95469. declare module BABYLON {
  95470. /** @hidden */
  95471. export var lightsFragmentFunctions: {
  95472. name: string;
  95473. shader: string;
  95474. };
  95475. }
  95476. declare module BABYLON {
  95477. /** @hidden */
  95478. export var shadowsFragmentFunctions: {
  95479. name: string;
  95480. shader: string;
  95481. };
  95482. }
  95483. declare module BABYLON {
  95484. /** @hidden */
  95485. export var fresnelFunction: {
  95486. name: string;
  95487. shader: string;
  95488. };
  95489. }
  95490. declare module BABYLON {
  95491. /** @hidden */
  95492. export var reflectionFunction: {
  95493. name: string;
  95494. shader: string;
  95495. };
  95496. }
  95497. declare module BABYLON {
  95498. /** @hidden */
  95499. export var bumpFragmentFunctions: {
  95500. name: string;
  95501. shader: string;
  95502. };
  95503. }
  95504. declare module BABYLON {
  95505. /** @hidden */
  95506. export var logDepthDeclaration: {
  95507. name: string;
  95508. shader: string;
  95509. };
  95510. }
  95511. declare module BABYLON {
  95512. /** @hidden */
  95513. export var bumpFragment: {
  95514. name: string;
  95515. shader: string;
  95516. };
  95517. }
  95518. declare module BABYLON {
  95519. /** @hidden */
  95520. export var depthPrePass: {
  95521. name: string;
  95522. shader: string;
  95523. };
  95524. }
  95525. declare module BABYLON {
  95526. /** @hidden */
  95527. export var lightFragment: {
  95528. name: string;
  95529. shader: string;
  95530. };
  95531. }
  95532. declare module BABYLON {
  95533. /** @hidden */
  95534. export var logDepthFragment: {
  95535. name: string;
  95536. shader: string;
  95537. };
  95538. }
  95539. declare module BABYLON {
  95540. /** @hidden */
  95541. export var defaultPixelShader: {
  95542. name: string;
  95543. shader: string;
  95544. };
  95545. }
  95546. declare module BABYLON {
  95547. /** @hidden */
  95548. export var defaultVertexDeclaration: {
  95549. name: string;
  95550. shader: string;
  95551. };
  95552. }
  95553. declare module BABYLON {
  95554. /** @hidden */
  95555. export var bumpVertexDeclaration: {
  95556. name: string;
  95557. shader: string;
  95558. };
  95559. }
  95560. declare module BABYLON {
  95561. /** @hidden */
  95562. export var bumpVertex: {
  95563. name: string;
  95564. shader: string;
  95565. };
  95566. }
  95567. declare module BABYLON {
  95568. /** @hidden */
  95569. export var fogVertex: {
  95570. name: string;
  95571. shader: string;
  95572. };
  95573. }
  95574. declare module BABYLON {
  95575. /** @hidden */
  95576. export var shadowsVertex: {
  95577. name: string;
  95578. shader: string;
  95579. };
  95580. }
  95581. declare module BABYLON {
  95582. /** @hidden */
  95583. export var pointCloudVertex: {
  95584. name: string;
  95585. shader: string;
  95586. };
  95587. }
  95588. declare module BABYLON {
  95589. /** @hidden */
  95590. export var logDepthVertex: {
  95591. name: string;
  95592. shader: string;
  95593. };
  95594. }
  95595. declare module BABYLON {
  95596. /** @hidden */
  95597. export var defaultVertexShader: {
  95598. name: string;
  95599. shader: string;
  95600. };
  95601. }
  95602. declare module BABYLON {
  95603. /** @hidden */
  95604. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95605. MAINUV1: boolean;
  95606. MAINUV2: boolean;
  95607. DIFFUSE: boolean;
  95608. DIFFUSEDIRECTUV: number;
  95609. AMBIENT: boolean;
  95610. AMBIENTDIRECTUV: number;
  95611. OPACITY: boolean;
  95612. OPACITYDIRECTUV: number;
  95613. OPACITYRGB: boolean;
  95614. REFLECTION: boolean;
  95615. EMISSIVE: boolean;
  95616. EMISSIVEDIRECTUV: number;
  95617. SPECULAR: boolean;
  95618. SPECULARDIRECTUV: number;
  95619. BUMP: boolean;
  95620. BUMPDIRECTUV: number;
  95621. PARALLAX: boolean;
  95622. PARALLAXOCCLUSION: boolean;
  95623. SPECULAROVERALPHA: boolean;
  95624. CLIPPLANE: boolean;
  95625. CLIPPLANE2: boolean;
  95626. CLIPPLANE3: boolean;
  95627. CLIPPLANE4: boolean;
  95628. ALPHATEST: boolean;
  95629. DEPTHPREPASS: boolean;
  95630. ALPHAFROMDIFFUSE: boolean;
  95631. POINTSIZE: boolean;
  95632. FOG: boolean;
  95633. SPECULARTERM: boolean;
  95634. DIFFUSEFRESNEL: boolean;
  95635. OPACITYFRESNEL: boolean;
  95636. REFLECTIONFRESNEL: boolean;
  95637. REFRACTIONFRESNEL: boolean;
  95638. EMISSIVEFRESNEL: boolean;
  95639. FRESNEL: boolean;
  95640. NORMAL: boolean;
  95641. UV1: boolean;
  95642. UV2: boolean;
  95643. VERTEXCOLOR: boolean;
  95644. VERTEXALPHA: boolean;
  95645. NUM_BONE_INFLUENCERS: number;
  95646. BonesPerMesh: number;
  95647. BONETEXTURE: boolean;
  95648. INSTANCES: boolean;
  95649. GLOSSINESS: boolean;
  95650. ROUGHNESS: boolean;
  95651. EMISSIVEASILLUMINATION: boolean;
  95652. LINKEMISSIVEWITHDIFFUSE: boolean;
  95653. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95654. LIGHTMAP: boolean;
  95655. LIGHTMAPDIRECTUV: number;
  95656. OBJECTSPACE_NORMALMAP: boolean;
  95657. USELIGHTMAPASSHADOWMAP: boolean;
  95658. REFLECTIONMAP_3D: boolean;
  95659. REFLECTIONMAP_SPHERICAL: boolean;
  95660. REFLECTIONMAP_PLANAR: boolean;
  95661. REFLECTIONMAP_CUBIC: boolean;
  95662. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95663. REFLECTIONMAP_PROJECTION: boolean;
  95664. REFLECTIONMAP_SKYBOX: boolean;
  95665. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95666. REFLECTIONMAP_EXPLICIT: boolean;
  95667. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95668. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95669. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95670. INVERTCUBICMAP: boolean;
  95671. LOGARITHMICDEPTH: boolean;
  95672. REFRACTION: boolean;
  95673. REFRACTIONMAP_3D: boolean;
  95674. REFLECTIONOVERALPHA: boolean;
  95675. TWOSIDEDLIGHTING: boolean;
  95676. SHADOWFLOAT: boolean;
  95677. MORPHTARGETS: boolean;
  95678. MORPHTARGETS_NORMAL: boolean;
  95679. MORPHTARGETS_TANGENT: boolean;
  95680. NUM_MORPH_INFLUENCERS: number;
  95681. NONUNIFORMSCALING: boolean;
  95682. PREMULTIPLYALPHA: boolean;
  95683. IMAGEPROCESSING: boolean;
  95684. VIGNETTE: boolean;
  95685. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95686. VIGNETTEBLENDMODEOPAQUE: boolean;
  95687. TONEMAPPING: boolean;
  95688. TONEMAPPING_ACES: boolean;
  95689. CONTRAST: boolean;
  95690. COLORCURVES: boolean;
  95691. COLORGRADING: boolean;
  95692. COLORGRADING3D: boolean;
  95693. SAMPLER3DGREENDEPTH: boolean;
  95694. SAMPLER3DBGRMAP: boolean;
  95695. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95696. /**
  95697. * If the reflection texture on this material is in linear color space
  95698. * @hidden
  95699. */
  95700. IS_REFLECTION_LINEAR: boolean;
  95701. /**
  95702. * If the refraction texture on this material is in linear color space
  95703. * @hidden
  95704. */
  95705. IS_REFRACTION_LINEAR: boolean;
  95706. EXPOSURE: boolean;
  95707. constructor();
  95708. setReflectionMode(modeToEnable: string): void;
  95709. }
  95710. /**
  95711. * This is the default material used in Babylon. It is the best trade off between quality
  95712. * and performances.
  95713. * @see http://doc.babylonjs.com/babylon101/materials
  95714. */
  95715. export class StandardMaterial extends PushMaterial {
  95716. private _diffuseTexture;
  95717. /**
  95718. * The basic texture of the material as viewed under a light.
  95719. */
  95720. diffuseTexture: Nullable<BaseTexture>;
  95721. private _ambientTexture;
  95722. /**
  95723. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95724. */
  95725. ambientTexture: Nullable<BaseTexture>;
  95726. private _opacityTexture;
  95727. /**
  95728. * Define the transparency of the material from a texture.
  95729. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95730. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95731. */
  95732. opacityTexture: Nullable<BaseTexture>;
  95733. private _reflectionTexture;
  95734. /**
  95735. * Define the texture used to display the reflection.
  95736. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95737. */
  95738. reflectionTexture: Nullable<BaseTexture>;
  95739. private _emissiveTexture;
  95740. /**
  95741. * Define texture of the material as if self lit.
  95742. * This will be mixed in the final result even in the absence of light.
  95743. */
  95744. emissiveTexture: Nullable<BaseTexture>;
  95745. private _specularTexture;
  95746. /**
  95747. * Define how the color and intensity of the highlight given by the light in the material.
  95748. */
  95749. specularTexture: Nullable<BaseTexture>;
  95750. private _bumpTexture;
  95751. /**
  95752. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95753. * 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.
  95754. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95755. */
  95756. bumpTexture: Nullable<BaseTexture>;
  95757. private _lightmapTexture;
  95758. /**
  95759. * Complex lighting can be computationally expensive to compute at runtime.
  95760. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95761. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95762. */
  95763. lightmapTexture: Nullable<BaseTexture>;
  95764. private _refractionTexture;
  95765. /**
  95766. * Define the texture used to display the refraction.
  95767. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95768. */
  95769. refractionTexture: Nullable<BaseTexture>;
  95770. /**
  95771. * The color of the material lit by the environmental background lighting.
  95772. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95773. */
  95774. ambientColor: Color3;
  95775. /**
  95776. * The basic color of the material as viewed under a light.
  95777. */
  95778. diffuseColor: Color3;
  95779. /**
  95780. * Define how the color and intensity of the highlight given by the light in the material.
  95781. */
  95782. specularColor: Color3;
  95783. /**
  95784. * Define the color of the material as if self lit.
  95785. * This will be mixed in the final result even in the absence of light.
  95786. */
  95787. emissiveColor: Color3;
  95788. /**
  95789. * Defines how sharp are the highlights in the material.
  95790. * The bigger the value the sharper giving a more glossy feeling to the result.
  95791. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95792. */
  95793. specularPower: number;
  95794. private _useAlphaFromDiffuseTexture;
  95795. /**
  95796. * Does the transparency come from the diffuse texture alpha channel.
  95797. */
  95798. useAlphaFromDiffuseTexture: boolean;
  95799. private _useEmissiveAsIllumination;
  95800. /**
  95801. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95802. */
  95803. useEmissiveAsIllumination: boolean;
  95804. private _linkEmissiveWithDiffuse;
  95805. /**
  95806. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95807. * the emissive level when the final color is close to one.
  95808. */
  95809. linkEmissiveWithDiffuse: boolean;
  95810. private _useSpecularOverAlpha;
  95811. /**
  95812. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95813. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95814. */
  95815. useSpecularOverAlpha: boolean;
  95816. private _useReflectionOverAlpha;
  95817. /**
  95818. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95819. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95820. */
  95821. useReflectionOverAlpha: boolean;
  95822. private _disableLighting;
  95823. /**
  95824. * Does lights from the scene impacts this material.
  95825. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95826. */
  95827. disableLighting: boolean;
  95828. private _useObjectSpaceNormalMap;
  95829. /**
  95830. * Allows using an object space normal map (instead of tangent space).
  95831. */
  95832. useObjectSpaceNormalMap: boolean;
  95833. private _useParallax;
  95834. /**
  95835. * Is parallax enabled or not.
  95836. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95837. */
  95838. useParallax: boolean;
  95839. private _useParallaxOcclusion;
  95840. /**
  95841. * Is parallax occlusion enabled or not.
  95842. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95843. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95844. */
  95845. useParallaxOcclusion: boolean;
  95846. /**
  95847. * 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.
  95848. */
  95849. parallaxScaleBias: number;
  95850. private _roughness;
  95851. /**
  95852. * Helps to define how blurry the reflections should appears in the material.
  95853. */
  95854. roughness: number;
  95855. /**
  95856. * In case of refraction, define the value of the indice of refraction.
  95857. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95858. */
  95859. indexOfRefraction: number;
  95860. /**
  95861. * Invert the refraction texture alongside the y axis.
  95862. * It can be useful with procedural textures or probe for instance.
  95863. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95864. */
  95865. invertRefractionY: boolean;
  95866. /**
  95867. * Defines the alpha limits in alpha test mode.
  95868. */
  95869. alphaCutOff: number;
  95870. private _useLightmapAsShadowmap;
  95871. /**
  95872. * In case of light mapping, define whether the map contains light or shadow informations.
  95873. */
  95874. useLightmapAsShadowmap: boolean;
  95875. private _diffuseFresnelParameters;
  95876. /**
  95877. * Define the diffuse fresnel parameters of the material.
  95878. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95879. */
  95880. diffuseFresnelParameters: FresnelParameters;
  95881. private _opacityFresnelParameters;
  95882. /**
  95883. * Define the opacity fresnel parameters of the material.
  95884. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95885. */
  95886. opacityFresnelParameters: FresnelParameters;
  95887. private _reflectionFresnelParameters;
  95888. /**
  95889. * Define the reflection fresnel parameters of the material.
  95890. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95891. */
  95892. reflectionFresnelParameters: FresnelParameters;
  95893. private _refractionFresnelParameters;
  95894. /**
  95895. * Define the refraction fresnel parameters of the material.
  95896. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95897. */
  95898. refractionFresnelParameters: FresnelParameters;
  95899. private _emissiveFresnelParameters;
  95900. /**
  95901. * Define the emissive fresnel parameters of the material.
  95902. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95903. */
  95904. emissiveFresnelParameters: FresnelParameters;
  95905. private _useReflectionFresnelFromSpecular;
  95906. /**
  95907. * If true automatically deducts the fresnels values from the material specularity.
  95908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95909. */
  95910. useReflectionFresnelFromSpecular: boolean;
  95911. private _useGlossinessFromSpecularMapAlpha;
  95912. /**
  95913. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95914. */
  95915. useGlossinessFromSpecularMapAlpha: boolean;
  95916. private _maxSimultaneousLights;
  95917. /**
  95918. * Defines the maximum number of lights that can be used in the material
  95919. */
  95920. maxSimultaneousLights: number;
  95921. private _invertNormalMapX;
  95922. /**
  95923. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95924. */
  95925. invertNormalMapX: boolean;
  95926. private _invertNormalMapY;
  95927. /**
  95928. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95929. */
  95930. invertNormalMapY: boolean;
  95931. private _twoSidedLighting;
  95932. /**
  95933. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95934. */
  95935. twoSidedLighting: boolean;
  95936. /**
  95937. * Default configuration related to image processing available in the standard Material.
  95938. */
  95939. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95940. /**
  95941. * Gets the image processing configuration used either in this material.
  95942. */
  95943. /**
  95944. * Sets the Default image processing configuration used either in the this material.
  95945. *
  95946. * If sets to null, the scene one is in use.
  95947. */
  95948. imageProcessingConfiguration: ImageProcessingConfiguration;
  95949. /**
  95950. * Keep track of the image processing observer to allow dispose and replace.
  95951. */
  95952. private _imageProcessingObserver;
  95953. /**
  95954. * Attaches a new image processing configuration to the Standard Material.
  95955. * @param configuration
  95956. */
  95957. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95958. /**
  95959. * Gets wether the color curves effect is enabled.
  95960. */
  95961. /**
  95962. * Sets wether the color curves effect is enabled.
  95963. */
  95964. cameraColorCurvesEnabled: boolean;
  95965. /**
  95966. * Gets wether the color grading effect is enabled.
  95967. */
  95968. /**
  95969. * Gets wether the color grading effect is enabled.
  95970. */
  95971. cameraColorGradingEnabled: boolean;
  95972. /**
  95973. * Gets wether tonemapping is enabled or not.
  95974. */
  95975. /**
  95976. * Sets wether tonemapping is enabled or not
  95977. */
  95978. cameraToneMappingEnabled: boolean;
  95979. /**
  95980. * The camera exposure used on this material.
  95981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95982. * This corresponds to a photographic exposure.
  95983. */
  95984. /**
  95985. * The camera exposure used on this material.
  95986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95987. * This corresponds to a photographic exposure.
  95988. */
  95989. cameraExposure: number;
  95990. /**
  95991. * Gets The camera contrast used on this material.
  95992. */
  95993. /**
  95994. * Sets The camera contrast used on this material.
  95995. */
  95996. cameraContrast: number;
  95997. /**
  95998. * Gets the Color Grading 2D Lookup Texture.
  95999. */
  96000. /**
  96001. * Sets the Color Grading 2D Lookup Texture.
  96002. */
  96003. cameraColorGradingTexture: Nullable<BaseTexture>;
  96004. /**
  96005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96007. * 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;
  96008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96009. */
  96010. /**
  96011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96013. * 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;
  96014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96015. */
  96016. cameraColorCurves: Nullable<ColorCurves>;
  96017. /**
  96018. * Custom callback helping to override the default shader used in the material.
  96019. */
  96020. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96021. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96022. protected _worldViewProjectionMatrix: Matrix;
  96023. protected _globalAmbientColor: Color3;
  96024. protected _useLogarithmicDepth: boolean;
  96025. /**
  96026. * Instantiates a new standard material.
  96027. * This is the default material used in Babylon. It is the best trade off between quality
  96028. * and performances.
  96029. * @see http://doc.babylonjs.com/babylon101/materials
  96030. * @param name Define the name of the material in the scene
  96031. * @param scene Define the scene the material belong to
  96032. */
  96033. constructor(name: string, scene: Scene);
  96034. /**
  96035. * Gets a boolean indicating that current material needs to register RTT
  96036. */
  96037. readonly hasRenderTargetTextures: boolean;
  96038. /**
  96039. * Gets the current class name of the material e.g. "StandardMaterial"
  96040. * Mainly use in serialization.
  96041. * @returns the class name
  96042. */
  96043. getClassName(): string;
  96044. /**
  96045. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96046. * You can try switching to logarithmic depth.
  96047. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96048. */
  96049. useLogarithmicDepth: boolean;
  96050. /**
  96051. * Specifies if the material will require alpha blending
  96052. * @returns a boolean specifying if alpha blending is needed
  96053. */
  96054. needAlphaBlending(): boolean;
  96055. /**
  96056. * Specifies if this material should be rendered in alpha test mode
  96057. * @returns a boolean specifying if an alpha test is needed.
  96058. */
  96059. needAlphaTesting(): boolean;
  96060. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96061. /**
  96062. * Get the texture used for alpha test purpose.
  96063. * @returns the diffuse texture in case of the standard material.
  96064. */
  96065. getAlphaTestTexture(): Nullable<BaseTexture>;
  96066. /**
  96067. * Get if the submesh is ready to be used and all its information available.
  96068. * Child classes can use it to update shaders
  96069. * @param mesh defines the mesh to check
  96070. * @param subMesh defines which submesh to check
  96071. * @param useInstances specifies that instances should be used
  96072. * @returns a boolean indicating that the submesh is ready or not
  96073. */
  96074. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96075. /**
  96076. * Builds the material UBO layouts.
  96077. * Used internally during the effect preparation.
  96078. */
  96079. buildUniformLayout(): void;
  96080. /**
  96081. * Unbinds the material from the mesh
  96082. */
  96083. unbind(): void;
  96084. /**
  96085. * Binds the submesh to this material by preparing the effect and shader to draw
  96086. * @param world defines the world transformation matrix
  96087. * @param mesh defines the mesh containing the submesh
  96088. * @param subMesh defines the submesh to bind the material to
  96089. */
  96090. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96091. /**
  96092. * Get the list of animatables in the material.
  96093. * @returns the list of animatables object used in the material
  96094. */
  96095. getAnimatables(): IAnimatable[];
  96096. /**
  96097. * Gets the active textures from the material
  96098. * @returns an array of textures
  96099. */
  96100. getActiveTextures(): BaseTexture[];
  96101. /**
  96102. * Specifies if the material uses a texture
  96103. * @param texture defines the texture to check against the material
  96104. * @returns a boolean specifying if the material uses the texture
  96105. */
  96106. hasTexture(texture: BaseTexture): boolean;
  96107. /**
  96108. * Disposes the material
  96109. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96110. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96111. */
  96112. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  96113. /**
  96114. * Makes a duplicate of the material, and gives it a new name
  96115. * @param name defines the new name for the duplicated material
  96116. * @returns the cloned material
  96117. */
  96118. clone(name: string): StandardMaterial;
  96119. /**
  96120. * Serializes this material in a JSON representation
  96121. * @returns the serialized material object
  96122. */
  96123. serialize(): any;
  96124. /**
  96125. * Creates a standard material from parsed material data
  96126. * @param source defines the JSON representation of the material
  96127. * @param scene defines the hosting scene
  96128. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96129. * @returns a new standard material
  96130. */
  96131. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96132. /**
  96133. * Are diffuse textures enabled in the application.
  96134. */
  96135. static DiffuseTextureEnabled: boolean;
  96136. /**
  96137. * Are ambient textures enabled in the application.
  96138. */
  96139. static AmbientTextureEnabled: boolean;
  96140. /**
  96141. * Are opacity textures enabled in the application.
  96142. */
  96143. static OpacityTextureEnabled: boolean;
  96144. /**
  96145. * Are reflection textures enabled in the application.
  96146. */
  96147. static ReflectionTextureEnabled: boolean;
  96148. /**
  96149. * Are emissive textures enabled in the application.
  96150. */
  96151. static EmissiveTextureEnabled: boolean;
  96152. /**
  96153. * Are specular textures enabled in the application.
  96154. */
  96155. static SpecularTextureEnabled: boolean;
  96156. /**
  96157. * Are bump textures enabled in the application.
  96158. */
  96159. static BumpTextureEnabled: boolean;
  96160. /**
  96161. * Are lightmap textures enabled in the application.
  96162. */
  96163. static LightmapTextureEnabled: boolean;
  96164. /**
  96165. * Are refraction textures enabled in the application.
  96166. */
  96167. static RefractionTextureEnabled: boolean;
  96168. /**
  96169. * Are color grading textures enabled in the application.
  96170. */
  96171. static ColorGradingTextureEnabled: boolean;
  96172. /**
  96173. * Are fresnels enabled in the application.
  96174. */
  96175. static FresnelEnabled: boolean;
  96176. }
  96177. }
  96178. declare module BABYLON {
  96179. /**
  96180. * A class extending Texture allowing drawing on a texture
  96181. * @see http://doc.babylonjs.com/how_to/dynamictexture
  96182. */
  96183. export class DynamicTexture extends Texture {
  96184. private _generateMipMaps;
  96185. private _canvas;
  96186. private _context;
  96187. private _engine;
  96188. /**
  96189. * Creates a DynamicTexture
  96190. * @param name defines the name of the texture
  96191. * @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
  96192. * @param scene defines the scene where you want the texture
  96193. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  96194. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96195. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  96196. */
  96197. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  96198. /**
  96199. * Get the current class name of the texture useful for serialization or dynamic coding.
  96200. * @returns "DynamicTexture"
  96201. */
  96202. getClassName(): string;
  96203. /**
  96204. * Gets the current state of canRescale
  96205. */
  96206. readonly canRescale: boolean;
  96207. private _recreate;
  96208. /**
  96209. * Scales the texture
  96210. * @param ratio the scale factor to apply to both width and height
  96211. */
  96212. scale(ratio: number): void;
  96213. /**
  96214. * Resizes the texture
  96215. * @param width the new width
  96216. * @param height the new height
  96217. */
  96218. scaleTo(width: number, height: number): void;
  96219. /**
  96220. * Gets the context of the canvas used by the texture
  96221. * @returns the canvas context of the dynamic texture
  96222. */
  96223. getContext(): CanvasRenderingContext2D;
  96224. /**
  96225. * Clears the texture
  96226. */
  96227. clear(): void;
  96228. /**
  96229. * Updates the texture
  96230. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96231. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  96232. */
  96233. update(invertY?: boolean, premulAlpha?: boolean): void;
  96234. /**
  96235. * Draws text onto the texture
  96236. * @param text defines the text to be drawn
  96237. * @param x defines the placement of the text from the left
  96238. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  96239. * @param font defines the font to be used with font-style, font-size, font-name
  96240. * @param color defines the color used for the text
  96241. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  96242. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96243. * @param update defines whether texture is immediately update (default is true)
  96244. */
  96245. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  96246. /**
  96247. * Clones the texture
  96248. * @returns the clone of the texture.
  96249. */
  96250. clone(): DynamicTexture;
  96251. /**
  96252. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  96253. * @returns a serialized dynamic texture object
  96254. */
  96255. serialize(): any;
  96256. /** @hidden */
  96257. _rebuild(): void;
  96258. }
  96259. }
  96260. declare module BABYLON {
  96261. /** @hidden */
  96262. export var imageProcessingPixelShader: {
  96263. name: string;
  96264. shader: string;
  96265. };
  96266. }
  96267. declare module BABYLON {
  96268. /**
  96269. * ImageProcessingPostProcess
  96270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  96271. */
  96272. export class ImageProcessingPostProcess extends PostProcess {
  96273. /**
  96274. * Default configuration related to image processing available in the PBR Material.
  96275. */
  96276. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96277. /**
  96278. * Gets the image processing configuration used either in this material.
  96279. */
  96280. /**
  96281. * Sets the Default image processing configuration used either in the this material.
  96282. *
  96283. * If sets to null, the scene one is in use.
  96284. */
  96285. imageProcessingConfiguration: ImageProcessingConfiguration;
  96286. /**
  96287. * Keep track of the image processing observer to allow dispose and replace.
  96288. */
  96289. private _imageProcessingObserver;
  96290. /**
  96291. * Attaches a new image processing configuration to the PBR Material.
  96292. * @param configuration
  96293. */
  96294. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  96295. /**
  96296. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96297. */
  96298. /**
  96299. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96300. */
  96301. colorCurves: Nullable<ColorCurves>;
  96302. /**
  96303. * Gets wether the color curves effect is enabled.
  96304. */
  96305. /**
  96306. * Sets wether the color curves effect is enabled.
  96307. */
  96308. colorCurvesEnabled: boolean;
  96309. /**
  96310. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96311. */
  96312. /**
  96313. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96314. */
  96315. colorGradingTexture: Nullable<BaseTexture>;
  96316. /**
  96317. * Gets wether the color grading effect is enabled.
  96318. */
  96319. /**
  96320. * Gets wether the color grading effect is enabled.
  96321. */
  96322. colorGradingEnabled: boolean;
  96323. /**
  96324. * Gets exposure used in the effect.
  96325. */
  96326. /**
  96327. * Sets exposure used in the effect.
  96328. */
  96329. exposure: number;
  96330. /**
  96331. * Gets wether tonemapping is enabled or not.
  96332. */
  96333. /**
  96334. * Sets wether tonemapping is enabled or not
  96335. */
  96336. toneMappingEnabled: boolean;
  96337. /**
  96338. * Gets the type of tone mapping effect.
  96339. */
  96340. /**
  96341. * Sets the type of tone mapping effect.
  96342. */
  96343. toneMappingType: number;
  96344. /**
  96345. * Gets contrast used in the effect.
  96346. */
  96347. /**
  96348. * Sets contrast used in the effect.
  96349. */
  96350. contrast: number;
  96351. /**
  96352. * Gets Vignette stretch size.
  96353. */
  96354. /**
  96355. * Sets Vignette stretch size.
  96356. */
  96357. vignetteStretch: number;
  96358. /**
  96359. * Gets Vignette centre X Offset.
  96360. */
  96361. /**
  96362. * Sets Vignette centre X Offset.
  96363. */
  96364. vignetteCentreX: number;
  96365. /**
  96366. * Gets Vignette centre Y Offset.
  96367. */
  96368. /**
  96369. * Sets Vignette centre Y Offset.
  96370. */
  96371. vignetteCentreY: number;
  96372. /**
  96373. * Gets Vignette weight or intensity of the vignette effect.
  96374. */
  96375. /**
  96376. * Sets Vignette weight or intensity of the vignette effect.
  96377. */
  96378. vignetteWeight: number;
  96379. /**
  96380. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96381. * if vignetteEnabled is set to true.
  96382. */
  96383. /**
  96384. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96385. * if vignetteEnabled is set to true.
  96386. */
  96387. vignetteColor: Color4;
  96388. /**
  96389. * Gets Camera field of view used by the Vignette effect.
  96390. */
  96391. /**
  96392. * Sets Camera field of view used by the Vignette effect.
  96393. */
  96394. vignetteCameraFov: number;
  96395. /**
  96396. * Gets the vignette blend mode allowing different kind of effect.
  96397. */
  96398. /**
  96399. * Sets the vignette blend mode allowing different kind of effect.
  96400. */
  96401. vignetteBlendMode: number;
  96402. /**
  96403. * Gets wether the vignette effect is enabled.
  96404. */
  96405. /**
  96406. * Sets wether the vignette effect is enabled.
  96407. */
  96408. vignetteEnabled: boolean;
  96409. private _fromLinearSpace;
  96410. /**
  96411. * Gets wether the input of the processing is in Gamma or Linear Space.
  96412. */
  96413. /**
  96414. * Sets wether the input of the processing is in Gamma or Linear Space.
  96415. */
  96416. fromLinearSpace: boolean;
  96417. /**
  96418. * Defines cache preventing GC.
  96419. */
  96420. private _defines;
  96421. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96422. /**
  96423. * "ImageProcessingPostProcess"
  96424. * @returns "ImageProcessingPostProcess"
  96425. */
  96426. getClassName(): string;
  96427. protected _updateParameters(): void;
  96428. dispose(camera?: Camera): void;
  96429. }
  96430. }
  96431. declare module BABYLON {
  96432. /**
  96433. * Class containing static functions to help procedurally build meshes
  96434. */
  96435. export class GroundBuilder {
  96436. /**
  96437. * Creates a ground mesh
  96438. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96439. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96441. * @param name defines the name of the mesh
  96442. * @param options defines the options used to create the mesh
  96443. * @param scene defines the hosting scene
  96444. * @returns the ground mesh
  96445. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96446. */
  96447. static CreateGround(name: string, options: {
  96448. width?: number;
  96449. height?: number;
  96450. subdivisions?: number;
  96451. subdivisionsX?: number;
  96452. subdivisionsY?: number;
  96453. updatable?: boolean;
  96454. }, scene: any): Mesh;
  96455. /**
  96456. * Creates a tiled ground mesh
  96457. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96458. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96459. * * 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
  96460. * * 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
  96461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96462. * @param name defines the name of the mesh
  96463. * @param options defines the options used to create the mesh
  96464. * @param scene defines the hosting scene
  96465. * @returns the tiled ground mesh
  96466. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96467. */
  96468. static CreateTiledGround(name: string, options: {
  96469. xmin: number;
  96470. zmin: number;
  96471. xmax: number;
  96472. zmax: number;
  96473. subdivisions?: {
  96474. w: number;
  96475. h: number;
  96476. };
  96477. precision?: {
  96478. w: number;
  96479. h: number;
  96480. };
  96481. updatable?: boolean;
  96482. }, scene: Scene): Mesh;
  96483. /**
  96484. * Creates a ground mesh from a height map
  96485. * * The parameter `url` sets the URL of the height map image resource.
  96486. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96487. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96488. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96489. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96490. * * 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.
  96491. * * 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).
  96492. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96494. * @param name defines the name of the mesh
  96495. * @param url defines the url to the height map
  96496. * @param options defines the options used to create the mesh
  96497. * @param scene defines the hosting scene
  96498. * @returns the ground mesh
  96499. * @see https://doc.babylonjs.com/babylon101/height_map
  96500. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96501. */
  96502. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96503. width?: number;
  96504. height?: number;
  96505. subdivisions?: number;
  96506. minHeight?: number;
  96507. maxHeight?: number;
  96508. colorFilter?: Color3;
  96509. alphaFilter?: number;
  96510. updatable?: boolean;
  96511. onReady?: (mesh: GroundMesh) => void;
  96512. }, scene: Scene): GroundMesh;
  96513. }
  96514. }
  96515. declare module BABYLON {
  96516. /**
  96517. * Class containing static functions to help procedurally build meshes
  96518. */
  96519. export class TorusBuilder {
  96520. /**
  96521. * Creates a torus mesh
  96522. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96523. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96524. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96528. * @param name defines the name of the mesh
  96529. * @param options defines the options used to create the mesh
  96530. * @param scene defines the hosting scene
  96531. * @returns the torus mesh
  96532. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96533. */
  96534. static CreateTorus(name: string, options: {
  96535. diameter?: number;
  96536. thickness?: number;
  96537. tessellation?: number;
  96538. updatable?: boolean;
  96539. sideOrientation?: number;
  96540. frontUVs?: Vector4;
  96541. backUVs?: Vector4;
  96542. }, scene: any): Mesh;
  96543. }
  96544. }
  96545. declare module BABYLON {
  96546. /**
  96547. * Class containing static functions to help procedurally build meshes
  96548. */
  96549. export class CylinderBuilder {
  96550. /**
  96551. * Creates a cylinder or a cone mesh
  96552. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96553. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96554. * * 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.
  96555. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96556. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96557. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96558. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96559. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96560. * * 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).
  96561. * * 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
  96562. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96563. * * 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
  96564. * * 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.
  96565. * * If `enclose` is false, a ring surface is one element.
  96566. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96567. * * 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
  96568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96571. * @param name defines the name of the mesh
  96572. * @param options defines the options used to create the mesh
  96573. * @param scene defines the hosting scene
  96574. * @returns the cylinder mesh
  96575. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96576. */
  96577. static CreateCylinder(name: string, options: {
  96578. height?: number;
  96579. diameterTop?: number;
  96580. diameterBottom?: number;
  96581. diameter?: number;
  96582. tessellation?: number;
  96583. subdivisions?: number;
  96584. arc?: number;
  96585. faceColors?: Color4[];
  96586. faceUV?: Vector4[];
  96587. updatable?: boolean;
  96588. hasRings?: boolean;
  96589. enclose?: boolean;
  96590. sideOrientation?: number;
  96591. frontUVs?: Vector4;
  96592. backUVs?: Vector4;
  96593. }, scene: any): Mesh;
  96594. }
  96595. }
  96596. declare module BABYLON {
  96597. /**
  96598. * Manager for handling gamepads
  96599. */
  96600. export class GamepadManager {
  96601. private _scene?;
  96602. private _babylonGamepads;
  96603. private _oneGamepadConnected;
  96604. /** @hidden */
  96605. _isMonitoring: boolean;
  96606. private _gamepadEventSupported;
  96607. private _gamepadSupport;
  96608. /**
  96609. * observable to be triggered when the gamepad controller has been connected
  96610. */
  96611. onGamepadConnectedObservable: Observable<Gamepad>;
  96612. /**
  96613. * observable to be triggered when the gamepad controller has been disconnected
  96614. */
  96615. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96616. private _onGamepadConnectedEvent;
  96617. private _onGamepadDisconnectedEvent;
  96618. /**
  96619. * Initializes the gamepad manager
  96620. * @param _scene BabylonJS scene
  96621. */
  96622. constructor(_scene?: Scene | undefined);
  96623. /**
  96624. * The gamepads in the game pad manager
  96625. */
  96626. readonly gamepads: Gamepad[];
  96627. /**
  96628. * Get the gamepad controllers based on type
  96629. * @param type The type of gamepad controller
  96630. * @returns Nullable gamepad
  96631. */
  96632. getGamepadByType(type?: number): Nullable<Gamepad>;
  96633. /**
  96634. * Disposes the gamepad manager
  96635. */
  96636. dispose(): void;
  96637. private _addNewGamepad;
  96638. private _startMonitoringGamepads;
  96639. private _stopMonitoringGamepads;
  96640. /** @hidden */
  96641. _checkGamepadsStatus(): void;
  96642. private _updateGamepadObjects;
  96643. }
  96644. }
  96645. declare module BABYLON {
  96646. interface Scene {
  96647. /** @hidden */
  96648. _gamepadManager: Nullable<GamepadManager>;
  96649. /**
  96650. * Gets the gamepad manager associated with the scene
  96651. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96652. */
  96653. gamepadManager: GamepadManager;
  96654. }
  96655. /**
  96656. * Interface representing a free camera inputs manager
  96657. */
  96658. interface FreeCameraInputsManager {
  96659. /**
  96660. * Adds gamepad input support to the FreeCameraInputsManager.
  96661. * @returns the FreeCameraInputsManager
  96662. */
  96663. addGamepad(): FreeCameraInputsManager;
  96664. }
  96665. /**
  96666. * Interface representing an arc rotate camera inputs manager
  96667. */
  96668. interface ArcRotateCameraInputsManager {
  96669. /**
  96670. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96671. * @returns the camera inputs manager
  96672. */
  96673. addGamepad(): ArcRotateCameraInputsManager;
  96674. }
  96675. /**
  96676. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96677. */
  96678. export class GamepadSystemSceneComponent implements ISceneComponent {
  96679. /**
  96680. * The component name helpfull to identify the component in the list of scene components.
  96681. */
  96682. readonly name: string;
  96683. /**
  96684. * The scene the component belongs to.
  96685. */
  96686. scene: Scene;
  96687. /**
  96688. * Creates a new instance of the component for the given scene
  96689. * @param scene Defines the scene to register the component in
  96690. */
  96691. constructor(scene: Scene);
  96692. /**
  96693. * Registers the component in a given scene
  96694. */
  96695. register(): void;
  96696. /**
  96697. * Rebuilds the elements related to this component in case of
  96698. * context lost for instance.
  96699. */
  96700. rebuild(): void;
  96701. /**
  96702. * Disposes the component and the associated ressources
  96703. */
  96704. dispose(): void;
  96705. private _beforeCameraUpdate;
  96706. }
  96707. }
  96708. declare module BABYLON {
  96709. /**
  96710. * Options to modify the vr teleportation behavior.
  96711. */
  96712. export interface VRTeleportationOptions {
  96713. /**
  96714. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96715. */
  96716. floorMeshName?: string;
  96717. /**
  96718. * A list of meshes to be used as the teleportation floor. (default: empty)
  96719. */
  96720. floorMeshes?: Mesh[];
  96721. }
  96722. /**
  96723. * Options to modify the vr experience helper's behavior.
  96724. */
  96725. export interface VRExperienceHelperOptions extends WebVROptions {
  96726. /**
  96727. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96728. */
  96729. createDeviceOrientationCamera?: boolean;
  96730. /**
  96731. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96732. */
  96733. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96734. /**
  96735. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96736. */
  96737. laserToggle?: boolean;
  96738. /**
  96739. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96740. */
  96741. floorMeshes?: Mesh[];
  96742. /**
  96743. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96744. */
  96745. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96746. }
  96747. /**
  96748. * Event containing information after VR has been entered
  96749. */
  96750. export class OnAfterEnteringVRObservableEvent {
  96751. /**
  96752. * If entering vr was successful
  96753. */
  96754. success: boolean;
  96755. }
  96756. /**
  96757. * Helps to quickly add VR support to an existing scene.
  96758. * See http://doc.babylonjs.com/how_to/webvr_helper
  96759. */
  96760. export class VRExperienceHelper {
  96761. /** Options to modify the vr experience helper's behavior. */
  96762. webVROptions: VRExperienceHelperOptions;
  96763. private _scene;
  96764. private _position;
  96765. private _btnVR;
  96766. private _btnVRDisplayed;
  96767. private _webVRsupported;
  96768. private _webVRready;
  96769. private _webVRrequesting;
  96770. private _webVRpresenting;
  96771. private _hasEnteredVR;
  96772. private _fullscreenVRpresenting;
  96773. private _canvas;
  96774. private _webVRCamera;
  96775. private _vrDeviceOrientationCamera;
  96776. private _deviceOrientationCamera;
  96777. private _existingCamera;
  96778. private _onKeyDown;
  96779. private _onVrDisplayPresentChange;
  96780. private _onVRDisplayChanged;
  96781. private _onVRRequestPresentStart;
  96782. private _onVRRequestPresentComplete;
  96783. /**
  96784. * Observable raised right before entering VR.
  96785. */
  96786. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96787. /**
  96788. * Observable raised when entering VR has completed.
  96789. */
  96790. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96791. /**
  96792. * Observable raised when exiting VR.
  96793. */
  96794. onExitingVRObservable: Observable<VRExperienceHelper>;
  96795. /**
  96796. * Observable raised when controller mesh is loaded.
  96797. */
  96798. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96799. /** Return this.onEnteringVRObservable
  96800. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96801. */
  96802. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96803. /** Return this.onExitingVRObservable
  96804. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96805. */
  96806. readonly onExitingVR: Observable<VRExperienceHelper>;
  96807. /** Return this.onControllerMeshLoadedObservable
  96808. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96809. */
  96810. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96811. private _rayLength;
  96812. private _useCustomVRButton;
  96813. private _teleportationRequested;
  96814. private _teleportActive;
  96815. private _floorMeshName;
  96816. private _floorMeshesCollection;
  96817. private _rotationAllowed;
  96818. private _teleportBackwardsVector;
  96819. private _teleportationTarget;
  96820. private _isDefaultTeleportationTarget;
  96821. private _postProcessMove;
  96822. private _teleportationFillColor;
  96823. private _teleportationBorderColor;
  96824. private _rotationAngle;
  96825. private _haloCenter;
  96826. private _cameraGazer;
  96827. private _padSensibilityUp;
  96828. private _padSensibilityDown;
  96829. private _leftController;
  96830. private _rightController;
  96831. /**
  96832. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96833. */
  96834. onNewMeshSelected: Observable<AbstractMesh>;
  96835. /**
  96836. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96837. */
  96838. onNewMeshPicked: Observable<PickingInfo>;
  96839. private _circleEase;
  96840. /**
  96841. * Observable raised before camera teleportation
  96842. */
  96843. onBeforeCameraTeleport: Observable<Vector3>;
  96844. /**
  96845. * Observable raised after camera teleportation
  96846. */
  96847. onAfterCameraTeleport: Observable<Vector3>;
  96848. /**
  96849. * Observable raised when current selected mesh gets unselected
  96850. */
  96851. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96852. private _raySelectionPredicate;
  96853. /**
  96854. * To be optionaly changed by user to define custom ray selection
  96855. */
  96856. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96857. /**
  96858. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96859. */
  96860. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96861. /**
  96862. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96863. */
  96864. teleportationEnabled: boolean;
  96865. private _defaultHeight;
  96866. private _teleportationInitialized;
  96867. private _interactionsEnabled;
  96868. private _interactionsRequested;
  96869. private _displayGaze;
  96870. private _displayLaserPointer;
  96871. /**
  96872. * The mesh used to display where the user is going to teleport.
  96873. */
  96874. /**
  96875. * Sets the mesh to be used to display where the user is going to teleport.
  96876. */
  96877. teleportationTarget: Mesh;
  96878. /**
  96879. * 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
  96880. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96881. * See http://doc.babylonjs.com/resources/baking_transformations
  96882. */
  96883. gazeTrackerMesh: Mesh;
  96884. /**
  96885. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96886. */
  96887. updateGazeTrackerScale: boolean;
  96888. /**
  96889. * If the gaze trackers color should be updated when selecting meshes
  96890. */
  96891. updateGazeTrackerColor: boolean;
  96892. /**
  96893. * The gaze tracking mesh corresponding to the left controller
  96894. */
  96895. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96896. /**
  96897. * The gaze tracking mesh corresponding to the right controller
  96898. */
  96899. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96900. /**
  96901. * If the ray of the gaze should be displayed.
  96902. */
  96903. /**
  96904. * Sets if the ray of the gaze should be displayed.
  96905. */
  96906. displayGaze: boolean;
  96907. /**
  96908. * If the ray of the LaserPointer should be displayed.
  96909. */
  96910. /**
  96911. * Sets if the ray of the LaserPointer should be displayed.
  96912. */
  96913. displayLaserPointer: boolean;
  96914. /**
  96915. * The deviceOrientationCamera used as the camera when not in VR.
  96916. */
  96917. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96918. /**
  96919. * Based on the current WebVR support, returns the current VR camera used.
  96920. */
  96921. readonly currentVRCamera: Nullable<Camera>;
  96922. /**
  96923. * The webVRCamera which is used when in VR.
  96924. */
  96925. readonly webVRCamera: WebVRFreeCamera;
  96926. /**
  96927. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96928. */
  96929. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96930. private readonly _teleportationRequestInitiated;
  96931. /**
  96932. * Defines wether or not Pointer lock should be requested when switching to
  96933. * full screen.
  96934. */
  96935. requestPointerLockOnFullScreen: boolean;
  96936. /**
  96937. * Instantiates a VRExperienceHelper.
  96938. * Helps to quickly add VR support to an existing scene.
  96939. * @param scene The scene the VRExperienceHelper belongs to.
  96940. * @param webVROptions Options to modify the vr experience helper's behavior.
  96941. */
  96942. constructor(scene: Scene,
  96943. /** Options to modify the vr experience helper's behavior. */
  96944. webVROptions?: VRExperienceHelperOptions);
  96945. private _onDefaultMeshLoaded;
  96946. private _onResize;
  96947. private _onFullscreenChange;
  96948. /**
  96949. * Gets a value indicating if we are currently in VR mode.
  96950. */
  96951. readonly isInVRMode: boolean;
  96952. private onVrDisplayPresentChange;
  96953. private onVRDisplayChanged;
  96954. private moveButtonToBottomRight;
  96955. private displayVRButton;
  96956. private updateButtonVisibility;
  96957. private _cachedAngularSensibility;
  96958. /**
  96959. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96960. * Otherwise, will use the fullscreen API.
  96961. */
  96962. enterVR(): void;
  96963. /**
  96964. * Attempt to exit VR, or fullscreen.
  96965. */
  96966. exitVR(): void;
  96967. /**
  96968. * The position of the vr experience helper.
  96969. */
  96970. /**
  96971. * Sets the position of the vr experience helper.
  96972. */
  96973. position: Vector3;
  96974. /**
  96975. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96976. */
  96977. enableInteractions(): void;
  96978. private readonly _noControllerIsActive;
  96979. private beforeRender;
  96980. private _isTeleportationFloor;
  96981. /**
  96982. * Adds a floor mesh to be used for teleportation.
  96983. * @param floorMesh the mesh to be used for teleportation.
  96984. */
  96985. addFloorMesh(floorMesh: Mesh): void;
  96986. /**
  96987. * Removes a floor mesh from being used for teleportation.
  96988. * @param floorMesh the mesh to be removed.
  96989. */
  96990. removeFloorMesh(floorMesh: Mesh): void;
  96991. /**
  96992. * Enables interactions and teleportation using the VR controllers and gaze.
  96993. * @param vrTeleportationOptions options to modify teleportation behavior.
  96994. */
  96995. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96996. private _onNewGamepadConnected;
  96997. private _tryEnableInteractionOnController;
  96998. private _onNewGamepadDisconnected;
  96999. private _enableInteractionOnController;
  97000. private _checkTeleportWithRay;
  97001. private _checkRotate;
  97002. private _checkTeleportBackwards;
  97003. private _enableTeleportationOnController;
  97004. private _createTeleportationCircles;
  97005. private _displayTeleportationTarget;
  97006. private _hideTeleportationTarget;
  97007. private _rotateCamera;
  97008. private _moveTeleportationSelectorTo;
  97009. private _workingVector;
  97010. private _workingQuaternion;
  97011. private _workingMatrix;
  97012. /**
  97013. * Teleports the users feet to the desired location
  97014. * @param location The location where the user's feet should be placed
  97015. */
  97016. teleportCamera(location: Vector3): void;
  97017. private _convertNormalToDirectionOfRay;
  97018. private _castRayAndSelectObject;
  97019. private _notifySelectedMeshUnselected;
  97020. /**
  97021. * Sets the color of the laser ray from the vr controllers.
  97022. * @param color new color for the ray.
  97023. */
  97024. changeLaserColor(color: Color3): void;
  97025. /**
  97026. * Sets the color of the ray from the vr headsets gaze.
  97027. * @param color new color for the ray.
  97028. */
  97029. changeGazeColor(color: Color3): void;
  97030. /**
  97031. * Exits VR and disposes of the vr experience helper
  97032. */
  97033. dispose(): void;
  97034. /**
  97035. * Gets the name of the VRExperienceHelper class
  97036. * @returns "VRExperienceHelper"
  97037. */
  97038. getClassName(): string;
  97039. }
  97040. }
  97041. declare module BABYLON {
  97042. /**
  97043. * Manages an XRSession
  97044. * @see https://doc.babylonjs.com/how_to/webxr
  97045. */
  97046. export class WebXRSessionManager implements IDisposable {
  97047. private scene;
  97048. /**
  97049. * Fires every time a new xrFrame arrives which can be used to update the camera
  97050. */
  97051. onXRFrameObservable: Observable<any>;
  97052. /**
  97053. * Fires when the xr session is ended either by the device or manually done
  97054. */
  97055. onXRSessionEnded: Observable<any>;
  97056. /** @hidden */
  97057. _xrSession: XRSession;
  97058. /** @hidden */
  97059. _frameOfReference: XRFrameOfReference;
  97060. /** @hidden */
  97061. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  97062. /** @hidden */
  97063. _currentXRFrame: Nullable<XRFrame>;
  97064. private _xrNavigator;
  97065. private _xrDevice;
  97066. private _tmpMatrix;
  97067. /**
  97068. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  97069. * @param scene The scene which the session should be created for
  97070. */
  97071. constructor(scene: Scene);
  97072. /**
  97073. * Initializes the manager
  97074. * After initialization enterXR can be called to start an XR session
  97075. * @returns Promise which resolves after it is initialized
  97076. */
  97077. initializeAsync(): Promise<void>;
  97078. /**
  97079. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  97080. * @param sessionCreationOptions xr options to create the session with
  97081. * @param frameOfReferenceType option to configure how the xr pose is expressed
  97082. * @returns Promise which resolves after it enters XR
  97083. */
  97084. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  97085. /**
  97086. * Stops the xrSession and restores the renderloop
  97087. * @returns Promise which resolves after it exits XR
  97088. */
  97089. exitXRAsync(): Promise<void>;
  97090. /**
  97091. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97092. * @param ray ray to cast into the environment
  97093. * @returns Promise which resolves with a collision point in the environment if it exists
  97094. */
  97095. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97096. /**
  97097. * Checks if a session would be supported for the creation options specified
  97098. * @param options creation options to check if they are supported
  97099. * @returns true if supported
  97100. */
  97101. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97102. /**
  97103. * @hidden
  97104. * Converts the render layer of xrSession to a render target
  97105. * @param session session to create render target for
  97106. * @param scene scene the new render target should be created for
  97107. */
  97108. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  97109. /**
  97110. * Disposes of the session manager
  97111. */
  97112. dispose(): void;
  97113. }
  97114. }
  97115. declare module BABYLON {
  97116. /**
  97117. * WebXR Camera which holds the views for the xrSession
  97118. * @see https://doc.babylonjs.com/how_to/webxr
  97119. */
  97120. export class WebXRCamera extends FreeCamera {
  97121. private static _TmpMatrix;
  97122. /**
  97123. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  97124. * @param name the name of the camera
  97125. * @param scene the scene to add the camera to
  97126. */
  97127. constructor(name: string, scene: Scene);
  97128. private _updateNumberOfRigCameras;
  97129. /** @hidden */
  97130. _updateForDualEyeDebugging(pupilDistance?: number): void;
  97131. /**
  97132. * Updates the cameras position from the current pose information of the XR session
  97133. * @param xrSessionManager the session containing pose information
  97134. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  97135. */
  97136. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  97137. }
  97138. }
  97139. declare module BABYLON {
  97140. /**
  97141. * States of the webXR experience
  97142. */
  97143. export enum WebXRState {
  97144. /**
  97145. * Transitioning to being in XR mode
  97146. */
  97147. ENTERING_XR = 0,
  97148. /**
  97149. * Transitioning to non XR mode
  97150. */
  97151. EXITING_XR = 1,
  97152. /**
  97153. * In XR mode and presenting
  97154. */
  97155. IN_XR = 2,
  97156. /**
  97157. * Not entered XR mode
  97158. */
  97159. NOT_IN_XR = 3
  97160. }
  97161. /**
  97162. * Helper class used to enable XR
  97163. * @see https://doc.babylonjs.com/how_to/webxr
  97164. */
  97165. export class WebXRExperienceHelper implements IDisposable {
  97166. private scene;
  97167. /**
  97168. * 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
  97169. */
  97170. container: AbstractMesh;
  97171. /**
  97172. * Camera used to render xr content
  97173. */
  97174. camera: WebXRCamera;
  97175. /**
  97176. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  97177. */
  97178. state: WebXRState;
  97179. private _setState;
  97180. private static _TmpVector;
  97181. /**
  97182. * Fires when the state of the experience helper has changed
  97183. */
  97184. onStateChangedObservable: Observable<WebXRState>;
  97185. /** @hidden */
  97186. _sessionManager: WebXRSessionManager;
  97187. private _nonVRCamera;
  97188. private _originalSceneAutoClear;
  97189. private _supported;
  97190. /**
  97191. * Creates the experience helper
  97192. * @param scene the scene to attach the experience helper to
  97193. * @returns a promise for the experience helper
  97194. */
  97195. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  97196. /**
  97197. * Creates a WebXRExperienceHelper
  97198. * @param scene The scene the helper should be created in
  97199. */
  97200. private constructor();
  97201. /**
  97202. * Exits XR mode and returns the scene to its original state
  97203. * @returns promise that resolves after xr mode has exited
  97204. */
  97205. exitXRAsync(): Promise<void>;
  97206. /**
  97207. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  97208. * @param sessionCreationOptions options for the XR session
  97209. * @param frameOfReference frame of reference of the XR session
  97210. * @returns promise that resolves after xr mode has entered
  97211. */
  97212. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  97213. /**
  97214. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97215. * @param ray ray to cast into the environment
  97216. * @returns Promise which resolves with a collision point in the environment if it exists
  97217. */
  97218. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97219. /**
  97220. * Updates the global position of the camera by moving the camera's container
  97221. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  97222. * @param position The desired global position of the camera
  97223. */
  97224. setPositionOfCameraUsingContainer(position: Vector3): void;
  97225. /**
  97226. * Rotates the xr camera by rotating the camera's container around the camera's position
  97227. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  97228. * @param rotation the desired quaternion rotation to apply to the camera
  97229. */
  97230. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  97231. /**
  97232. * Checks if the creation options are supported by the xr session
  97233. * @param options creation options
  97234. * @returns true if supported
  97235. */
  97236. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97237. /**
  97238. * Disposes of the experience helper
  97239. */
  97240. dispose(): void;
  97241. }
  97242. }
  97243. declare module BABYLON {
  97244. /**
  97245. * Button which can be used to enter a different mode of XR
  97246. */
  97247. export class WebXREnterExitUIButton {
  97248. /** button element */
  97249. element: HTMLElement;
  97250. /** XR initialization options for the button */
  97251. initializationOptions: XRSessionCreationOptions;
  97252. /**
  97253. * Creates a WebXREnterExitUIButton
  97254. * @param element button element
  97255. * @param initializationOptions XR initialization options for the button
  97256. */
  97257. constructor(
  97258. /** button element */
  97259. element: HTMLElement,
  97260. /** XR initialization options for the button */
  97261. initializationOptions: XRSessionCreationOptions);
  97262. /**
  97263. * Overwritable function which can be used to update the button's visuals when the state changes
  97264. * @param activeButton the current active button in the UI
  97265. */
  97266. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  97267. }
  97268. /**
  97269. * Options to create the webXR UI
  97270. */
  97271. export class WebXREnterExitUIOptions {
  97272. /**
  97273. * Context to enter xr with
  97274. */
  97275. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  97276. /**
  97277. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  97278. */
  97279. customButtons?: Array<WebXREnterExitUIButton>;
  97280. }
  97281. /**
  97282. * UI to allow the user to enter/exit XR mode
  97283. */
  97284. export class WebXREnterExitUI implements IDisposable {
  97285. private scene;
  97286. private _overlay;
  97287. private _buttons;
  97288. private _activeButton;
  97289. /**
  97290. * Fired every time the active button is changed.
  97291. *
  97292. * When xr is entered via a button that launches xr that button will be the callback parameter
  97293. *
  97294. * When exiting xr the callback parameter will be null)
  97295. */
  97296. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  97297. /**
  97298. * Creates UI to allow the user to enter/exit XR mode
  97299. * @param scene the scene to add the ui to
  97300. * @param helper the xr experience helper to enter/exit xr with
  97301. * @param options options to configure the UI
  97302. * @returns the created ui
  97303. */
  97304. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  97305. private constructor();
  97306. private _updateButtons;
  97307. /**
  97308. * Disposes of the object
  97309. */
  97310. dispose(): void;
  97311. }
  97312. }
  97313. declare module BABYLON {
  97314. /**
  97315. * Represents an XR input
  97316. */
  97317. export class WebXRController {
  97318. /**
  97319. * 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
  97320. */
  97321. grip?: AbstractMesh;
  97322. /**
  97323. * Pointer which can be used to select objects or attach a visible laser to
  97324. */
  97325. pointer: AbstractMesh;
  97326. /**
  97327. * Creates the controller
  97328. * @see https://doc.babylonjs.com/how_to/webxr
  97329. * @param scene the scene which the controller should be associated to
  97330. */
  97331. constructor(scene: Scene);
  97332. /**
  97333. * Disposes of the object
  97334. */
  97335. dispose(): void;
  97336. }
  97337. /**
  97338. * XR input used to track XR inputs such as controllers/rays
  97339. */
  97340. export class WebXRInput implements IDisposable {
  97341. private helper;
  97342. /**
  97343. * XR controllers being tracked
  97344. */
  97345. controllers: Array<WebXRController>;
  97346. private _tmpMatrix;
  97347. private _frameObserver;
  97348. /**
  97349. * Initializes the WebXRInput
  97350. * @param helper experience helper which the input should be created for
  97351. */
  97352. constructor(helper: WebXRExperienceHelper);
  97353. /**
  97354. * Disposes of the object
  97355. */
  97356. dispose(): void;
  97357. }
  97358. }
  97359. declare module BABYLON {
  97360. /**
  97361. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97362. */
  97363. export class WebXRManagedOutputCanvas implements IDisposable {
  97364. private _canvas;
  97365. /**
  97366. * xrpresent context of the canvas which can be used to display/mirror xr content
  97367. */
  97368. canvasContext: Nullable<WebGLRenderingContext>;
  97369. /**
  97370. * Initializes the canvas to be added/removed upon entering/exiting xr
  97371. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97372. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97373. */
  97374. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97375. /**
  97376. * Disposes of the object
  97377. */
  97378. dispose(): void;
  97379. private _setManagedOutputCanvas;
  97380. private _addCanvas;
  97381. private _removeCanvas;
  97382. }
  97383. }
  97384. declare module BABYLON {
  97385. /**
  97386. * Contains an array of blocks representing the octree
  97387. */
  97388. export interface IOctreeContainer<T> {
  97389. /**
  97390. * Blocks within the octree
  97391. */
  97392. blocks: Array<OctreeBlock<T>>;
  97393. }
  97394. /**
  97395. * Class used to store a cell in an octree
  97396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97397. */
  97398. export class OctreeBlock<T> {
  97399. /**
  97400. * Gets the content of the current block
  97401. */
  97402. entries: T[];
  97403. /**
  97404. * Gets the list of block children
  97405. */
  97406. blocks: Array<OctreeBlock<T>>;
  97407. private _depth;
  97408. private _maxDepth;
  97409. private _capacity;
  97410. private _minPoint;
  97411. private _maxPoint;
  97412. private _boundingVectors;
  97413. private _creationFunc;
  97414. /**
  97415. * Creates a new block
  97416. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97417. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97418. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97419. * @param depth defines the current depth of this block in the octree
  97420. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97421. * @param creationFunc defines a callback to call when an element is added to the block
  97422. */
  97423. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97424. /**
  97425. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97426. */
  97427. readonly capacity: number;
  97428. /**
  97429. * Gets the minimum vector (in world space) of the block's bounding box
  97430. */
  97431. readonly minPoint: Vector3;
  97432. /**
  97433. * Gets the maximum vector (in world space) of the block's bounding box
  97434. */
  97435. readonly maxPoint: Vector3;
  97436. /**
  97437. * Add a new element to this block
  97438. * @param entry defines the element to add
  97439. */
  97440. addEntry(entry: T): void;
  97441. /**
  97442. * Remove an element from this block
  97443. * @param entry defines the element to remove
  97444. */
  97445. removeEntry(entry: T): void;
  97446. /**
  97447. * Add an array of elements to this block
  97448. * @param entries defines the array of elements to add
  97449. */
  97450. addEntries(entries: T[]): void;
  97451. /**
  97452. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97453. * @param frustumPlanes defines the frustum planes to test
  97454. * @param selection defines the array to store current content if selection is positive
  97455. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97456. */
  97457. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97458. /**
  97459. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97460. * @param sphereCenter defines the bounding sphere center
  97461. * @param sphereRadius defines the bounding sphere radius
  97462. * @param selection defines the array to store current content if selection is positive
  97463. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97464. */
  97465. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97466. /**
  97467. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97468. * @param ray defines the ray to test with
  97469. * @param selection defines the array to store current content if selection is positive
  97470. */
  97471. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97472. /**
  97473. * Subdivide the content into child blocks (this block will then be empty)
  97474. */
  97475. createInnerBlocks(): void;
  97476. /**
  97477. * @hidden
  97478. */
  97479. 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;
  97480. }
  97481. }
  97482. declare module BABYLON {
  97483. /**
  97484. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97485. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97486. */
  97487. export class Octree<T> {
  97488. /** 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.) */
  97489. maxDepth: number;
  97490. /**
  97491. * Blocks within the octree containing objects
  97492. */
  97493. blocks: Array<OctreeBlock<T>>;
  97494. /**
  97495. * Content stored in the octree
  97496. */
  97497. dynamicContent: T[];
  97498. private _maxBlockCapacity;
  97499. private _selectionContent;
  97500. private _creationFunc;
  97501. /**
  97502. * Creates a octree
  97503. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97504. * @param creationFunc function to be used to instatiate the octree
  97505. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97506. * @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.)
  97507. */
  97508. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97509. /** 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.) */
  97510. maxDepth?: number);
  97511. /**
  97512. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97513. * @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);
  97514. * @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);
  97515. * @param entries meshes to be added to the octree blocks
  97516. */
  97517. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97518. /**
  97519. * Adds a mesh to the octree
  97520. * @param entry Mesh to add to the octree
  97521. */
  97522. addMesh(entry: T): void;
  97523. /**
  97524. * Remove an element from the octree
  97525. * @param entry defines the element to remove
  97526. */
  97527. removeMesh(entry: T): void;
  97528. /**
  97529. * Selects an array of meshes within the frustum
  97530. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97531. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97532. * @returns array of meshes within the frustum
  97533. */
  97534. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97535. /**
  97536. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97537. * @param sphereCenter defines the bounding sphere center
  97538. * @param sphereRadius defines the bounding sphere radius
  97539. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97540. * @returns an array of objects that intersect the sphere
  97541. */
  97542. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97543. /**
  97544. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97545. * @param ray defines the ray to test with
  97546. * @returns array of intersected objects
  97547. */
  97548. intersectsRay(ray: Ray): SmartArray<T>;
  97549. /**
  97550. * Adds a mesh into the octree block if it intersects the block
  97551. */
  97552. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97553. /**
  97554. * Adds a submesh into the octree block if it intersects the block
  97555. */
  97556. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97557. }
  97558. }
  97559. declare module BABYLON {
  97560. interface Scene {
  97561. /**
  97562. * @hidden
  97563. * Backing Filed
  97564. */
  97565. _selectionOctree: Octree<AbstractMesh>;
  97566. /**
  97567. * Gets the octree used to boost mesh selection (picking)
  97568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97569. */
  97570. selectionOctree: Octree<AbstractMesh>;
  97571. /**
  97572. * Creates or updates the octree used to boost selection (picking)
  97573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97574. * @param maxCapacity defines the maximum capacity per leaf
  97575. * @param maxDepth defines the maximum depth of the octree
  97576. * @returns an octree of AbstractMesh
  97577. */
  97578. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97579. }
  97580. interface AbstractMesh {
  97581. /**
  97582. * @hidden
  97583. * Backing Field
  97584. */
  97585. _submeshesOctree: Octree<SubMesh>;
  97586. /**
  97587. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97588. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97589. * @param maxCapacity defines the maximum size of each block (64 by default)
  97590. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97591. * @returns the new octree
  97592. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97594. */
  97595. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97596. }
  97597. /**
  97598. * Defines the octree scene component responsible to manage any octrees
  97599. * in a given scene.
  97600. */
  97601. export class OctreeSceneComponent {
  97602. /**
  97603. * The component name helpfull to identify the component in the list of scene components.
  97604. */
  97605. readonly name: string;
  97606. /**
  97607. * The scene the component belongs to.
  97608. */
  97609. scene: Scene;
  97610. /**
  97611. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97612. */
  97613. readonly checksIsEnabled: boolean;
  97614. /**
  97615. * Creates a new instance of the component for the given scene
  97616. * @param scene Defines the scene to register the component in
  97617. */
  97618. constructor(scene: Scene);
  97619. /**
  97620. * Registers the component in a given scene
  97621. */
  97622. register(): void;
  97623. /**
  97624. * Return the list of active meshes
  97625. * @returns the list of active meshes
  97626. */
  97627. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97628. /**
  97629. * Return the list of active sub meshes
  97630. * @param mesh The mesh to get the candidates sub meshes from
  97631. * @returns the list of active sub meshes
  97632. */
  97633. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97634. private _tempRay;
  97635. /**
  97636. * Return the list of sub meshes intersecting with a given local ray
  97637. * @param mesh defines the mesh to find the submesh for
  97638. * @param localRay defines the ray in local space
  97639. * @returns the list of intersecting sub meshes
  97640. */
  97641. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97642. /**
  97643. * Return the list of sub meshes colliding with a collider
  97644. * @param mesh defines the mesh to find the submesh for
  97645. * @param collider defines the collider to evaluate the collision against
  97646. * @returns the list of colliding sub meshes
  97647. */
  97648. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97649. /**
  97650. * Rebuilds the elements related to this component in case of
  97651. * context lost for instance.
  97652. */
  97653. rebuild(): void;
  97654. /**
  97655. * Disposes the component and the associated ressources.
  97656. */
  97657. dispose(): void;
  97658. }
  97659. }
  97660. declare module BABYLON {
  97661. /**
  97662. * Class containing static functions to help procedurally build meshes
  97663. */
  97664. export class LinesBuilder {
  97665. /**
  97666. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97667. * * 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
  97668. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97669. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97670. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97671. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97672. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97673. * * 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
  97674. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97677. * @param name defines the name of the new line system
  97678. * @param options defines the options used to create the line system
  97679. * @param scene defines the hosting scene
  97680. * @returns a new line system mesh
  97681. */
  97682. static CreateLineSystem(name: string, options: {
  97683. lines: Vector3[][];
  97684. updatable?: boolean;
  97685. instance?: Nullable<LinesMesh>;
  97686. colors?: Nullable<Color4[][]>;
  97687. useVertexAlpha?: boolean;
  97688. }, scene: Nullable<Scene>): LinesMesh;
  97689. /**
  97690. * Creates a line mesh
  97691. * 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
  97692. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97693. * * The parameter `points` is an array successive Vector3
  97694. * * 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
  97695. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97696. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97697. * * When updating an instance, remember that only point positions can change, not the number of points
  97698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97700. * @param name defines the name of the new line system
  97701. * @param options defines the options used to create the line system
  97702. * @param scene defines the hosting scene
  97703. * @returns a new line mesh
  97704. */
  97705. static CreateLines(name: string, options: {
  97706. points: Vector3[];
  97707. updatable?: boolean;
  97708. instance?: Nullable<LinesMesh>;
  97709. colors?: Color4[];
  97710. useVertexAlpha?: boolean;
  97711. }, scene?: Nullable<Scene>): LinesMesh;
  97712. /**
  97713. * Creates a dashed line mesh
  97714. * * 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
  97715. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97716. * * The parameter `points` is an array successive Vector3
  97717. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97718. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97719. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97720. * * 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
  97721. * * When updating an instance, remember that only point positions can change, not the number of points
  97722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97723. * @param name defines the name of the mesh
  97724. * @param options defines the options used to create the mesh
  97725. * @param scene defines the hosting scene
  97726. * @returns the dashed line mesh
  97727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97728. */
  97729. static CreateDashedLines(name: string, options: {
  97730. points: Vector3[];
  97731. dashSize?: number;
  97732. gapSize?: number;
  97733. dashNb?: number;
  97734. updatable?: boolean;
  97735. instance?: LinesMesh;
  97736. }, scene?: Nullable<Scene>): LinesMesh;
  97737. }
  97738. }
  97739. declare module BABYLON {
  97740. /**
  97741. * Renders a layer on top of an existing scene
  97742. */
  97743. export class UtilityLayerRenderer implements IDisposable {
  97744. /** the original scene that will be rendered on top of */
  97745. originalScene: Scene;
  97746. private _pointerCaptures;
  97747. private _lastPointerEvents;
  97748. private static _DefaultUtilityLayer;
  97749. private static _DefaultKeepDepthUtilityLayer;
  97750. /**
  97751. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97752. */
  97753. pickUtilitySceneFirst: boolean;
  97754. /**
  97755. * 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)
  97756. */
  97757. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97758. /**
  97759. * 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)
  97760. */
  97761. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97762. /**
  97763. * The scene that is rendered on top of the original scene
  97764. */
  97765. utilityLayerScene: Scene;
  97766. /**
  97767. * If the utility layer should automatically be rendered on top of existing scene
  97768. */
  97769. shouldRender: boolean;
  97770. /**
  97771. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97772. */
  97773. onlyCheckPointerDownEvents: boolean;
  97774. /**
  97775. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97776. */
  97777. processAllEvents: boolean;
  97778. /**
  97779. * Observable raised when the pointer move from the utility layer scene to the main scene
  97780. */
  97781. onPointerOutObservable: Observable<number>;
  97782. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97783. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97784. private _afterRenderObserver;
  97785. private _sceneDisposeObserver;
  97786. private _originalPointerObserver;
  97787. /**
  97788. * Instantiates a UtilityLayerRenderer
  97789. * @param originalScene the original scene that will be rendered on top of
  97790. * @param handleEvents boolean indicating if the utility layer should handle events
  97791. */
  97792. constructor(
  97793. /** the original scene that will be rendered on top of */
  97794. originalScene: Scene, handleEvents?: boolean);
  97795. private _notifyObservers;
  97796. /**
  97797. * Renders the utility layers scene on top of the original scene
  97798. */
  97799. render(): void;
  97800. /**
  97801. * Disposes of the renderer
  97802. */
  97803. dispose(): void;
  97804. private _updateCamera;
  97805. }
  97806. }
  97807. declare module BABYLON {
  97808. /**
  97809. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97810. */
  97811. export class Gizmo implements IDisposable {
  97812. /** The utility layer the gizmo will be added to */
  97813. gizmoLayer: UtilityLayerRenderer;
  97814. /**
  97815. * The root mesh of the gizmo
  97816. */
  97817. _rootMesh: Mesh;
  97818. private _attachedMesh;
  97819. /**
  97820. * Ratio for the scale of the gizmo (Default: 1)
  97821. */
  97822. scaleRatio: number;
  97823. private _tmpMatrix;
  97824. /**
  97825. * If a custom mesh has been set (Default: false)
  97826. */
  97827. protected _customMeshSet: boolean;
  97828. /**
  97829. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97830. * * When set, interactions will be enabled
  97831. */
  97832. attachedMesh: Nullable<AbstractMesh>;
  97833. /**
  97834. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97835. * @param mesh The mesh to replace the default mesh of the gizmo
  97836. */
  97837. setCustomMesh(mesh: Mesh): void;
  97838. /**
  97839. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97840. */
  97841. updateGizmoRotationToMatchAttachedMesh: boolean;
  97842. /**
  97843. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97844. */
  97845. updateGizmoPositionToMatchAttachedMesh: boolean;
  97846. /**
  97847. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97848. */
  97849. protected _updateScale: boolean;
  97850. protected _interactionsEnabled: boolean;
  97851. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97852. private _beforeRenderObserver;
  97853. /**
  97854. * Creates a gizmo
  97855. * @param gizmoLayer The utility layer the gizmo will be added to
  97856. */
  97857. constructor(
  97858. /** The utility layer the gizmo will be added to */
  97859. gizmoLayer?: UtilityLayerRenderer);
  97860. private _tempVector;
  97861. /**
  97862. * @hidden
  97863. * Updates the gizmo to match the attached mesh's position/rotation
  97864. */
  97865. protected _update(): void;
  97866. /**
  97867. * Disposes of the gizmo
  97868. */
  97869. dispose(): void;
  97870. }
  97871. }
  97872. declare module BABYLON {
  97873. /**
  97874. * Single axis drag gizmo
  97875. */
  97876. export class AxisDragGizmo extends Gizmo {
  97877. /**
  97878. * Drag behavior responsible for the gizmos dragging interactions
  97879. */
  97880. dragBehavior: PointerDragBehavior;
  97881. private _pointerObserver;
  97882. /**
  97883. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97884. */
  97885. snapDistance: number;
  97886. /**
  97887. * Event that fires each time the gizmo snaps to a new location.
  97888. * * snapDistance is the the change in distance
  97889. */
  97890. onSnapObservable: Observable<{
  97891. snapDistance: number;
  97892. }>;
  97893. /** @hidden */
  97894. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97895. /** @hidden */
  97896. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97897. /**
  97898. * Creates an AxisDragGizmo
  97899. * @param gizmoLayer The utility layer the gizmo will be added to
  97900. * @param dragAxis The axis which the gizmo will be able to drag on
  97901. * @param color The color of the gizmo
  97902. */
  97903. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97904. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97905. /**
  97906. * Disposes of the gizmo
  97907. */
  97908. dispose(): void;
  97909. }
  97910. }
  97911. declare module BABYLON.Debug {
  97912. /**
  97913. * The Axes viewer will show 3 axes in a specific point in space
  97914. */
  97915. export class AxesViewer {
  97916. private _xAxis;
  97917. private _yAxis;
  97918. private _zAxis;
  97919. private _scaleLinesFactor;
  97920. private _instanced;
  97921. /**
  97922. * Gets the hosting scene
  97923. */
  97924. scene: Scene;
  97925. /**
  97926. * Gets or sets a number used to scale line length
  97927. */
  97928. scaleLines: number;
  97929. /** Gets the node hierarchy used to render x-axis */
  97930. readonly xAxis: TransformNode;
  97931. /** Gets the node hierarchy used to render y-axis */
  97932. readonly yAxis: TransformNode;
  97933. /** Gets the node hierarchy used to render z-axis */
  97934. readonly zAxis: TransformNode;
  97935. /**
  97936. * Creates a new AxesViewer
  97937. * @param scene defines the hosting scene
  97938. * @param scaleLines defines a number used to scale line length (1 by default)
  97939. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97940. * @param xAxis defines the node hierarchy used to render the x-axis
  97941. * @param yAxis defines the node hierarchy used to render the y-axis
  97942. * @param zAxis defines the node hierarchy used to render the z-axis
  97943. */
  97944. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97945. /**
  97946. * Force the viewer to update
  97947. * @param position defines the position of the viewer
  97948. * @param xaxis defines the x axis of the viewer
  97949. * @param yaxis defines the y axis of the viewer
  97950. * @param zaxis defines the z axis of the viewer
  97951. */
  97952. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97953. /**
  97954. * Creates an instance of this axes viewer.
  97955. * @returns a new axes viewer with instanced meshes
  97956. */
  97957. createInstance(): AxesViewer;
  97958. /** Releases resources */
  97959. dispose(): void;
  97960. private static _SetRenderingGroupId;
  97961. }
  97962. }
  97963. declare module BABYLON.Debug {
  97964. /**
  97965. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97966. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97967. */
  97968. export class BoneAxesViewer extends AxesViewer {
  97969. /**
  97970. * Gets or sets the target mesh where to display the axes viewer
  97971. */
  97972. mesh: Nullable<Mesh>;
  97973. /**
  97974. * Gets or sets the target bone where to display the axes viewer
  97975. */
  97976. bone: Nullable<Bone>;
  97977. /** Gets current position */
  97978. pos: Vector3;
  97979. /** Gets direction of X axis */
  97980. xaxis: Vector3;
  97981. /** Gets direction of Y axis */
  97982. yaxis: Vector3;
  97983. /** Gets direction of Z axis */
  97984. zaxis: Vector3;
  97985. /**
  97986. * Creates a new BoneAxesViewer
  97987. * @param scene defines the hosting scene
  97988. * @param bone defines the target bone
  97989. * @param mesh defines the target mesh
  97990. * @param scaleLines defines a scaling factor for line length (1 by default)
  97991. */
  97992. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97993. /**
  97994. * Force the viewer to update
  97995. */
  97996. update(): void;
  97997. /** Releases resources */
  97998. dispose(): void;
  97999. }
  98000. }
  98001. declare module BABYLON {
  98002. /**
  98003. * Interface used to define scene explorer extensibility option
  98004. */
  98005. export interface IExplorerExtensibilityOption {
  98006. /**
  98007. * Define the option label
  98008. */
  98009. label: string;
  98010. /**
  98011. * Defines the action to execute on click
  98012. */
  98013. action: (entity: any) => void;
  98014. }
  98015. /**
  98016. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98017. */
  98018. export interface IExplorerExtensibilityGroup {
  98019. /**
  98020. * Defines a predicate to test if a given type mut be extended
  98021. */
  98022. predicate: (entity: any) => boolean;
  98023. /**
  98024. * Gets the list of options added to a type
  98025. */
  98026. entries: IExplorerExtensibilityOption[];
  98027. }
  98028. /**
  98029. * Interface used to define the options to use to create the Inspector
  98030. */
  98031. export interface IInspectorOptions {
  98032. /**
  98033. * Display in overlay mode (default: false)
  98034. */
  98035. overlay?: boolean;
  98036. /**
  98037. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98038. */
  98039. globalRoot?: HTMLElement;
  98040. /**
  98041. * Display the Scene explorer
  98042. */
  98043. showExplorer?: boolean;
  98044. /**
  98045. * Display the property inspector
  98046. */
  98047. showInspector?: boolean;
  98048. /**
  98049. * Display in embed mode (both panes on the right)
  98050. */
  98051. embedMode?: boolean;
  98052. /**
  98053. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  98054. */
  98055. handleResize?: boolean;
  98056. /**
  98057. * Allow the panes to popup (default: true)
  98058. */
  98059. enablePopup?: boolean;
  98060. /**
  98061. * Allow the panes to be closed by users (default: true)
  98062. */
  98063. enableClose?: boolean;
  98064. /**
  98065. * Optional list of extensibility entries
  98066. */
  98067. explorerExtensibility?: IExplorerExtensibilityGroup[];
  98068. /**
  98069. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  98070. */
  98071. inspectorURL?: string;
  98072. }
  98073. interface Scene {
  98074. /**
  98075. * @hidden
  98076. * Backing field
  98077. */
  98078. _debugLayer: DebugLayer;
  98079. /**
  98080. * Gets the debug layer (aka Inspector) associated with the scene
  98081. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98082. */
  98083. debugLayer: DebugLayer;
  98084. }
  98085. /**
  98086. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98087. * what is happening in your scene
  98088. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98089. */
  98090. export class DebugLayer {
  98091. /**
  98092. * Define the url to get the inspector script from.
  98093. * By default it uses the babylonjs CDN.
  98094. * @ignoreNaming
  98095. */
  98096. static InspectorURL: string;
  98097. private _scene;
  98098. private BJSINSPECTOR;
  98099. /**
  98100. * Observable triggered when a property is changed through the inspector.
  98101. */
  98102. onPropertyChangedObservable: Observable<{
  98103. object: any;
  98104. property: string;
  98105. value: any;
  98106. initialValue: any;
  98107. }>;
  98108. /**
  98109. * Instantiates a new debug layer.
  98110. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98111. * what is happening in your scene
  98112. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98113. * @param scene Defines the scene to inspect
  98114. */
  98115. constructor(scene: Scene);
  98116. /** Creates the inspector window. */
  98117. private _createInspector;
  98118. /**
  98119. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  98120. * @param entity defines the entity to select
  98121. * @param lineContainerTitle defines the specific block to highlight
  98122. */
  98123. select(entity: any, lineContainerTitle?: string): void;
  98124. /** Get the inspector from bundle or global */
  98125. private _getGlobalInspector;
  98126. /**
  98127. * Get if the inspector is visible or not.
  98128. * @returns true if visible otherwise, false
  98129. */
  98130. isVisible(): boolean;
  98131. /**
  98132. * Hide the inspector and close its window.
  98133. */
  98134. hide(): void;
  98135. /**
  98136. * Launch the debugLayer.
  98137. * @param config Define the configuration of the inspector
  98138. * @return a promise fulfilled when the debug layer is visible
  98139. */
  98140. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98141. }
  98142. }
  98143. declare module BABYLON {
  98144. /**
  98145. * Class containing static functions to help procedurally build meshes
  98146. */
  98147. export class BoxBuilder {
  98148. /**
  98149. * Creates a box mesh
  98150. * * The parameter `size` sets the size (float) of each box side (default 1)
  98151. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98152. * * 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)
  98153. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98157. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98158. * @param name defines the name of the mesh
  98159. * @param options defines the options used to create the mesh
  98160. * @param scene defines the hosting scene
  98161. * @returns the box mesh
  98162. */
  98163. static CreateBox(name: string, options: {
  98164. size?: number;
  98165. width?: number;
  98166. height?: number;
  98167. depth?: number;
  98168. faceUV?: Vector4[];
  98169. faceColors?: Color4[];
  98170. sideOrientation?: number;
  98171. frontUVs?: Vector4;
  98172. backUVs?: Vector4;
  98173. updatable?: boolean;
  98174. }, scene?: Nullable<Scene>): Mesh;
  98175. }
  98176. }
  98177. declare module BABYLON {
  98178. /**
  98179. * Class containing static functions to help procedurally build meshes
  98180. */
  98181. export class SphereBuilder {
  98182. /**
  98183. * Creates a sphere mesh
  98184. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  98185. * * 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`)
  98186. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  98187. * * 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
  98188. * * 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)
  98189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98192. * @param name defines the name of the mesh
  98193. * @param options defines the options used to create the mesh
  98194. * @param scene defines the hosting scene
  98195. * @returns the sphere mesh
  98196. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  98197. */
  98198. static CreateSphere(name: string, options: {
  98199. segments?: number;
  98200. diameter?: number;
  98201. diameterX?: number;
  98202. diameterY?: number;
  98203. diameterZ?: number;
  98204. arc?: number;
  98205. slice?: number;
  98206. sideOrientation?: number;
  98207. frontUVs?: Vector4;
  98208. backUVs?: Vector4;
  98209. updatable?: boolean;
  98210. }, scene: any): Mesh;
  98211. }
  98212. }
  98213. declare module BABYLON.Debug {
  98214. /**
  98215. * Used to show the physics impostor around the specific mesh
  98216. */
  98217. export class PhysicsViewer {
  98218. /** @hidden */
  98219. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  98220. /** @hidden */
  98221. protected _meshes: Array<Nullable<AbstractMesh>>;
  98222. /** @hidden */
  98223. protected _scene: Nullable<Scene>;
  98224. /** @hidden */
  98225. protected _numMeshes: number;
  98226. /** @hidden */
  98227. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  98228. private _renderFunction;
  98229. private _utilityLayer;
  98230. private _debugBoxMesh;
  98231. private _debugSphereMesh;
  98232. private _debugMaterial;
  98233. /**
  98234. * Creates a new PhysicsViewer
  98235. * @param scene defines the hosting scene
  98236. */
  98237. constructor(scene: Scene);
  98238. /** @hidden */
  98239. protected _updateDebugMeshes(): void;
  98240. /**
  98241. * Renders a specified physic impostor
  98242. * @param impostor defines the impostor to render
  98243. * @returns the new debug mesh used to render the impostor
  98244. */
  98245. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  98246. /**
  98247. * Hides a specified physic impostor
  98248. * @param impostor defines the impostor to hide
  98249. */
  98250. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  98251. private _getDebugMaterial;
  98252. private _getDebugBoxMesh;
  98253. private _getDebugSphereMesh;
  98254. private _getDebugMesh;
  98255. /** Releases all resources */
  98256. dispose(): void;
  98257. }
  98258. }
  98259. declare module BABYLON {
  98260. /**
  98261. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98262. * in order to better appreciate the issue one might have.
  98263. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98264. */
  98265. export class RayHelper {
  98266. /**
  98267. * Defines the ray we are currently tryin to visualize.
  98268. */
  98269. ray: Nullable<Ray>;
  98270. private _renderPoints;
  98271. private _renderLine;
  98272. private _renderFunction;
  98273. private _scene;
  98274. private _updateToMeshFunction;
  98275. private _attachedToMesh;
  98276. private _meshSpaceDirection;
  98277. private _meshSpaceOrigin;
  98278. /**
  98279. * Helper function to create a colored helper in a scene in one line.
  98280. * @param ray Defines the ray we are currently tryin to visualize
  98281. * @param scene Defines the scene the ray is used in
  98282. * @param color Defines the color we want to see the ray in
  98283. * @returns The newly created ray helper.
  98284. */
  98285. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  98286. /**
  98287. * Instantiate a new ray helper.
  98288. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98289. * in order to better appreciate the issue one might have.
  98290. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98291. * @param ray Defines the ray we are currently tryin to visualize
  98292. */
  98293. constructor(ray: Ray);
  98294. /**
  98295. * Shows the ray we are willing to debug.
  98296. * @param scene Defines the scene the ray needs to be rendered in
  98297. * @param color Defines the color the ray needs to be rendered in
  98298. */
  98299. show(scene: Scene, color?: Color3): void;
  98300. /**
  98301. * Hides the ray we are debugging.
  98302. */
  98303. hide(): void;
  98304. private _render;
  98305. /**
  98306. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  98307. * @param mesh Defines the mesh we want the helper attached to
  98308. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  98309. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  98310. * @param length Defines the length of the ray
  98311. */
  98312. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  98313. /**
  98314. * Detach the ray helper from the mesh it has previously been attached to.
  98315. */
  98316. detachFromMesh(): void;
  98317. private _updateToMesh;
  98318. /**
  98319. * Dispose the helper and release its associated resources.
  98320. */
  98321. dispose(): void;
  98322. }
  98323. }
  98324. declare module BABYLON.Debug {
  98325. /**
  98326. * Class used to render a debug view of a given skeleton
  98327. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  98328. */
  98329. export class SkeletonViewer {
  98330. /** defines the skeleton to render */
  98331. skeleton: Skeleton;
  98332. /** defines the mesh attached to the skeleton */
  98333. mesh: AbstractMesh;
  98334. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98335. autoUpdateBonesMatrices: boolean;
  98336. /** defines the rendering group id to use with the viewer */
  98337. renderingGroupId: number;
  98338. /** Gets or sets the color used to render the skeleton */
  98339. color: Color3;
  98340. private _scene;
  98341. private _debugLines;
  98342. private _debugMesh;
  98343. private _isEnabled;
  98344. private _renderFunction;
  98345. private _utilityLayer;
  98346. /**
  98347. * Returns the mesh used to render the bones
  98348. */
  98349. readonly debugMesh: Nullable<LinesMesh>;
  98350. /**
  98351. * Creates a new SkeletonViewer
  98352. * @param skeleton defines the skeleton to render
  98353. * @param mesh defines the mesh attached to the skeleton
  98354. * @param scene defines the hosting scene
  98355. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98356. * @param renderingGroupId defines the rendering group id to use with the viewer
  98357. */
  98358. constructor(
  98359. /** defines the skeleton to render */
  98360. skeleton: Skeleton,
  98361. /** defines the mesh attached to the skeleton */
  98362. mesh: AbstractMesh, scene: Scene,
  98363. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98364. autoUpdateBonesMatrices?: boolean,
  98365. /** defines the rendering group id to use with the viewer */
  98366. renderingGroupId?: number);
  98367. /** Gets or sets a boolean indicating if the viewer is enabled */
  98368. isEnabled: boolean;
  98369. private _getBonePosition;
  98370. private _getLinesForBonesWithLength;
  98371. private _getLinesForBonesNoLength;
  98372. /** Update the viewer to sync with current skeleton state */
  98373. update(): void;
  98374. /** Release associated resources */
  98375. dispose(): void;
  98376. }
  98377. }
  98378. declare module BABYLON {
  98379. /**
  98380. * Options to create the null engine
  98381. */
  98382. export class NullEngineOptions {
  98383. /**
  98384. * Render width (Default: 512)
  98385. */
  98386. renderWidth: number;
  98387. /**
  98388. * Render height (Default: 256)
  98389. */
  98390. renderHeight: number;
  98391. /**
  98392. * Texture size (Default: 512)
  98393. */
  98394. textureSize: number;
  98395. /**
  98396. * If delta time between frames should be constant
  98397. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98398. */
  98399. deterministicLockstep: boolean;
  98400. /**
  98401. * Maximum about of steps between frames (Default: 4)
  98402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98403. */
  98404. lockstepMaxSteps: number;
  98405. }
  98406. /**
  98407. * The null engine class provides support for headless version of babylon.js.
  98408. * This can be used in server side scenario or for testing purposes
  98409. */
  98410. export class NullEngine extends Engine {
  98411. private _options;
  98412. /**
  98413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98414. */
  98415. isDeterministicLockStep(): boolean;
  98416. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98417. getLockstepMaxSteps(): number;
  98418. /**
  98419. * Sets hardware scaling, used to save performance if needed
  98420. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98421. */
  98422. getHardwareScalingLevel(): number;
  98423. constructor(options?: NullEngineOptions);
  98424. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98425. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98426. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98427. getRenderWidth(useScreen?: boolean): number;
  98428. getRenderHeight(useScreen?: boolean): number;
  98429. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98430. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98431. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98432. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98433. bindSamplers(effect: Effect): void;
  98434. enableEffect(effect: Effect): void;
  98435. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98436. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98437. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98438. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98439. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98440. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98441. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98442. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98443. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98444. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98445. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98446. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98447. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98448. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98449. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98450. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98451. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98452. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98453. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98455. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98456. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98457. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98458. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98459. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98460. bindBuffers(vertexBuffers: {
  98461. [key: string]: VertexBuffer;
  98462. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98463. wipeCaches(bruteForce?: boolean): void;
  98464. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98467. /** @hidden */
  98468. _createTexture(): WebGLTexture;
  98469. /** @hidden */
  98470. _releaseTexture(texture: InternalTexture): void;
  98471. 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;
  98472. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98475. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98476. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98477. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98478. areAllEffectsReady(): boolean;
  98479. /**
  98480. * @hidden
  98481. * Get the current error code of the webGL context
  98482. * @returns the error code
  98483. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98484. */
  98485. getError(): number;
  98486. /** @hidden */
  98487. _getUnpackAlignement(): number;
  98488. /** @hidden */
  98489. _unpackFlipY(value: boolean): void;
  98490. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98491. /**
  98492. * Updates a dynamic vertex buffer.
  98493. * @param vertexBuffer the vertex buffer to update
  98494. * @param data the data used to update the vertex buffer
  98495. * @param byteOffset the byte offset of the data (optional)
  98496. * @param byteLength the byte length of the data (optional)
  98497. */
  98498. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98499. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98500. /** @hidden */
  98501. _bindTexture(channel: number, texture: InternalTexture): void;
  98502. /** @hidden */
  98503. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98504. releaseEffects(): void;
  98505. displayLoadingUI(): void;
  98506. hideLoadingUI(): void;
  98507. /** @hidden */
  98508. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98509. /** @hidden */
  98510. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98511. /** @hidden */
  98512. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98513. /** @hidden */
  98514. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98515. }
  98516. }
  98517. declare module BABYLON {
  98518. /** @hidden */
  98519. export class _OcclusionDataStorage {
  98520. /** @hidden */
  98521. occlusionInternalRetryCounter: number;
  98522. /** @hidden */
  98523. isOcclusionQueryInProgress: boolean;
  98524. /** @hidden */
  98525. isOccluded: boolean;
  98526. /** @hidden */
  98527. occlusionRetryCount: number;
  98528. /** @hidden */
  98529. occlusionType: number;
  98530. /** @hidden */
  98531. occlusionQueryAlgorithmType: number;
  98532. }
  98533. interface Engine {
  98534. /**
  98535. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98536. * @return the new query
  98537. */
  98538. createQuery(): WebGLQuery;
  98539. /**
  98540. * Delete and release a webGL query
  98541. * @param query defines the query to delete
  98542. * @return the current engine
  98543. */
  98544. deleteQuery(query: WebGLQuery): Engine;
  98545. /**
  98546. * Check if a given query has resolved and got its value
  98547. * @param query defines the query to check
  98548. * @returns true if the query got its value
  98549. */
  98550. isQueryResultAvailable(query: WebGLQuery): boolean;
  98551. /**
  98552. * Gets the value of a given query
  98553. * @param query defines the query to check
  98554. * @returns the value of the query
  98555. */
  98556. getQueryResult(query: WebGLQuery): number;
  98557. /**
  98558. * Initiates an occlusion query
  98559. * @param algorithmType defines the algorithm to use
  98560. * @param query defines the query to use
  98561. * @returns the current engine
  98562. * @see http://doc.babylonjs.com/features/occlusionquery
  98563. */
  98564. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98565. /**
  98566. * Ends an occlusion query
  98567. * @see http://doc.babylonjs.com/features/occlusionquery
  98568. * @param algorithmType defines the algorithm to use
  98569. * @returns the current engine
  98570. */
  98571. endOcclusionQuery(algorithmType: number): Engine;
  98572. /**
  98573. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98574. * Please note that only one query can be issued at a time
  98575. * @returns a time token used to track the time span
  98576. */
  98577. startTimeQuery(): Nullable<_TimeToken>;
  98578. /**
  98579. * Ends a time query
  98580. * @param token defines the token used to measure the time span
  98581. * @returns the time spent (in ns)
  98582. */
  98583. endTimeQuery(token: _TimeToken): int;
  98584. /** @hidden */
  98585. _currentNonTimestampToken: Nullable<_TimeToken>;
  98586. /** @hidden */
  98587. _createTimeQuery(): WebGLQuery;
  98588. /** @hidden */
  98589. _deleteTimeQuery(query: WebGLQuery): void;
  98590. /** @hidden */
  98591. _getGlAlgorithmType(algorithmType: number): number;
  98592. /** @hidden */
  98593. _getTimeQueryResult(query: WebGLQuery): any;
  98594. /** @hidden */
  98595. _getTimeQueryAvailability(query: WebGLQuery): any;
  98596. }
  98597. interface AbstractMesh {
  98598. /**
  98599. * Backing filed
  98600. * @hidden
  98601. */
  98602. __occlusionDataStorage: _OcclusionDataStorage;
  98603. /**
  98604. * Access property
  98605. * @hidden
  98606. */
  98607. _occlusionDataStorage: _OcclusionDataStorage;
  98608. /**
  98609. * 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.
  98610. * The default value is -1 which means don't break the query and wait till the result
  98611. * @see http://doc.babylonjs.com/features/occlusionquery
  98612. */
  98613. occlusionRetryCount: number;
  98614. /**
  98615. * 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:
  98616. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98617. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98618. * * 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.
  98619. * @see http://doc.babylonjs.com/features/occlusionquery
  98620. */
  98621. occlusionType: number;
  98622. /**
  98623. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98624. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98625. * * 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.
  98626. * @see http://doc.babylonjs.com/features/occlusionquery
  98627. */
  98628. occlusionQueryAlgorithmType: number;
  98629. /**
  98630. * 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
  98631. * @see http://doc.babylonjs.com/features/occlusionquery
  98632. */
  98633. isOccluded: boolean;
  98634. /**
  98635. * Flag to check the progress status of the query
  98636. * @see http://doc.babylonjs.com/features/occlusionquery
  98637. */
  98638. isOcclusionQueryInProgress: boolean;
  98639. }
  98640. }
  98641. declare module BABYLON {
  98642. /** @hidden */
  98643. export var _forceTransformFeedbackToBundle: boolean;
  98644. interface Engine {
  98645. /**
  98646. * Creates a webGL transform feedback object
  98647. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98648. * @returns the webGL transform feedback object
  98649. */
  98650. createTransformFeedback(): WebGLTransformFeedback;
  98651. /**
  98652. * Delete a webGL transform feedback object
  98653. * @param value defines the webGL transform feedback object to delete
  98654. */
  98655. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98656. /**
  98657. * Bind a webGL transform feedback object to the webgl context
  98658. * @param value defines the webGL transform feedback object to bind
  98659. */
  98660. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98661. /**
  98662. * Begins a transform feedback operation
  98663. * @param usePoints defines if points or triangles must be used
  98664. */
  98665. beginTransformFeedback(usePoints: boolean): void;
  98666. /**
  98667. * Ends a transform feedback operation
  98668. */
  98669. endTransformFeedback(): void;
  98670. /**
  98671. * Specify the varyings to use with transform feedback
  98672. * @param program defines the associated webGL program
  98673. * @param value defines the list of strings representing the varying names
  98674. */
  98675. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98676. /**
  98677. * Bind a webGL buffer for a transform feedback operation
  98678. * @param value defines the webGL buffer to bind
  98679. */
  98680. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98681. }
  98682. }
  98683. declare module BABYLON {
  98684. /**
  98685. * Gather the list of clipboard event types as constants.
  98686. */
  98687. export class ClipboardEventTypes {
  98688. /**
  98689. * The clipboard event is fired when a copy command is active (pressed).
  98690. */
  98691. static readonly COPY: number;
  98692. /**
  98693. * The clipboard event is fired when a cut command is active (pressed).
  98694. */
  98695. static readonly CUT: number;
  98696. /**
  98697. * The clipboard event is fired when a paste command is active (pressed).
  98698. */
  98699. static readonly PASTE: number;
  98700. }
  98701. /**
  98702. * This class is used to store clipboard related info for the onClipboardObservable event.
  98703. */
  98704. export class ClipboardInfo {
  98705. /**
  98706. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98707. */
  98708. type: number;
  98709. /**
  98710. * Defines the related dom event
  98711. */
  98712. event: ClipboardEvent;
  98713. /**
  98714. *Creates an instance of ClipboardInfo.
  98715. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98716. * @param event Defines the related dom event
  98717. */
  98718. constructor(
  98719. /**
  98720. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98721. */
  98722. type: number,
  98723. /**
  98724. * Defines the related dom event
  98725. */
  98726. event: ClipboardEvent);
  98727. /**
  98728. * Get the clipboard event's type from the keycode.
  98729. * @param keyCode Defines the keyCode for the current keyboard event.
  98730. * @return {number}
  98731. */
  98732. static GetTypeFromCharacter(keyCode: number): number;
  98733. }
  98734. }
  98735. declare module BABYLON {
  98736. /**
  98737. * Class used to represent data loading progression
  98738. */
  98739. export class SceneLoaderProgressEvent {
  98740. /** defines if data length to load can be evaluated */
  98741. readonly lengthComputable: boolean;
  98742. /** defines the loaded data length */
  98743. readonly loaded: number;
  98744. /** defines the data length to load */
  98745. readonly total: number;
  98746. /**
  98747. * Create a new progress event
  98748. * @param lengthComputable defines if data length to load can be evaluated
  98749. * @param loaded defines the loaded data length
  98750. * @param total defines the data length to load
  98751. */
  98752. constructor(
  98753. /** defines if data length to load can be evaluated */
  98754. lengthComputable: boolean,
  98755. /** defines the loaded data length */
  98756. loaded: number,
  98757. /** defines the data length to load */
  98758. total: number);
  98759. /**
  98760. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98761. * @param event defines the source event
  98762. * @returns a new SceneLoaderProgressEvent
  98763. */
  98764. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98765. }
  98766. /**
  98767. * Interface used by SceneLoader plugins to define supported file extensions
  98768. */
  98769. export interface ISceneLoaderPluginExtensions {
  98770. /**
  98771. * Defines the list of supported extensions
  98772. */
  98773. [extension: string]: {
  98774. isBinary: boolean;
  98775. };
  98776. }
  98777. /**
  98778. * Interface used by SceneLoader plugin factory
  98779. */
  98780. export interface ISceneLoaderPluginFactory {
  98781. /**
  98782. * Defines the name of the factory
  98783. */
  98784. name: string;
  98785. /**
  98786. * Function called to create a new plugin
  98787. * @return the new plugin
  98788. */
  98789. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98790. /**
  98791. * Boolean indicating if the plugin can direct load specific data
  98792. */
  98793. canDirectLoad?: (data: string) => boolean;
  98794. }
  98795. /**
  98796. * Interface used to define a SceneLoader plugin
  98797. */
  98798. export interface ISceneLoaderPlugin {
  98799. /**
  98800. * The friendly name of this plugin.
  98801. */
  98802. name: string;
  98803. /**
  98804. * The file extensions supported by this plugin.
  98805. */
  98806. extensions: string | ISceneLoaderPluginExtensions;
  98807. /**
  98808. * Import meshes into a scene.
  98809. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98810. * @param scene The scene to import into
  98811. * @param data The data to import
  98812. * @param rootUrl The root url for scene and resources
  98813. * @param meshes The meshes array to import into
  98814. * @param particleSystems The particle systems array to import into
  98815. * @param skeletons The skeletons array to import into
  98816. * @param onError The callback when import fails
  98817. * @returns True if successful or false otherwise
  98818. */
  98819. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98820. /**
  98821. * Load into a scene.
  98822. * @param scene The scene to load into
  98823. * @param data The data to import
  98824. * @param rootUrl The root url for scene and resources
  98825. * @param onError The callback when import fails
  98826. * @returns true if successful or false otherwise
  98827. */
  98828. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98829. /**
  98830. * The callback that returns true if the data can be directly loaded.
  98831. */
  98832. canDirectLoad?: (data: string) => boolean;
  98833. /**
  98834. * The callback that allows custom handling of the root url based on the response url.
  98835. */
  98836. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98837. /**
  98838. * Load into an asset container.
  98839. * @param scene The scene to load into
  98840. * @param data The data to import
  98841. * @param rootUrl The root url for scene and resources
  98842. * @param onError The callback when import fails
  98843. * @returns The loaded asset container
  98844. */
  98845. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98846. }
  98847. /**
  98848. * Interface used to define an async SceneLoader plugin
  98849. */
  98850. export interface ISceneLoaderPluginAsync {
  98851. /**
  98852. * The friendly name of this plugin.
  98853. */
  98854. name: string;
  98855. /**
  98856. * The file extensions supported by this plugin.
  98857. */
  98858. extensions: string | ISceneLoaderPluginExtensions;
  98859. /**
  98860. * Import meshes into a scene.
  98861. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98862. * @param scene The scene to import into
  98863. * @param data The data to import
  98864. * @param rootUrl The root url for scene and resources
  98865. * @param onProgress The callback when the load progresses
  98866. * @param fileName Defines the name of the file to load
  98867. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98868. */
  98869. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98870. meshes: AbstractMesh[];
  98871. particleSystems: IParticleSystem[];
  98872. skeletons: Skeleton[];
  98873. animationGroups: AnimationGroup[];
  98874. }>;
  98875. /**
  98876. * Load into a scene.
  98877. * @param scene The scene to load into
  98878. * @param data The data to import
  98879. * @param rootUrl The root url for scene and resources
  98880. * @param onProgress The callback when the load progresses
  98881. * @param fileName Defines the name of the file to load
  98882. * @returns Nothing
  98883. */
  98884. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98885. /**
  98886. * The callback that returns true if the data can be directly loaded.
  98887. */
  98888. canDirectLoad?: (data: string) => boolean;
  98889. /**
  98890. * The callback that allows custom handling of the root url based on the response url.
  98891. */
  98892. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98893. /**
  98894. * Load into an asset container.
  98895. * @param scene The scene to load into
  98896. * @param data The data to import
  98897. * @param rootUrl The root url for scene and resources
  98898. * @param onProgress The callback when the load progresses
  98899. * @param fileName Defines the name of the file to load
  98900. * @returns The loaded asset container
  98901. */
  98902. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98903. }
  98904. /**
  98905. * Class used to load scene from various file formats using registered plugins
  98906. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98907. */
  98908. export class SceneLoader {
  98909. /**
  98910. * No logging while loading
  98911. */
  98912. static readonly NO_LOGGING: number;
  98913. /**
  98914. * Minimal logging while loading
  98915. */
  98916. static readonly MINIMAL_LOGGING: number;
  98917. /**
  98918. * Summary logging while loading
  98919. */
  98920. static readonly SUMMARY_LOGGING: number;
  98921. /**
  98922. * Detailled logging while loading
  98923. */
  98924. static readonly DETAILED_LOGGING: number;
  98925. /**
  98926. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98927. */
  98928. static ForceFullSceneLoadingForIncremental: boolean;
  98929. /**
  98930. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98931. */
  98932. static ShowLoadingScreen: boolean;
  98933. /**
  98934. * Defines the current logging level (while loading the scene)
  98935. * @ignorenaming
  98936. */
  98937. static loggingLevel: number;
  98938. /**
  98939. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98940. */
  98941. static CleanBoneMatrixWeights: boolean;
  98942. /**
  98943. * Event raised when a plugin is used to load a scene
  98944. */
  98945. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98946. private static _registeredPlugins;
  98947. private static _getDefaultPlugin;
  98948. private static _getPluginForExtension;
  98949. private static _getPluginForDirectLoad;
  98950. private static _getPluginForFilename;
  98951. private static _getDirectLoad;
  98952. private static _loadData;
  98953. private static _getFileInfo;
  98954. /**
  98955. * Gets a plugin that can load the given extension
  98956. * @param extension defines the extension to load
  98957. * @returns a plugin or null if none works
  98958. */
  98959. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98960. /**
  98961. * Gets a boolean indicating that the given extension can be loaded
  98962. * @param extension defines the extension to load
  98963. * @returns true if the extension is supported
  98964. */
  98965. static IsPluginForExtensionAvailable(extension: string): boolean;
  98966. /**
  98967. * Adds a new plugin to the list of registered plugins
  98968. * @param plugin defines the plugin to add
  98969. */
  98970. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98971. /**
  98972. * Import meshes into a scene
  98973. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98974. * @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)
  98975. * @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)
  98976. * @param scene the instance of BABYLON.Scene to append to
  98977. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98978. * @param onProgress a callback with a progress event for each file being loaded
  98979. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98980. * @param pluginExtension the extension used to determine the plugin
  98981. * @returns The loaded plugin
  98982. */
  98983. 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>;
  98984. /**
  98985. * Import meshes into a scene
  98986. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98987. * @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)
  98988. * @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)
  98989. * @param scene the instance of BABYLON.Scene to append to
  98990. * @param onProgress a callback with a progress event for each file being loaded
  98991. * @param pluginExtension the extension used to determine the plugin
  98992. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98993. */
  98994. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98995. meshes: AbstractMesh[];
  98996. particleSystems: IParticleSystem[];
  98997. skeletons: Skeleton[];
  98998. animationGroups: AnimationGroup[];
  98999. }>;
  99000. /**
  99001. * Load a scene
  99002. * @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)
  99003. * @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)
  99004. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99005. * @param onSuccess a callback with the scene when import succeeds
  99006. * @param onProgress a callback with a progress event for each file being loaded
  99007. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99008. * @param pluginExtension the extension used to determine the plugin
  99009. * @returns The loaded plugin
  99010. */
  99011. 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>;
  99012. /**
  99013. * Load a scene
  99014. * @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)
  99015. * @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)
  99016. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99017. * @param onProgress a callback with a progress event for each file being loaded
  99018. * @param pluginExtension the extension used to determine the plugin
  99019. * @returns The loaded scene
  99020. */
  99021. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99022. /**
  99023. * Append a scene
  99024. * @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)
  99025. * @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)
  99026. * @param scene is the instance of BABYLON.Scene to append to
  99027. * @param onSuccess a callback with the scene when import succeeds
  99028. * @param onProgress a callback with a progress event for each file being loaded
  99029. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99030. * @param pluginExtension the extension used to determine the plugin
  99031. * @returns The loaded plugin
  99032. */
  99033. 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>;
  99034. /**
  99035. * Append a scene
  99036. * @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)
  99037. * @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)
  99038. * @param scene is the instance of BABYLON.Scene to append to
  99039. * @param onProgress a callback with a progress event for each file being loaded
  99040. * @param pluginExtension the extension used to determine the plugin
  99041. * @returns The given scene
  99042. */
  99043. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99044. /**
  99045. * Load a scene into an asset container
  99046. * @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)
  99047. * @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)
  99048. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  99049. * @param onSuccess a callback with the scene when import succeeds
  99050. * @param onProgress a callback with a progress event for each file being loaded
  99051. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99052. * @param pluginExtension the extension used to determine the plugin
  99053. * @returns The loaded plugin
  99054. */
  99055. 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>;
  99056. /**
  99057. * Load a scene into an asset container
  99058. * @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)
  99059. * @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)
  99060. * @param scene is the instance of Scene to append to
  99061. * @param onProgress a callback with a progress event for each file being loaded
  99062. * @param pluginExtension the extension used to determine the plugin
  99063. * @returns The loaded asset container
  99064. */
  99065. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  99066. }
  99067. }
  99068. declare module BABYLON {
  99069. /**
  99070. * Google Daydream controller
  99071. */
  99072. export class DaydreamController extends WebVRController {
  99073. /**
  99074. * Base Url for the controller model.
  99075. */
  99076. static MODEL_BASE_URL: string;
  99077. /**
  99078. * File name for the controller model.
  99079. */
  99080. static MODEL_FILENAME: string;
  99081. /**
  99082. * Gamepad Id prefix used to identify Daydream Controller.
  99083. */
  99084. static readonly GAMEPAD_ID_PREFIX: string;
  99085. /**
  99086. * Creates a new DaydreamController from a gamepad
  99087. * @param vrGamepad the gamepad that the controller should be created from
  99088. */
  99089. constructor(vrGamepad: any);
  99090. /**
  99091. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99092. * @param scene scene in which to add meshes
  99093. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99094. */
  99095. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99096. /**
  99097. * Called once for each button that changed state since the last frame
  99098. * @param buttonIdx Which button index changed
  99099. * @param state New state of the button
  99100. * @param changes Which properties on the state changed since last frame
  99101. */
  99102. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99103. }
  99104. }
  99105. declare module BABYLON {
  99106. /**
  99107. * Gear VR Controller
  99108. */
  99109. export class GearVRController extends WebVRController {
  99110. /**
  99111. * Base Url for the controller model.
  99112. */
  99113. static MODEL_BASE_URL: string;
  99114. /**
  99115. * File name for the controller model.
  99116. */
  99117. static MODEL_FILENAME: string;
  99118. /**
  99119. * Gamepad Id prefix used to identify this controller.
  99120. */
  99121. static readonly GAMEPAD_ID_PREFIX: string;
  99122. private readonly _buttonIndexToObservableNameMap;
  99123. /**
  99124. * Creates a new GearVRController from a gamepad
  99125. * @param vrGamepad the gamepad that the controller should be created from
  99126. */
  99127. constructor(vrGamepad: any);
  99128. /**
  99129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99130. * @param scene scene in which to add meshes
  99131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99132. */
  99133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99134. /**
  99135. * Called once for each button that changed state since the last frame
  99136. * @param buttonIdx Which button index changed
  99137. * @param state New state of the button
  99138. * @param changes Which properties on the state changed since last frame
  99139. */
  99140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99141. }
  99142. }
  99143. declare module BABYLON {
  99144. /**
  99145. * Generic Controller
  99146. */
  99147. export class GenericController extends WebVRController {
  99148. /**
  99149. * Base Url for the controller model.
  99150. */
  99151. static readonly MODEL_BASE_URL: string;
  99152. /**
  99153. * File name for the controller model.
  99154. */
  99155. static readonly MODEL_FILENAME: string;
  99156. /**
  99157. * Creates a new GenericController from a gamepad
  99158. * @param vrGamepad the gamepad that the controller should be created from
  99159. */
  99160. constructor(vrGamepad: any);
  99161. /**
  99162. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99163. * @param scene scene in which to add meshes
  99164. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99165. */
  99166. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99167. /**
  99168. * Called once for each button that changed state since the last frame
  99169. * @param buttonIdx Which button index changed
  99170. * @param state New state of the button
  99171. * @param changes Which properties on the state changed since last frame
  99172. */
  99173. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99174. }
  99175. }
  99176. declare module BABYLON {
  99177. /**
  99178. * Oculus Touch Controller
  99179. */
  99180. export class OculusTouchController extends WebVRController {
  99181. /**
  99182. * Base Url for the controller model.
  99183. */
  99184. static MODEL_BASE_URL: string;
  99185. /**
  99186. * File name for the left controller model.
  99187. */
  99188. static MODEL_LEFT_FILENAME: string;
  99189. /**
  99190. * File name for the right controller model.
  99191. */
  99192. static MODEL_RIGHT_FILENAME: string;
  99193. /**
  99194. * Fired when the secondary trigger on this controller is modified
  99195. */
  99196. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99197. /**
  99198. * Fired when the thumb rest on this controller is modified
  99199. */
  99200. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  99201. /**
  99202. * Creates a new OculusTouchController from a gamepad
  99203. * @param vrGamepad the gamepad that the controller should be created from
  99204. */
  99205. constructor(vrGamepad: any);
  99206. /**
  99207. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99208. * @param scene scene in which to add meshes
  99209. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99210. */
  99211. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99212. /**
  99213. * Fired when the A button on this controller is modified
  99214. */
  99215. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99216. /**
  99217. * Fired when the B button on this controller is modified
  99218. */
  99219. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99220. /**
  99221. * Fired when the X button on this controller is modified
  99222. */
  99223. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99224. /**
  99225. * Fired when the Y button on this controller is modified
  99226. */
  99227. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99228. /**
  99229. * Called once for each button that changed state since the last frame
  99230. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  99231. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  99232. * 2) secondary trigger (same)
  99233. * 3) A (right) X (left), touch, pressed = value
  99234. * 4) B / Y
  99235. * 5) thumb rest
  99236. * @param buttonIdx Which button index changed
  99237. * @param state New state of the button
  99238. * @param changes Which properties on the state changed since last frame
  99239. */
  99240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99241. }
  99242. }
  99243. declare module BABYLON {
  99244. /**
  99245. * Vive Controller
  99246. */
  99247. export class ViveController extends WebVRController {
  99248. /**
  99249. * Base Url for the controller model.
  99250. */
  99251. static MODEL_BASE_URL: string;
  99252. /**
  99253. * File name for the controller model.
  99254. */
  99255. static MODEL_FILENAME: string;
  99256. /**
  99257. * Creates a new ViveController from a gamepad
  99258. * @param vrGamepad the gamepad that the controller should be created from
  99259. */
  99260. constructor(vrGamepad: any);
  99261. /**
  99262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99263. * @param scene scene in which to add meshes
  99264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99265. */
  99266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99267. /**
  99268. * Fired when the left button on this controller is modified
  99269. */
  99270. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99271. /**
  99272. * Fired when the right button on this controller is modified
  99273. */
  99274. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99275. /**
  99276. * Fired when the menu button on this controller is modified
  99277. */
  99278. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99279. /**
  99280. * Called once for each button that changed state since the last frame
  99281. * Vive mapping:
  99282. * 0: touchpad
  99283. * 1: trigger
  99284. * 2: left AND right buttons
  99285. * 3: menu button
  99286. * @param buttonIdx Which button index changed
  99287. * @param state New state of the button
  99288. * @param changes Which properties on the state changed since last frame
  99289. */
  99290. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99291. }
  99292. }
  99293. declare module BABYLON {
  99294. /**
  99295. * Defines the WindowsMotionController object that the state of the windows motion controller
  99296. */
  99297. export class WindowsMotionController extends WebVRController {
  99298. /**
  99299. * The base url used to load the left and right controller models
  99300. */
  99301. static MODEL_BASE_URL: string;
  99302. /**
  99303. * The name of the left controller model file
  99304. */
  99305. static MODEL_LEFT_FILENAME: string;
  99306. /**
  99307. * The name of the right controller model file
  99308. */
  99309. static MODEL_RIGHT_FILENAME: string;
  99310. /**
  99311. * The controller name prefix for this controller type
  99312. */
  99313. static readonly GAMEPAD_ID_PREFIX: string;
  99314. /**
  99315. * The controller id pattern for this controller type
  99316. */
  99317. private static readonly GAMEPAD_ID_PATTERN;
  99318. private _loadedMeshInfo;
  99319. private readonly _mapping;
  99320. /**
  99321. * Fired when the trackpad on this controller is clicked
  99322. */
  99323. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  99324. /**
  99325. * Fired when the trackpad on this controller is modified
  99326. */
  99327. onTrackpadValuesChangedObservable: Observable<StickValues>;
  99328. /**
  99329. * The current x and y values of this controller's trackpad
  99330. */
  99331. trackpad: StickValues;
  99332. /**
  99333. * Creates a new WindowsMotionController from a gamepad
  99334. * @param vrGamepad the gamepad that the controller should be created from
  99335. */
  99336. constructor(vrGamepad: any);
  99337. /**
  99338. * Fired when the trigger on this controller is modified
  99339. */
  99340. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99341. /**
  99342. * Fired when the menu button on this controller is modified
  99343. */
  99344. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99345. /**
  99346. * Fired when the grip button on this controller is modified
  99347. */
  99348. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99349. /**
  99350. * Fired when the thumbstick button on this controller is modified
  99351. */
  99352. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99353. /**
  99354. * Fired when the touchpad button on this controller is modified
  99355. */
  99356. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99357. /**
  99358. * Fired when the touchpad values on this controller are modified
  99359. */
  99360. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99361. private _updateTrackpad;
  99362. /**
  99363. * Called once per frame by the engine.
  99364. */
  99365. update(): void;
  99366. /**
  99367. * Called once for each button that changed state since the last frame
  99368. * @param buttonIdx Which button index changed
  99369. * @param state New state of the button
  99370. * @param changes Which properties on the state changed since last frame
  99371. */
  99372. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99373. /**
  99374. * Moves the buttons on the controller mesh based on their current state
  99375. * @param buttonName the name of the button to move
  99376. * @param buttonValue the value of the button which determines the buttons new position
  99377. */
  99378. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99379. /**
  99380. * Moves the axis on the controller mesh based on its current state
  99381. * @param axis the index of the axis
  99382. * @param axisValue the value of the axis which determines the meshes new position
  99383. * @hidden
  99384. */
  99385. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99386. /**
  99387. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99388. * @param scene scene in which to add meshes
  99389. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99390. */
  99391. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99392. /**
  99393. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99394. * can be transformed by button presses and axes values, based on this._mapping.
  99395. *
  99396. * @param scene scene in which the meshes exist
  99397. * @param meshes list of meshes that make up the controller model to process
  99398. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99399. */
  99400. private processModel;
  99401. private createMeshInfo;
  99402. /**
  99403. * Gets the ray of the controller in the direction the controller is pointing
  99404. * @param length the length the resulting ray should be
  99405. * @returns a ray in the direction the controller is pointing
  99406. */
  99407. getForwardRay(length?: number): Ray;
  99408. /**
  99409. * Disposes of the controller
  99410. */
  99411. dispose(): void;
  99412. }
  99413. }
  99414. declare module BABYLON {
  99415. /**
  99416. * Single axis scale gizmo
  99417. */
  99418. export class AxisScaleGizmo extends Gizmo {
  99419. private _coloredMaterial;
  99420. /**
  99421. * Drag behavior responsible for the gizmos dragging interactions
  99422. */
  99423. dragBehavior: PointerDragBehavior;
  99424. private _pointerObserver;
  99425. /**
  99426. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99427. */
  99428. snapDistance: number;
  99429. /**
  99430. * Event that fires each time the gizmo snaps to a new location.
  99431. * * snapDistance is the the change in distance
  99432. */
  99433. onSnapObservable: Observable<{
  99434. snapDistance: number;
  99435. }>;
  99436. /**
  99437. * If the scaling operation should be done on all axis (default: false)
  99438. */
  99439. uniformScaling: boolean;
  99440. /**
  99441. * Creates an AxisScaleGizmo
  99442. * @param gizmoLayer The utility layer the gizmo will be added to
  99443. * @param dragAxis The axis which the gizmo will be able to scale on
  99444. * @param color The color of the gizmo
  99445. */
  99446. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99447. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99448. /**
  99449. * Disposes of the gizmo
  99450. */
  99451. dispose(): void;
  99452. /**
  99453. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99454. * @param mesh The mesh to replace the default mesh of the gizmo
  99455. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99456. */
  99457. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * Bounding box gizmo
  99463. */
  99464. export class BoundingBoxGizmo extends Gizmo {
  99465. private _lineBoundingBox;
  99466. private _rotateSpheresParent;
  99467. private _scaleBoxesParent;
  99468. private _boundingDimensions;
  99469. private _renderObserver;
  99470. private _pointerObserver;
  99471. private _scaleDragSpeed;
  99472. private _tmpQuaternion;
  99473. private _tmpVector;
  99474. private _tmpRotationMatrix;
  99475. /**
  99476. * 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)
  99477. */
  99478. ignoreChildren: boolean;
  99479. /**
  99480. * 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)
  99481. */
  99482. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99483. /**
  99484. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99485. */
  99486. rotationSphereSize: number;
  99487. /**
  99488. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99489. */
  99490. scaleBoxSize: number;
  99491. /**
  99492. * 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)
  99493. */
  99494. fixedDragMeshScreenSize: boolean;
  99495. /**
  99496. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99497. */
  99498. fixedDragMeshScreenSizeDistanceFactor: number;
  99499. /**
  99500. * Fired when a rotation sphere or scale box is dragged
  99501. */
  99502. onDragStartObservable: Observable<{}>;
  99503. /**
  99504. * Fired when a scale box is dragged
  99505. */
  99506. onScaleBoxDragObservable: Observable<{}>;
  99507. /**
  99508. * Fired when a scale box drag is ended
  99509. */
  99510. onScaleBoxDragEndObservable: Observable<{}>;
  99511. /**
  99512. * Fired when a rotation sphere is dragged
  99513. */
  99514. onRotationSphereDragObservable: Observable<{}>;
  99515. /**
  99516. * Fired when a rotation sphere drag is ended
  99517. */
  99518. onRotationSphereDragEndObservable: Observable<{}>;
  99519. /**
  99520. * 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)
  99521. */
  99522. scalePivot: Nullable<Vector3>;
  99523. private _anchorMesh;
  99524. private _existingMeshScale;
  99525. private _dragMesh;
  99526. private pointerDragBehavior;
  99527. private coloredMaterial;
  99528. private hoverColoredMaterial;
  99529. /**
  99530. * Sets the color of the bounding box gizmo
  99531. * @param color the color to set
  99532. */
  99533. setColor(color: Color3): void;
  99534. /**
  99535. * Creates an BoundingBoxGizmo
  99536. * @param gizmoLayer The utility layer the gizmo will be added to
  99537. * @param color The color of the gizmo
  99538. */
  99539. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99541. private _selectNode;
  99542. /**
  99543. * Updates the bounding box information for the Gizmo
  99544. */
  99545. updateBoundingBox(): void;
  99546. private _updateRotationSpheres;
  99547. private _updateScaleBoxes;
  99548. /**
  99549. * Enables rotation on the specified axis and disables rotation on the others
  99550. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99551. */
  99552. setEnabledRotationAxis(axis: string): void;
  99553. /**
  99554. * Enables/disables scaling
  99555. * @param enable if scaling should be enabled
  99556. */
  99557. setEnabledScaling(enable: boolean): void;
  99558. private _updateDummy;
  99559. /**
  99560. * Enables a pointer drag behavior on the bounding box of the gizmo
  99561. */
  99562. enableDragBehavior(): void;
  99563. /**
  99564. * Disposes of the gizmo
  99565. */
  99566. dispose(): void;
  99567. /**
  99568. * 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)
  99569. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99570. * @returns the bounding box mesh with the passed in mesh as a child
  99571. */
  99572. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99573. /**
  99574. * CustomMeshes are not supported by this gizmo
  99575. * @param mesh The mesh to replace the default mesh of the gizmo
  99576. */
  99577. setCustomMesh(mesh: Mesh): void;
  99578. }
  99579. }
  99580. declare module BABYLON {
  99581. /**
  99582. * Single plane rotation gizmo
  99583. */
  99584. export class PlaneRotationGizmo extends Gizmo {
  99585. /**
  99586. * Drag behavior responsible for the gizmos dragging interactions
  99587. */
  99588. dragBehavior: PointerDragBehavior;
  99589. private _pointerObserver;
  99590. /**
  99591. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99592. */
  99593. snapDistance: number;
  99594. /**
  99595. * Event that fires each time the gizmo snaps to a new location.
  99596. * * snapDistance is the the change in distance
  99597. */
  99598. onSnapObservable: Observable<{
  99599. snapDistance: number;
  99600. }>;
  99601. /**
  99602. * Creates a PlaneRotationGizmo
  99603. * @param gizmoLayer The utility layer the gizmo will be added to
  99604. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99605. * @param color The color of the gizmo
  99606. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99607. */
  99608. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99609. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99610. /**
  99611. * Disposes of the gizmo
  99612. */
  99613. dispose(): void;
  99614. }
  99615. }
  99616. declare module BABYLON {
  99617. /**
  99618. * Gizmo that enables rotating a mesh along 3 axis
  99619. */
  99620. export class RotationGizmo extends Gizmo {
  99621. /**
  99622. * Internal gizmo used for interactions on the x axis
  99623. */
  99624. xGizmo: PlaneRotationGizmo;
  99625. /**
  99626. * Internal gizmo used for interactions on the y axis
  99627. */
  99628. yGizmo: PlaneRotationGizmo;
  99629. /**
  99630. * Internal gizmo used for interactions on the z axis
  99631. */
  99632. zGizmo: PlaneRotationGizmo;
  99633. /** Fires an event when any of it's sub gizmos are dragged */
  99634. onDragStartObservable: Observable<{}>;
  99635. /** Fires an event when any of it's sub gizmos are released from dragging */
  99636. onDragEndObservable: Observable<{}>;
  99637. attachedMesh: Nullable<AbstractMesh>;
  99638. /**
  99639. * Creates a RotationGizmo
  99640. * @param gizmoLayer The utility layer the gizmo will be added to
  99641. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99642. */
  99643. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99644. updateGizmoRotationToMatchAttachedMesh: boolean;
  99645. /**
  99646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99647. */
  99648. snapDistance: number;
  99649. /**
  99650. * Ratio for the scale of the gizmo (Default: 1)
  99651. */
  99652. scaleRatio: number;
  99653. /**
  99654. * Disposes of the gizmo
  99655. */
  99656. dispose(): void;
  99657. /**
  99658. * CustomMeshes are not supported by this gizmo
  99659. * @param mesh The mesh to replace the default mesh of the gizmo
  99660. */
  99661. setCustomMesh(mesh: Mesh): void;
  99662. }
  99663. }
  99664. declare module BABYLON {
  99665. /**
  99666. * Gizmo that enables dragging a mesh along 3 axis
  99667. */
  99668. export class PositionGizmo extends Gizmo {
  99669. /**
  99670. * Internal gizmo used for interactions on the x axis
  99671. */
  99672. xGizmo: AxisDragGizmo;
  99673. /**
  99674. * Internal gizmo used for interactions on the y axis
  99675. */
  99676. yGizmo: AxisDragGizmo;
  99677. /**
  99678. * Internal gizmo used for interactions on the z axis
  99679. */
  99680. zGizmo: AxisDragGizmo;
  99681. /** Fires an event when any of it's sub gizmos are dragged */
  99682. onDragStartObservable: Observable<{}>;
  99683. /** Fires an event when any of it's sub gizmos are released from dragging */
  99684. onDragEndObservable: Observable<{}>;
  99685. attachedMesh: Nullable<AbstractMesh>;
  99686. /**
  99687. * Creates a PositionGizmo
  99688. * @param gizmoLayer The utility layer the gizmo will be added to
  99689. */
  99690. constructor(gizmoLayer?: UtilityLayerRenderer);
  99691. updateGizmoRotationToMatchAttachedMesh: boolean;
  99692. /**
  99693. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99694. */
  99695. snapDistance: number;
  99696. /**
  99697. * Ratio for the scale of the gizmo (Default: 1)
  99698. */
  99699. scaleRatio: number;
  99700. /**
  99701. * Disposes of the gizmo
  99702. */
  99703. dispose(): void;
  99704. /**
  99705. * CustomMeshes are not supported by this gizmo
  99706. * @param mesh The mesh to replace the default mesh of the gizmo
  99707. */
  99708. setCustomMesh(mesh: Mesh): void;
  99709. }
  99710. }
  99711. declare module BABYLON {
  99712. /**
  99713. * Class containing static functions to help procedurally build meshes
  99714. */
  99715. export class PolyhedronBuilder {
  99716. /**
  99717. * Creates a polyhedron mesh
  99718. * * 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
  99719. * * The parameter `size` (positive float, default 1) sets the polygon size
  99720. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99721. * * 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`
  99722. * * 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
  99723. * * 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)`)
  99724. * * 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
  99725. * * 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
  99726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99729. * @param name defines the name of the mesh
  99730. * @param options defines the options used to create the mesh
  99731. * @param scene defines the hosting scene
  99732. * @returns the polyhedron mesh
  99733. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99734. */
  99735. static CreatePolyhedron(name: string, options: {
  99736. type?: number;
  99737. size?: number;
  99738. sizeX?: number;
  99739. sizeY?: number;
  99740. sizeZ?: number;
  99741. custom?: any;
  99742. faceUV?: Vector4[];
  99743. faceColors?: Color4[];
  99744. flat?: boolean;
  99745. updatable?: boolean;
  99746. sideOrientation?: number;
  99747. frontUVs?: Vector4;
  99748. backUVs?: Vector4;
  99749. }, scene: Scene): Mesh;
  99750. }
  99751. }
  99752. declare module BABYLON {
  99753. /**
  99754. * Gizmo that enables scaling a mesh along 3 axis
  99755. */
  99756. export class ScaleGizmo extends Gizmo {
  99757. /**
  99758. * Internal gizmo used for interactions on the x axis
  99759. */
  99760. xGizmo: AxisScaleGizmo;
  99761. /**
  99762. * Internal gizmo used for interactions on the y axis
  99763. */
  99764. yGizmo: AxisScaleGizmo;
  99765. /**
  99766. * Internal gizmo used for interactions on the z axis
  99767. */
  99768. zGizmo: AxisScaleGizmo;
  99769. /**
  99770. * Internal gizmo used to scale all axis equally
  99771. */
  99772. uniformScaleGizmo: AxisScaleGizmo;
  99773. /** Fires an event when any of it's sub gizmos are dragged */
  99774. onDragStartObservable: Observable<{}>;
  99775. /** Fires an event when any of it's sub gizmos are released from dragging */
  99776. onDragEndObservable: Observable<{}>;
  99777. attachedMesh: Nullable<AbstractMesh>;
  99778. /**
  99779. * Creates a ScaleGizmo
  99780. * @param gizmoLayer The utility layer the gizmo will be added to
  99781. */
  99782. constructor(gizmoLayer?: UtilityLayerRenderer);
  99783. updateGizmoRotationToMatchAttachedMesh: boolean;
  99784. /**
  99785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99786. */
  99787. snapDistance: number;
  99788. /**
  99789. * Ratio for the scale of the gizmo (Default: 1)
  99790. */
  99791. scaleRatio: number;
  99792. /**
  99793. * Disposes of the gizmo
  99794. */
  99795. dispose(): void;
  99796. }
  99797. }
  99798. declare module BABYLON {
  99799. /**
  99800. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99801. */
  99802. export class GizmoManager implements IDisposable {
  99803. private scene;
  99804. /**
  99805. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99806. */
  99807. gizmos: {
  99808. positionGizmo: Nullable<PositionGizmo>;
  99809. rotationGizmo: Nullable<RotationGizmo>;
  99810. scaleGizmo: Nullable<ScaleGizmo>;
  99811. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99812. };
  99813. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99814. clearGizmoOnEmptyPointerEvent: boolean;
  99815. /** Fires an event when the manager is attached to a mesh */
  99816. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99817. private _gizmosEnabled;
  99818. private _pointerObserver;
  99819. private _attachedMesh;
  99820. private _boundingBoxColor;
  99821. private _defaultUtilityLayer;
  99822. private _defaultKeepDepthUtilityLayer;
  99823. /**
  99824. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99825. */
  99826. boundingBoxDragBehavior: SixDofDragBehavior;
  99827. /**
  99828. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99829. */
  99830. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99831. /**
  99832. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99833. */
  99834. usePointerToAttachGizmos: boolean;
  99835. /**
  99836. * Instatiates a gizmo manager
  99837. * @param scene the scene to overlay the gizmos on top of
  99838. */
  99839. constructor(scene: Scene);
  99840. /**
  99841. * Attaches a set of gizmos to the specified mesh
  99842. * @param mesh The mesh the gizmo's should be attached to
  99843. */
  99844. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99845. /**
  99846. * If the position gizmo is enabled
  99847. */
  99848. positionGizmoEnabled: boolean;
  99849. /**
  99850. * If the rotation gizmo is enabled
  99851. */
  99852. rotationGizmoEnabled: boolean;
  99853. /**
  99854. * If the scale gizmo is enabled
  99855. */
  99856. scaleGizmoEnabled: boolean;
  99857. /**
  99858. * If the boundingBox gizmo is enabled
  99859. */
  99860. boundingBoxGizmoEnabled: boolean;
  99861. /**
  99862. * Disposes of the gizmo manager
  99863. */
  99864. dispose(): void;
  99865. }
  99866. }
  99867. declare module BABYLON {
  99868. /**
  99869. * Gizmo that enables viewing a light
  99870. */
  99871. export class LightGizmo extends Gizmo {
  99872. private _box;
  99873. /**
  99874. * Creates a LightGizmo
  99875. * @param gizmoLayer The utility layer the gizmo will be added to
  99876. */
  99877. constructor(gizmoLayer?: UtilityLayerRenderer);
  99878. private _light;
  99879. /**
  99880. * The light that the gizmo is attached to
  99881. */
  99882. light: Nullable<Light>;
  99883. /**
  99884. * @hidden
  99885. * Updates the gizmo to match the attached mesh's position/rotation
  99886. */
  99887. protected _update(): void;
  99888. }
  99889. }
  99890. declare module BABYLON {
  99891. /** @hidden */
  99892. export var backgroundFragmentDeclaration: {
  99893. name: string;
  99894. shader: string;
  99895. };
  99896. }
  99897. declare module BABYLON {
  99898. /** @hidden */
  99899. export var backgroundUboDeclaration: {
  99900. name: string;
  99901. shader: string;
  99902. };
  99903. }
  99904. declare module BABYLON {
  99905. /** @hidden */
  99906. export var backgroundPixelShader: {
  99907. name: string;
  99908. shader: string;
  99909. };
  99910. }
  99911. declare module BABYLON {
  99912. /** @hidden */
  99913. export var backgroundVertexDeclaration: {
  99914. name: string;
  99915. shader: string;
  99916. };
  99917. }
  99918. declare module BABYLON {
  99919. /** @hidden */
  99920. export var backgroundVertexShader: {
  99921. name: string;
  99922. shader: string;
  99923. };
  99924. }
  99925. declare module BABYLON {
  99926. /**
  99927. * Background material used to create an efficient environement around your scene.
  99928. */
  99929. export class BackgroundMaterial extends PushMaterial {
  99930. /**
  99931. * Standard reflectance value at parallel view angle.
  99932. */
  99933. static StandardReflectance0: number;
  99934. /**
  99935. * Standard reflectance value at grazing angle.
  99936. */
  99937. static StandardReflectance90: number;
  99938. protected _primaryColor: Color3;
  99939. /**
  99940. * Key light Color (multiply against the environement texture)
  99941. */
  99942. primaryColor: Color3;
  99943. protected __perceptualColor: Nullable<Color3>;
  99944. /**
  99945. * Experimental Internal Use Only.
  99946. *
  99947. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99948. * This acts as a helper to set the primary color to a more "human friendly" value.
  99949. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99950. * output color as close as possible from the chosen value.
  99951. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99952. * part of lighting setup.)
  99953. */
  99954. _perceptualColor: Nullable<Color3>;
  99955. protected _primaryColorShadowLevel: float;
  99956. /**
  99957. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99958. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99959. */
  99960. primaryColorShadowLevel: float;
  99961. protected _primaryColorHighlightLevel: float;
  99962. /**
  99963. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99964. * The primary color is used at the level chosen to define what the white area would look.
  99965. */
  99966. primaryColorHighlightLevel: float;
  99967. protected _reflectionTexture: Nullable<BaseTexture>;
  99968. /**
  99969. * Reflection Texture used in the material.
  99970. * Should be author in a specific way for the best result (refer to the documentation).
  99971. */
  99972. reflectionTexture: Nullable<BaseTexture>;
  99973. protected _reflectionBlur: float;
  99974. /**
  99975. * Reflection Texture level of blur.
  99976. *
  99977. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99978. * texture twice.
  99979. */
  99980. reflectionBlur: float;
  99981. protected _diffuseTexture: Nullable<BaseTexture>;
  99982. /**
  99983. * Diffuse Texture used in the material.
  99984. * Should be author in a specific way for the best result (refer to the documentation).
  99985. */
  99986. diffuseTexture: Nullable<BaseTexture>;
  99987. protected _shadowLights: Nullable<IShadowLight[]>;
  99988. /**
  99989. * Specify the list of lights casting shadow on the material.
  99990. * All scene shadow lights will be included if null.
  99991. */
  99992. shadowLights: Nullable<IShadowLight[]>;
  99993. protected _shadowLevel: float;
  99994. /**
  99995. * Helps adjusting the shadow to a softer level if required.
  99996. * 0 means black shadows and 1 means no shadows.
  99997. */
  99998. shadowLevel: float;
  99999. protected _sceneCenter: Vector3;
  100000. /**
  100001. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100002. * It is usually zero but might be interesting to modify according to your setup.
  100003. */
  100004. sceneCenter: Vector3;
  100005. protected _opacityFresnel: boolean;
  100006. /**
  100007. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100008. * This helps ensuring a nice transition when the camera goes under the ground.
  100009. */
  100010. opacityFresnel: boolean;
  100011. protected _reflectionFresnel: boolean;
  100012. /**
  100013. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100014. * This helps adding a mirror texture on the ground.
  100015. */
  100016. reflectionFresnel: boolean;
  100017. protected _reflectionFalloffDistance: number;
  100018. /**
  100019. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100020. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100021. */
  100022. reflectionFalloffDistance: number;
  100023. protected _reflectionAmount: number;
  100024. /**
  100025. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100026. */
  100027. reflectionAmount: number;
  100028. protected _reflectionReflectance0: number;
  100029. /**
  100030. * This specifies the weight of the reflection at grazing angle.
  100031. */
  100032. reflectionReflectance0: number;
  100033. protected _reflectionReflectance90: number;
  100034. /**
  100035. * This specifies the weight of the reflection at a perpendicular point of view.
  100036. */
  100037. reflectionReflectance90: number;
  100038. /**
  100039. * Sets the reflection reflectance fresnel values according to the default standard
  100040. * empirically know to work well :-)
  100041. */
  100042. reflectionStandardFresnelWeight: number;
  100043. protected _useRGBColor: boolean;
  100044. /**
  100045. * Helps to directly use the maps channels instead of their level.
  100046. */
  100047. useRGBColor: boolean;
  100048. protected _enableNoise: boolean;
  100049. /**
  100050. * This helps reducing the banding effect that could occur on the background.
  100051. */
  100052. enableNoise: boolean;
  100053. /**
  100054. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100055. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  100056. * Recommended to be keep at 1.0 except for special cases.
  100057. */
  100058. fovMultiplier: number;
  100059. private _fovMultiplier;
  100060. /**
  100061. * Enable the FOV adjustment feature controlled by fovMultiplier.
  100062. */
  100063. useEquirectangularFOV: boolean;
  100064. private _maxSimultaneousLights;
  100065. /**
  100066. * Number of Simultaneous lights allowed on the material.
  100067. */
  100068. maxSimultaneousLights: int;
  100069. /**
  100070. * Default configuration related to image processing available in the Background Material.
  100071. */
  100072. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100073. /**
  100074. * Keep track of the image processing observer to allow dispose and replace.
  100075. */
  100076. private _imageProcessingObserver;
  100077. /**
  100078. * Attaches a new image processing configuration to the PBR Material.
  100079. * @param configuration (if null the scene configuration will be use)
  100080. */
  100081. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100082. /**
  100083. * Gets the image processing configuration used either in this material.
  100084. */
  100085. /**
  100086. * Sets the Default image processing configuration used either in the this material.
  100087. *
  100088. * If sets to null, the scene one is in use.
  100089. */
  100090. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100091. /**
  100092. * Gets wether the color curves effect is enabled.
  100093. */
  100094. /**
  100095. * Sets wether the color curves effect is enabled.
  100096. */
  100097. cameraColorCurvesEnabled: boolean;
  100098. /**
  100099. * Gets wether the color grading effect is enabled.
  100100. */
  100101. /**
  100102. * Gets wether the color grading effect is enabled.
  100103. */
  100104. cameraColorGradingEnabled: boolean;
  100105. /**
  100106. * Gets wether tonemapping is enabled or not.
  100107. */
  100108. /**
  100109. * Sets wether tonemapping is enabled or not
  100110. */
  100111. cameraToneMappingEnabled: boolean;
  100112. /**
  100113. * The camera exposure used on this material.
  100114. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100115. * This corresponds to a photographic exposure.
  100116. */
  100117. /**
  100118. * The camera exposure used on this material.
  100119. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100120. * This corresponds to a photographic exposure.
  100121. */
  100122. cameraExposure: float;
  100123. /**
  100124. * Gets The camera contrast used on this material.
  100125. */
  100126. /**
  100127. * Sets The camera contrast used on this material.
  100128. */
  100129. cameraContrast: float;
  100130. /**
  100131. * Gets the Color Grading 2D Lookup Texture.
  100132. */
  100133. /**
  100134. * Sets the Color Grading 2D Lookup Texture.
  100135. */
  100136. cameraColorGradingTexture: Nullable<BaseTexture>;
  100137. /**
  100138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100140. * 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;
  100141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100142. */
  100143. /**
  100144. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100145. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100146. * 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;
  100147. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100148. */
  100149. cameraColorCurves: Nullable<ColorCurves>;
  100150. /**
  100151. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100152. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100153. */
  100154. switchToBGR: boolean;
  100155. private _renderTargets;
  100156. private _reflectionControls;
  100157. private _white;
  100158. private _primaryShadowColor;
  100159. private _primaryHighlightColor;
  100160. /**
  100161. * Instantiates a Background Material in the given scene
  100162. * @param name The friendly name of the material
  100163. * @param scene The scene to add the material to
  100164. */
  100165. constructor(name: string, scene: Scene);
  100166. /**
  100167. * Gets a boolean indicating that current material needs to register RTT
  100168. */
  100169. readonly hasRenderTargetTextures: boolean;
  100170. /**
  100171. * The entire material has been created in order to prevent overdraw.
  100172. * @returns false
  100173. */
  100174. needAlphaTesting(): boolean;
  100175. /**
  100176. * The entire material has been created in order to prevent overdraw.
  100177. * @returns true if blending is enable
  100178. */
  100179. needAlphaBlending(): boolean;
  100180. /**
  100181. * Checks wether the material is ready to be rendered for a given mesh.
  100182. * @param mesh The mesh to render
  100183. * @param subMesh The submesh to check against
  100184. * @param useInstances Specify wether or not the material is used with instances
  100185. * @returns true if all the dependencies are ready (Textures, Effects...)
  100186. */
  100187. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100188. /**
  100189. * Compute the primary color according to the chosen perceptual color.
  100190. */
  100191. private _computePrimaryColorFromPerceptualColor;
  100192. /**
  100193. * Compute the highlights and shadow colors according to their chosen levels.
  100194. */
  100195. private _computePrimaryColors;
  100196. /**
  100197. * Build the uniform buffer used in the material.
  100198. */
  100199. buildUniformLayout(): void;
  100200. /**
  100201. * Unbind the material.
  100202. */
  100203. unbind(): void;
  100204. /**
  100205. * Bind only the world matrix to the material.
  100206. * @param world The world matrix to bind.
  100207. */
  100208. bindOnlyWorldMatrix(world: Matrix): void;
  100209. /**
  100210. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  100211. * @param world The world matrix to bind.
  100212. * @param subMesh The submesh to bind for.
  100213. */
  100214. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100215. /**
  100216. * Dispose the material.
  100217. * @param forceDisposeEffect Force disposal of the associated effect.
  100218. * @param forceDisposeTextures Force disposal of the associated textures.
  100219. */
  100220. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100221. /**
  100222. * Clones the material.
  100223. * @param name The cloned name.
  100224. * @returns The cloned material.
  100225. */
  100226. clone(name: string): BackgroundMaterial;
  100227. /**
  100228. * Serializes the current material to its JSON representation.
  100229. * @returns The JSON representation.
  100230. */
  100231. serialize(): any;
  100232. /**
  100233. * Gets the class name of the material
  100234. * @returns "BackgroundMaterial"
  100235. */
  100236. getClassName(): string;
  100237. /**
  100238. * Parse a JSON input to create back a background material.
  100239. * @param source The JSON data to parse
  100240. * @param scene The scene to create the parsed material in
  100241. * @param rootUrl The root url of the assets the material depends upon
  100242. * @returns the instantiated BackgroundMaterial.
  100243. */
  100244. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  100245. }
  100246. }
  100247. declare module BABYLON {
  100248. /**
  100249. * Represents the different options available during the creation of
  100250. * a Environment helper.
  100251. *
  100252. * This can control the default ground, skybox and image processing setup of your scene.
  100253. */
  100254. export interface IEnvironmentHelperOptions {
  100255. /**
  100256. * Specifies wether or not to create a ground.
  100257. * True by default.
  100258. */
  100259. createGround: boolean;
  100260. /**
  100261. * Specifies the ground size.
  100262. * 15 by default.
  100263. */
  100264. groundSize: number;
  100265. /**
  100266. * The texture used on the ground for the main color.
  100267. * Comes from the BabylonJS CDN by default.
  100268. *
  100269. * Remarks: Can be either a texture or a url.
  100270. */
  100271. groundTexture: string | BaseTexture;
  100272. /**
  100273. * The color mixed in the ground texture by default.
  100274. * BabylonJS clearColor by default.
  100275. */
  100276. groundColor: Color3;
  100277. /**
  100278. * Specifies the ground opacity.
  100279. * 1 by default.
  100280. */
  100281. groundOpacity: number;
  100282. /**
  100283. * Enables the ground to receive shadows.
  100284. * True by default.
  100285. */
  100286. enableGroundShadow: boolean;
  100287. /**
  100288. * Helps preventing the shadow to be fully black on the ground.
  100289. * 0.5 by default.
  100290. */
  100291. groundShadowLevel: number;
  100292. /**
  100293. * Creates a mirror texture attach to the ground.
  100294. * false by default.
  100295. */
  100296. enableGroundMirror: boolean;
  100297. /**
  100298. * Specifies the ground mirror size ratio.
  100299. * 0.3 by default as the default kernel is 64.
  100300. */
  100301. groundMirrorSizeRatio: number;
  100302. /**
  100303. * Specifies the ground mirror blur kernel size.
  100304. * 64 by default.
  100305. */
  100306. groundMirrorBlurKernel: number;
  100307. /**
  100308. * Specifies the ground mirror visibility amount.
  100309. * 1 by default
  100310. */
  100311. groundMirrorAmount: number;
  100312. /**
  100313. * Specifies the ground mirror reflectance weight.
  100314. * This uses the standard weight of the background material to setup the fresnel effect
  100315. * of the mirror.
  100316. * 1 by default.
  100317. */
  100318. groundMirrorFresnelWeight: number;
  100319. /**
  100320. * Specifies the ground mirror Falloff distance.
  100321. * This can helps reducing the size of the reflection.
  100322. * 0 by Default.
  100323. */
  100324. groundMirrorFallOffDistance: number;
  100325. /**
  100326. * Specifies the ground mirror texture type.
  100327. * Unsigned Int by Default.
  100328. */
  100329. groundMirrorTextureType: number;
  100330. /**
  100331. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  100332. * the shown objects.
  100333. */
  100334. groundYBias: number;
  100335. /**
  100336. * Specifies wether or not to create a skybox.
  100337. * True by default.
  100338. */
  100339. createSkybox: boolean;
  100340. /**
  100341. * Specifies the skybox size.
  100342. * 20 by default.
  100343. */
  100344. skyboxSize: number;
  100345. /**
  100346. * The texture used on the skybox for the main color.
  100347. * Comes from the BabylonJS CDN by default.
  100348. *
  100349. * Remarks: Can be either a texture or a url.
  100350. */
  100351. skyboxTexture: string | BaseTexture;
  100352. /**
  100353. * The color mixed in the skybox texture by default.
  100354. * BabylonJS clearColor by default.
  100355. */
  100356. skyboxColor: Color3;
  100357. /**
  100358. * The background rotation around the Y axis of the scene.
  100359. * This helps aligning the key lights of your scene with the background.
  100360. * 0 by default.
  100361. */
  100362. backgroundYRotation: number;
  100363. /**
  100364. * Compute automatically the size of the elements to best fit with the scene.
  100365. */
  100366. sizeAuto: boolean;
  100367. /**
  100368. * Default position of the rootMesh if autoSize is not true.
  100369. */
  100370. rootPosition: Vector3;
  100371. /**
  100372. * Sets up the image processing in the scene.
  100373. * true by default.
  100374. */
  100375. setupImageProcessing: boolean;
  100376. /**
  100377. * The texture used as your environment texture in the scene.
  100378. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100379. *
  100380. * Remarks: Can be either a texture or a url.
  100381. */
  100382. environmentTexture: string | BaseTexture;
  100383. /**
  100384. * The value of the exposure to apply to the scene.
  100385. * 0.6 by default if setupImageProcessing is true.
  100386. */
  100387. cameraExposure: number;
  100388. /**
  100389. * The value of the contrast to apply to the scene.
  100390. * 1.6 by default if setupImageProcessing is true.
  100391. */
  100392. cameraContrast: number;
  100393. /**
  100394. * Specifies wether or not tonemapping should be enabled in the scene.
  100395. * true by default if setupImageProcessing is true.
  100396. */
  100397. toneMappingEnabled: boolean;
  100398. }
  100399. /**
  100400. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100401. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100402. * It also helps with the default setup of your imageProcessing configuration.
  100403. */
  100404. export class EnvironmentHelper {
  100405. /**
  100406. * Default ground texture URL.
  100407. */
  100408. private static _groundTextureCDNUrl;
  100409. /**
  100410. * Default skybox texture URL.
  100411. */
  100412. private static _skyboxTextureCDNUrl;
  100413. /**
  100414. * Default environment texture URL.
  100415. */
  100416. private static _environmentTextureCDNUrl;
  100417. /**
  100418. * Creates the default options for the helper.
  100419. */
  100420. private static _getDefaultOptions;
  100421. private _rootMesh;
  100422. /**
  100423. * Gets the root mesh created by the helper.
  100424. */
  100425. readonly rootMesh: Mesh;
  100426. private _skybox;
  100427. /**
  100428. * Gets the skybox created by the helper.
  100429. */
  100430. readonly skybox: Nullable<Mesh>;
  100431. private _skyboxTexture;
  100432. /**
  100433. * Gets the skybox texture created by the helper.
  100434. */
  100435. readonly skyboxTexture: Nullable<BaseTexture>;
  100436. private _skyboxMaterial;
  100437. /**
  100438. * Gets the skybox material created by the helper.
  100439. */
  100440. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100441. private _ground;
  100442. /**
  100443. * Gets the ground mesh created by the helper.
  100444. */
  100445. readonly ground: Nullable<Mesh>;
  100446. private _groundTexture;
  100447. /**
  100448. * Gets the ground texture created by the helper.
  100449. */
  100450. readonly groundTexture: Nullable<BaseTexture>;
  100451. private _groundMirror;
  100452. /**
  100453. * Gets the ground mirror created by the helper.
  100454. */
  100455. readonly groundMirror: Nullable<MirrorTexture>;
  100456. /**
  100457. * Gets the ground mirror render list to helps pushing the meshes
  100458. * you wish in the ground reflection.
  100459. */
  100460. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100461. private _groundMaterial;
  100462. /**
  100463. * Gets the ground material created by the helper.
  100464. */
  100465. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100466. /**
  100467. * Stores the creation options.
  100468. */
  100469. private readonly _scene;
  100470. private _options;
  100471. /**
  100472. * This observable will be notified with any error during the creation of the environment,
  100473. * mainly texture creation errors.
  100474. */
  100475. onErrorObservable: Observable<{
  100476. message?: string;
  100477. exception?: any;
  100478. }>;
  100479. /**
  100480. * constructor
  100481. * @param options Defines the options we want to customize the helper
  100482. * @param scene The scene to add the material to
  100483. */
  100484. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100485. /**
  100486. * Updates the background according to the new options
  100487. * @param options
  100488. */
  100489. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100490. /**
  100491. * Sets the primary color of all the available elements.
  100492. * @param color the main color to affect to the ground and the background
  100493. */
  100494. setMainColor(color: Color3): void;
  100495. /**
  100496. * Setup the image processing according to the specified options.
  100497. */
  100498. private _setupImageProcessing;
  100499. /**
  100500. * Setup the environment texture according to the specified options.
  100501. */
  100502. private _setupEnvironmentTexture;
  100503. /**
  100504. * Setup the background according to the specified options.
  100505. */
  100506. private _setupBackground;
  100507. /**
  100508. * Get the scene sizes according to the setup.
  100509. */
  100510. private _getSceneSize;
  100511. /**
  100512. * Setup the ground according to the specified options.
  100513. */
  100514. private _setupGround;
  100515. /**
  100516. * Setup the ground material according to the specified options.
  100517. */
  100518. private _setupGroundMaterial;
  100519. /**
  100520. * Setup the ground diffuse texture according to the specified options.
  100521. */
  100522. private _setupGroundDiffuseTexture;
  100523. /**
  100524. * Setup the ground mirror texture according to the specified options.
  100525. */
  100526. private _setupGroundMirrorTexture;
  100527. /**
  100528. * Setup the ground to receive the mirror texture.
  100529. */
  100530. private _setupMirrorInGroundMaterial;
  100531. /**
  100532. * Setup the skybox according to the specified options.
  100533. */
  100534. private _setupSkybox;
  100535. /**
  100536. * Setup the skybox material according to the specified options.
  100537. */
  100538. private _setupSkyboxMaterial;
  100539. /**
  100540. * Setup the skybox reflection texture according to the specified options.
  100541. */
  100542. private _setupSkyboxReflectionTexture;
  100543. private _errorHandler;
  100544. /**
  100545. * Dispose all the elements created by the Helper.
  100546. */
  100547. dispose(): void;
  100548. }
  100549. }
  100550. declare module BABYLON {
  100551. /**
  100552. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100553. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100554. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100555. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100556. */
  100557. export class PhotoDome extends TransformNode {
  100558. private _useDirectMapping;
  100559. /**
  100560. * The texture being displayed on the sphere
  100561. */
  100562. protected _photoTexture: Texture;
  100563. /**
  100564. * Gets or sets the texture being displayed on the sphere
  100565. */
  100566. photoTexture: Texture;
  100567. /**
  100568. * Observable raised when an error occured while loading the 360 image
  100569. */
  100570. onLoadErrorObservable: Observable<string>;
  100571. /**
  100572. * The skybox material
  100573. */
  100574. protected _material: BackgroundMaterial;
  100575. /**
  100576. * The surface used for the skybox
  100577. */
  100578. protected _mesh: Mesh;
  100579. /**
  100580. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100581. * Also see the options.resolution property.
  100582. */
  100583. fovMultiplier: number;
  100584. /**
  100585. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100586. * @param name Element's name, child elements will append suffixes for their own names.
  100587. * @param urlsOfPhoto defines the url of the photo to display
  100588. * @param options defines an object containing optional or exposed sub element properties
  100589. * @param onError defines a callback called when an error occured while loading the texture
  100590. */
  100591. constructor(name: string, urlOfPhoto: string, options: {
  100592. resolution?: number;
  100593. size?: number;
  100594. useDirectMapping?: boolean;
  100595. faceForward?: boolean;
  100596. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100597. /**
  100598. * Releases resources associated with this node.
  100599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100601. */
  100602. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100603. }
  100604. }
  100605. declare module BABYLON {
  100606. /**
  100607. * Class used to host texture specific utilities
  100608. */
  100609. export class TextureTools {
  100610. /**
  100611. * Uses the GPU to create a copy texture rescaled at a given size
  100612. * @param texture Texture to copy from
  100613. * @param width defines the desired width
  100614. * @param height defines the desired height
  100615. * @param useBilinearMode defines if bilinear mode has to be used
  100616. * @return the generated texture
  100617. */
  100618. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100619. /**
  100620. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100621. * @param scene defines the hosting scene
  100622. * @returns the environment BRDF texture
  100623. */
  100624. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100625. private static _environmentBRDFBase64Texture;
  100626. }
  100627. }
  100628. declare module BABYLON {
  100629. /**
  100630. * @hidden
  100631. */
  100632. export interface IMaterialClearCoatDefines {
  100633. CLEARCOAT: boolean;
  100634. CLEARCOAT_DEFAULTIOR: boolean;
  100635. CLEARCOAT_TEXTURE: boolean;
  100636. CLEARCOAT_TEXTUREDIRECTUV: number;
  100637. CLEARCOAT_BUMP: boolean;
  100638. CLEARCOAT_BUMPDIRECTUV: number;
  100639. CLEARCOAT_TINT: boolean;
  100640. CLEARCOAT_TINT_TEXTURE: boolean;
  100641. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100642. /** @hidden */
  100643. _areTexturesDirty: boolean;
  100644. }
  100645. /**
  100646. * Define the code related to the clear coat parameters of the pbr material.
  100647. */
  100648. export class PBRClearCoatConfiguration {
  100649. /**
  100650. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100651. * The default fits with a polyurethane material.
  100652. */
  100653. private static readonly _DefaultIndiceOfRefraction;
  100654. private _isEnabled;
  100655. /**
  100656. * Defines if the clear coat is enabled in the material.
  100657. */
  100658. isEnabled: boolean;
  100659. /**
  100660. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100661. */
  100662. intensity: number;
  100663. /**
  100664. * Defines the clear coat layer roughness.
  100665. */
  100666. roughness: number;
  100667. private _indiceOfRefraction;
  100668. /**
  100669. * Defines the indice of refraction of the clear coat.
  100670. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100671. * The default fits with a polyurethane material.
  100672. * Changing the default value is more performance intensive.
  100673. */
  100674. indiceOfRefraction: number;
  100675. private _texture;
  100676. /**
  100677. * Stores the clear coat values in a texture.
  100678. */
  100679. texture: Nullable<BaseTexture>;
  100680. private _bumpTexture;
  100681. /**
  100682. * Define the clear coat specific bump texture.
  100683. */
  100684. bumpTexture: Nullable<BaseTexture>;
  100685. private _isTintEnabled;
  100686. /**
  100687. * Defines if the clear coat tint is enabled in the material.
  100688. */
  100689. isTintEnabled: boolean;
  100690. /**
  100691. * Defines if the clear coat tint is enabled in the material.
  100692. * This is only use if tint is enabled
  100693. */
  100694. tintColor: Color3;
  100695. /**
  100696. * Defines if the distance at which the tint color should be found in the
  100697. * clear coat media.
  100698. * This is only use if tint is enabled
  100699. */
  100700. tintColorAtDistance: number;
  100701. /**
  100702. * Defines the clear coat layer thickness.
  100703. * This is only use if tint is enabled
  100704. */
  100705. tintThickness: number;
  100706. private _tintTexture;
  100707. /**
  100708. * Stores the clear tint values in a texture.
  100709. * rgb is tint
  100710. * a is a thickness factor
  100711. */
  100712. tintTexture: Nullable<BaseTexture>;
  100713. /** @hidden */
  100714. private _internalMarkAllSubMeshesAsTexturesDirty;
  100715. /** @hidden */
  100716. _markAllSubMeshesAsTexturesDirty(): void;
  100717. /**
  100718. * Instantiate a new istance of clear coat configuration.
  100719. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100720. */
  100721. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100722. /**
  100723. * Specifies that the submesh is ready to be used.
  100724. * @param defines the list of "defines" to update.
  100725. * @param scene defines the scene the material belongs to.
  100726. * @param engine defines the engine the material belongs to.
  100727. * @param disableBumpMap defines wether the material disables bump or not.
  100728. * @returns - boolean indicating that the submesh is ready or not.
  100729. */
  100730. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100731. /**
  100732. * Checks to see if a texture is used in the material.
  100733. * @param defines the list of "defines" to update.
  100734. * @param scene defines the scene to the material belongs to.
  100735. */
  100736. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100737. /**
  100738. * Binds the material data.
  100739. * @param uniformBuffer defines the Uniform buffer to fill in.
  100740. * @param scene defines the scene the material belongs to.
  100741. * @param engine defines the engine the material belongs to.
  100742. * @param disableBumpMap defines wether the material disables bump or not.
  100743. * @param isFrozen defines wether the material is frozen or not.
  100744. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100745. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100746. */
  100747. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100748. /**
  100749. * Checks to see if a texture is used in the material.
  100750. * @param texture - Base texture to use.
  100751. * @returns - Boolean specifying if a texture is used in the material.
  100752. */
  100753. hasTexture(texture: BaseTexture): boolean;
  100754. /**
  100755. * Returns an array of the actively used textures.
  100756. * @param activeTextures Array of BaseTextures
  100757. */
  100758. getActiveTextures(activeTextures: BaseTexture[]): void;
  100759. /**
  100760. * Returns the animatable textures.
  100761. * @param animatables Array of animatable textures.
  100762. */
  100763. getAnimatables(animatables: IAnimatable[]): void;
  100764. /**
  100765. * Disposes the resources of the material.
  100766. * @param forceDisposeTextures - Forces the disposal of all textures.
  100767. */
  100768. dispose(forceDisposeTextures?: boolean): void;
  100769. /**
  100770. * Get the current class name of the texture useful for serialization or dynamic coding.
  100771. * @returns "PBRClearCoatConfiguration"
  100772. */
  100773. getClassName(): string;
  100774. /**
  100775. * Add fallbacks to the effect fallbacks list.
  100776. * @param defines defines the Base texture to use.
  100777. * @param fallbacks defines the current fallback list.
  100778. * @param currentRank defines the current fallback rank.
  100779. * @returns the new fallback rank.
  100780. */
  100781. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100782. /**
  100783. * Add the required uniforms to the current list.
  100784. * @param uniforms defines the current uniform list.
  100785. */
  100786. static AddUniforms(uniforms: string[]): void;
  100787. /**
  100788. * Add the required samplers to the current list.
  100789. * @param samplers defines the current sampler list.
  100790. */
  100791. static AddSamplers(samplers: string[]): void;
  100792. /**
  100793. * Add the required uniforms to the current buffer.
  100794. * @param uniformBuffer defines the current uniform buffer.
  100795. */
  100796. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100797. /**
  100798. * Makes a duplicate of the current configuration into another one.
  100799. * @param clearCoatConfiguration define the config where to copy the info
  100800. */
  100801. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100802. /**
  100803. * Serializes this clear coat configuration.
  100804. * @returns - An object with the serialized config.
  100805. */
  100806. serialize(): any;
  100807. /**
  100808. * Parses a Clear Coat Configuration from a serialized object.
  100809. * @param source - Serialized object.
  100810. */
  100811. parse(source: any): void;
  100812. }
  100813. }
  100814. declare module BABYLON {
  100815. /**
  100816. * @hidden
  100817. */
  100818. export interface IMaterialAnisotropicDefines {
  100819. ANISOTROPIC: boolean;
  100820. ANISOTROPIC_TEXTURE: boolean;
  100821. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100822. MAINUV1: boolean;
  100823. _areTexturesDirty: boolean;
  100824. _needUVs: boolean;
  100825. }
  100826. /**
  100827. * Define the code related to the anisotropic parameters of the pbr material.
  100828. */
  100829. export class PBRAnisotropicConfiguration {
  100830. private _isEnabled;
  100831. /**
  100832. * Defines if the anisotropy is enabled in the material.
  100833. */
  100834. isEnabled: boolean;
  100835. /**
  100836. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100837. */
  100838. intensity: number;
  100839. /**
  100840. * Defines if the effect is along the tangents, bitangents or in between.
  100841. * By default, the effect is "strectching" the highlights along the tangents.
  100842. */
  100843. direction: Vector2;
  100844. private _texture;
  100845. /**
  100846. * Stores the anisotropy values in a texture.
  100847. * rg is direction (like normal from -1 to 1)
  100848. * b is a intensity
  100849. */
  100850. texture: Nullable<BaseTexture>;
  100851. /** @hidden */
  100852. private _internalMarkAllSubMeshesAsTexturesDirty;
  100853. /** @hidden */
  100854. _markAllSubMeshesAsTexturesDirty(): void;
  100855. /**
  100856. * Instantiate a new istance of anisotropy configuration.
  100857. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100858. */
  100859. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100860. /**
  100861. * Specifies that the submesh is ready to be used.
  100862. * @param defines the list of "defines" to update.
  100863. * @param scene defines the scene the material belongs to.
  100864. * @returns - boolean indicating that the submesh is ready or not.
  100865. */
  100866. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100867. /**
  100868. * Checks to see if a texture is used in the material.
  100869. * @param defines the list of "defines" to update.
  100870. * @param mesh the mesh we are preparing the defines for.
  100871. * @param scene defines the scene the material belongs to.
  100872. */
  100873. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100874. /**
  100875. * Binds the material data.
  100876. * @param uniformBuffer defines the Uniform buffer to fill in.
  100877. * @param scene defines the scene the material belongs to.
  100878. * @param isFrozen defines wether the material is frozen or not.
  100879. */
  100880. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100881. /**
  100882. * Checks to see if a texture is used in the material.
  100883. * @param texture - Base texture to use.
  100884. * @returns - Boolean specifying if a texture is used in the material.
  100885. */
  100886. hasTexture(texture: BaseTexture): boolean;
  100887. /**
  100888. * Returns an array of the actively used textures.
  100889. * @param activeTextures Array of BaseTextures
  100890. */
  100891. getActiveTextures(activeTextures: BaseTexture[]): void;
  100892. /**
  100893. * Returns the animatable textures.
  100894. * @param animatables Array of animatable textures.
  100895. */
  100896. getAnimatables(animatables: IAnimatable[]): void;
  100897. /**
  100898. * Disposes the resources of the material.
  100899. * @param forceDisposeTextures - Forces the disposal of all textures.
  100900. */
  100901. dispose(forceDisposeTextures?: boolean): void;
  100902. /**
  100903. * Get the current class name of the texture useful for serialization or dynamic coding.
  100904. * @returns "PBRAnisotropicConfiguration"
  100905. */
  100906. getClassName(): string;
  100907. /**
  100908. * Add fallbacks to the effect fallbacks list.
  100909. * @param defines defines the Base texture to use.
  100910. * @param fallbacks defines the current fallback list.
  100911. * @param currentRank defines the current fallback rank.
  100912. * @returns the new fallback rank.
  100913. */
  100914. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100915. /**
  100916. * Add the required uniforms to the current list.
  100917. * @param uniforms defines the current uniform list.
  100918. */
  100919. static AddUniforms(uniforms: string[]): void;
  100920. /**
  100921. * Add the required uniforms to the current buffer.
  100922. * @param uniformBuffer defines the current uniform buffer.
  100923. */
  100924. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100925. /**
  100926. * Add the required samplers to the current list.
  100927. * @param samplers defines the current sampler list.
  100928. */
  100929. static AddSamplers(samplers: string[]): void;
  100930. /**
  100931. * Makes a duplicate of the current configuration into another one.
  100932. * @param anisotropicConfiguration define the config where to copy the info
  100933. */
  100934. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100935. /**
  100936. * Serializes this anisotropy configuration.
  100937. * @returns - An object with the serialized config.
  100938. */
  100939. serialize(): any;
  100940. /**
  100941. * Parses a anisotropy Configuration from a serialized object.
  100942. * @param source - Serialized object.
  100943. */
  100944. parse(source: any): void;
  100945. }
  100946. }
  100947. declare module BABYLON {
  100948. /**
  100949. * @hidden
  100950. */
  100951. export interface IMaterialBRDFDefines {
  100952. BRDF_V_HEIGHT_CORRELATED: boolean;
  100953. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100954. /** @hidden */
  100955. _areMiscDirty: boolean;
  100956. }
  100957. /**
  100958. * Define the code related to the BRDF parameters of the pbr material.
  100959. */
  100960. export class PBRBRDFConfiguration {
  100961. private _useEnergyConservation;
  100962. /**
  100963. * Defines if the material uses energy conservation.
  100964. */
  100965. useEnergyConservation: boolean;
  100966. private _useSmithVisibilityHeightCorrelated;
  100967. /**
  100968. * LEGACY Mode set to false
  100969. * Defines if the material uses height smith correlated visibility term.
  100970. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100971. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100972. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100973. * Not relying on height correlated will also disable energy conservation.
  100974. */
  100975. useSmithVisibilityHeightCorrelated: boolean;
  100976. /** @hidden */
  100977. private _internalMarkAllSubMeshesAsMiscDirty;
  100978. /** @hidden */
  100979. _markAllSubMeshesAsMiscDirty(): void;
  100980. /**
  100981. * Instantiate a new istance of clear coat configuration.
  100982. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100983. */
  100984. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100985. /**
  100986. * Checks to see if a texture is used in the material.
  100987. * @param defines the list of "defines" to update.
  100988. */
  100989. prepareDefines(defines: IMaterialBRDFDefines): void;
  100990. /**
  100991. * Get the current class name of the texture useful for serialization or dynamic coding.
  100992. * @returns "PBRClearCoatConfiguration"
  100993. */
  100994. getClassName(): string;
  100995. /**
  100996. * Makes a duplicate of the current configuration into another one.
  100997. * @param brdfConfiguration define the config where to copy the info
  100998. */
  100999. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101000. /**
  101001. * Serializes this BRDF configuration.
  101002. * @returns - An object with the serialized config.
  101003. */
  101004. serialize(): any;
  101005. /**
  101006. * Parses a BRDF Configuration from a serialized object.
  101007. * @param source - Serialized object.
  101008. */
  101009. parse(source: any): void;
  101010. }
  101011. }
  101012. declare module BABYLON {
  101013. /**
  101014. * @hidden
  101015. */
  101016. export interface IMaterialSheenDefines {
  101017. SHEEN: boolean;
  101018. SHEEN_TEXTURE: boolean;
  101019. SHEEN_TEXTUREDIRECTUV: number;
  101020. SHEEN_LINKWITHALBEDO: boolean;
  101021. /** @hidden */
  101022. _areTexturesDirty: boolean;
  101023. }
  101024. /**
  101025. * Define the code related to the Sheen parameters of the pbr material.
  101026. */
  101027. export class PBRSheenConfiguration {
  101028. private _isEnabled;
  101029. /**
  101030. * Defines if the material uses sheen.
  101031. */
  101032. isEnabled: boolean;
  101033. private _linkSheenWithAlbedo;
  101034. /**
  101035. * Defines if the sheen is linked to the sheen color.
  101036. */
  101037. linkSheenWithAlbedo: boolean;
  101038. /**
  101039. * Defines the sheen intensity.
  101040. */
  101041. intensity: number;
  101042. /**
  101043. * Defines the sheen color.
  101044. */
  101045. color: Color3;
  101046. private _texture;
  101047. /**
  101048. * Stores the sheen tint values in a texture.
  101049. * rgb is tint
  101050. * a is a intensity
  101051. */
  101052. texture: Nullable<BaseTexture>;
  101053. /** @hidden */
  101054. private _internalMarkAllSubMeshesAsTexturesDirty;
  101055. /** @hidden */
  101056. _markAllSubMeshesAsTexturesDirty(): void;
  101057. /**
  101058. * Instantiate a new istance of clear coat configuration.
  101059. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101060. */
  101061. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101062. /**
  101063. * Specifies that the submesh is ready to be used.
  101064. * @param defines the list of "defines" to update.
  101065. * @param scene defines the scene the material belongs to.
  101066. * @returns - boolean indicating that the submesh is ready or not.
  101067. */
  101068. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101069. /**
  101070. * Checks to see if a texture is used in the material.
  101071. * @param defines the list of "defines" to update.
  101072. * @param scene defines the scene the material belongs to.
  101073. */
  101074. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101075. /**
  101076. * Binds the material data.
  101077. * @param uniformBuffer defines the Uniform buffer to fill in.
  101078. * @param scene defines the scene the material belongs to.
  101079. * @param isFrozen defines wether the material is frozen or not.
  101080. */
  101081. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101082. /**
  101083. * Checks to see if a texture is used in the material.
  101084. * @param texture - Base texture to use.
  101085. * @returns - Boolean specifying if a texture is used in the material.
  101086. */
  101087. hasTexture(texture: BaseTexture): boolean;
  101088. /**
  101089. * Returns an array of the actively used textures.
  101090. * @param activeTextures Array of BaseTextures
  101091. */
  101092. getActiveTextures(activeTextures: BaseTexture[]): void;
  101093. /**
  101094. * Returns the animatable textures.
  101095. * @param animatables Array of animatable textures.
  101096. */
  101097. getAnimatables(animatables: IAnimatable[]): void;
  101098. /**
  101099. * Disposes the resources of the material.
  101100. * @param forceDisposeTextures - Forces the disposal of all textures.
  101101. */
  101102. dispose(forceDisposeTextures?: boolean): void;
  101103. /**
  101104. * Get the current class name of the texture useful for serialization or dynamic coding.
  101105. * @returns "PBRSheenConfiguration"
  101106. */
  101107. getClassName(): string;
  101108. /**
  101109. * Add fallbacks to the effect fallbacks list.
  101110. * @param defines defines the Base texture to use.
  101111. * @param fallbacks defines the current fallback list.
  101112. * @param currentRank defines the current fallback rank.
  101113. * @returns the new fallback rank.
  101114. */
  101115. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101116. /**
  101117. * Add the required uniforms to the current list.
  101118. * @param uniforms defines the current uniform list.
  101119. */
  101120. static AddUniforms(uniforms: string[]): void;
  101121. /**
  101122. * Add the required uniforms to the current buffer.
  101123. * @param uniformBuffer defines the current uniform buffer.
  101124. */
  101125. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101126. /**
  101127. * Add the required samplers to the current list.
  101128. * @param samplers defines the current sampler list.
  101129. */
  101130. static AddSamplers(samplers: string[]): void;
  101131. /**
  101132. * Makes a duplicate of the current configuration into another one.
  101133. * @param sheenConfiguration define the config where to copy the info
  101134. */
  101135. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101136. /**
  101137. * Serializes this BRDF configuration.
  101138. * @returns - An object with the serialized config.
  101139. */
  101140. serialize(): any;
  101141. /**
  101142. * Parses a Sheen Configuration from a serialized object.
  101143. * @param source - Serialized object.
  101144. */
  101145. parse(source: any): void;
  101146. }
  101147. }
  101148. declare module BABYLON {
  101149. /** @hidden */
  101150. export var pbrFragmentDeclaration: {
  101151. name: string;
  101152. shader: string;
  101153. };
  101154. }
  101155. declare module BABYLON {
  101156. /** @hidden */
  101157. export var pbrUboDeclaration: {
  101158. name: string;
  101159. shader: string;
  101160. };
  101161. }
  101162. declare module BABYLON {
  101163. /** @hidden */
  101164. export var pbrFunctions: {
  101165. name: string;
  101166. shader: string;
  101167. };
  101168. }
  101169. declare module BABYLON {
  101170. /** @hidden */
  101171. export var harmonicsFunctions: {
  101172. name: string;
  101173. shader: string;
  101174. };
  101175. }
  101176. declare module BABYLON {
  101177. /** @hidden */
  101178. export var pbrPreLightingFunctions: {
  101179. name: string;
  101180. shader: string;
  101181. };
  101182. }
  101183. declare module BABYLON {
  101184. /** @hidden */
  101185. export var pbrFalloffLightingFunctions: {
  101186. name: string;
  101187. shader: string;
  101188. };
  101189. }
  101190. declare module BABYLON {
  101191. /** @hidden */
  101192. export var pbrLightingFunctions: {
  101193. name: string;
  101194. shader: string;
  101195. };
  101196. }
  101197. declare module BABYLON {
  101198. /** @hidden */
  101199. export var pbrDebug: {
  101200. name: string;
  101201. shader: string;
  101202. };
  101203. }
  101204. declare module BABYLON {
  101205. /** @hidden */
  101206. export var pbrPixelShader: {
  101207. name: string;
  101208. shader: string;
  101209. };
  101210. }
  101211. declare module BABYLON {
  101212. /** @hidden */
  101213. export var pbrVertexDeclaration: {
  101214. name: string;
  101215. shader: string;
  101216. };
  101217. }
  101218. declare module BABYLON {
  101219. /** @hidden */
  101220. export var pbrVertexShader: {
  101221. name: string;
  101222. shader: string;
  101223. };
  101224. }
  101225. declare module BABYLON {
  101226. /**
  101227. * The Physically based material base class of BJS.
  101228. *
  101229. * This offers the main features of a standard PBR material.
  101230. * For more information, please refer to the documentation :
  101231. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101232. */
  101233. export abstract class PBRBaseMaterial extends PushMaterial {
  101234. /**
  101235. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101236. */
  101237. static readonly PBRMATERIAL_OPAQUE: number;
  101238. /**
  101239. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101240. */
  101241. static readonly PBRMATERIAL_ALPHATEST: number;
  101242. /**
  101243. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101244. */
  101245. static readonly PBRMATERIAL_ALPHABLEND: number;
  101246. /**
  101247. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101248. * They are also discarded below the alpha cutoff threshold to improve performances.
  101249. */
  101250. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101251. /**
  101252. * Defines the default value of how much AO map is occluding the analytical lights
  101253. * (point spot...).
  101254. */
  101255. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101256. /**
  101257. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  101258. */
  101259. static readonly LIGHTFALLOFF_PHYSICAL: number;
  101260. /**
  101261. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  101262. * to enhance interoperability with other engines.
  101263. */
  101264. static readonly LIGHTFALLOFF_GLTF: number;
  101265. /**
  101266. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  101267. * to enhance interoperability with other materials.
  101268. */
  101269. static readonly LIGHTFALLOFF_STANDARD: number;
  101270. /**
  101271. * Intensity of the direct lights e.g. the four lights available in your scene.
  101272. * This impacts both the direct diffuse and specular highlights.
  101273. */
  101274. protected _directIntensity: number;
  101275. /**
  101276. * Intensity of the emissive part of the material.
  101277. * This helps controlling the emissive effect without modifying the emissive color.
  101278. */
  101279. protected _emissiveIntensity: number;
  101280. /**
  101281. * Intensity of the environment e.g. how much the environment will light the object
  101282. * either through harmonics for rough material or through the refelction for shiny ones.
  101283. */
  101284. protected _environmentIntensity: number;
  101285. /**
  101286. * This is a special control allowing the reduction of the specular highlights coming from the
  101287. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101288. */
  101289. protected _specularIntensity: number;
  101290. /**
  101291. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  101292. */
  101293. private _lightingInfos;
  101294. /**
  101295. * Debug Control allowing disabling the bump map on this material.
  101296. */
  101297. protected _disableBumpMap: boolean;
  101298. /**
  101299. * AKA Diffuse Texture in standard nomenclature.
  101300. */
  101301. protected _albedoTexture: BaseTexture;
  101302. /**
  101303. * AKA Occlusion Texture in other nomenclature.
  101304. */
  101305. protected _ambientTexture: BaseTexture;
  101306. /**
  101307. * AKA Occlusion Texture Intensity in other nomenclature.
  101308. */
  101309. protected _ambientTextureStrength: number;
  101310. /**
  101311. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101312. * 1 means it completely occludes it
  101313. * 0 mean it has no impact
  101314. */
  101315. protected _ambientTextureImpactOnAnalyticalLights: number;
  101316. /**
  101317. * Stores the alpha values in a texture.
  101318. */
  101319. protected _opacityTexture: BaseTexture;
  101320. /**
  101321. * Stores the reflection values in a texture.
  101322. */
  101323. protected _reflectionTexture: BaseTexture;
  101324. /**
  101325. * Stores the refraction values in a texture.
  101326. */
  101327. protected _refractionTexture: BaseTexture;
  101328. /**
  101329. * Stores the emissive values in a texture.
  101330. */
  101331. protected _emissiveTexture: BaseTexture;
  101332. /**
  101333. * AKA Specular texture in other nomenclature.
  101334. */
  101335. protected _reflectivityTexture: BaseTexture;
  101336. /**
  101337. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101338. */
  101339. protected _metallicTexture: BaseTexture;
  101340. /**
  101341. * Specifies the metallic scalar of the metallic/roughness workflow.
  101342. * Can also be used to scale the metalness values of the metallic texture.
  101343. */
  101344. protected _metallic: Nullable<number>;
  101345. /**
  101346. * Specifies the roughness scalar of the metallic/roughness workflow.
  101347. * Can also be used to scale the roughness values of the metallic texture.
  101348. */
  101349. protected _roughness: Nullable<number>;
  101350. /**
  101351. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101352. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101353. */
  101354. protected _microSurfaceTexture: BaseTexture;
  101355. /**
  101356. * Stores surface normal data used to displace a mesh in a texture.
  101357. */
  101358. protected _bumpTexture: BaseTexture;
  101359. /**
  101360. * Stores the pre-calculated light information of a mesh in a texture.
  101361. */
  101362. protected _lightmapTexture: BaseTexture;
  101363. /**
  101364. * The color of a material in ambient lighting.
  101365. */
  101366. protected _ambientColor: Color3;
  101367. /**
  101368. * AKA Diffuse Color in other nomenclature.
  101369. */
  101370. protected _albedoColor: Color3;
  101371. /**
  101372. * AKA Specular Color in other nomenclature.
  101373. */
  101374. protected _reflectivityColor: Color3;
  101375. /**
  101376. * The color applied when light is reflected from a material.
  101377. */
  101378. protected _reflectionColor: Color3;
  101379. /**
  101380. * The color applied when light is emitted from a material.
  101381. */
  101382. protected _emissiveColor: Color3;
  101383. /**
  101384. * AKA Glossiness in other nomenclature.
  101385. */
  101386. protected _microSurface: number;
  101387. /**
  101388. * source material index of refraction (IOR)' / 'destination material IOR.
  101389. */
  101390. protected _indexOfRefraction: number;
  101391. /**
  101392. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101393. */
  101394. protected _invertRefractionY: boolean;
  101395. /**
  101396. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101397. * Materials half opaque for instance using refraction could benefit from this control.
  101398. */
  101399. protected _linkRefractionWithTransparency: boolean;
  101400. /**
  101401. * Specifies that the material will use the light map as a show map.
  101402. */
  101403. protected _useLightmapAsShadowmap: boolean;
  101404. /**
  101405. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101406. * makes the reflect vector face the model (under horizon).
  101407. */
  101408. protected _useHorizonOcclusion: boolean;
  101409. /**
  101410. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101411. * too much the area relying on ambient texture to define their ambient occlusion.
  101412. */
  101413. protected _useRadianceOcclusion: boolean;
  101414. /**
  101415. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101416. */
  101417. protected _useAlphaFromAlbedoTexture: boolean;
  101418. /**
  101419. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101420. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101421. */
  101422. protected _useSpecularOverAlpha: boolean;
  101423. /**
  101424. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101425. */
  101426. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101427. /**
  101428. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101429. */
  101430. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101431. /**
  101432. * Specifies if the metallic texture contains the roughness information in its green channel.
  101433. */
  101434. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101435. /**
  101436. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101437. */
  101438. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101439. /**
  101440. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101441. */
  101442. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101443. /**
  101444. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101445. */
  101446. protected _useAmbientInGrayScale: boolean;
  101447. /**
  101448. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101449. * The material will try to infer what glossiness each pixel should be.
  101450. */
  101451. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101452. /**
  101453. * Defines the falloff type used in this material.
  101454. * It by default is Physical.
  101455. */
  101456. protected _lightFalloff: number;
  101457. /**
  101458. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101459. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101460. */
  101461. protected _useRadianceOverAlpha: boolean;
  101462. /**
  101463. * Allows using an object space normal map (instead of tangent space).
  101464. */
  101465. protected _useObjectSpaceNormalMap: boolean;
  101466. /**
  101467. * Allows using the bump map in parallax mode.
  101468. */
  101469. protected _useParallax: boolean;
  101470. /**
  101471. * Allows using the bump map in parallax occlusion mode.
  101472. */
  101473. protected _useParallaxOcclusion: boolean;
  101474. /**
  101475. * Controls the scale bias of the parallax mode.
  101476. */
  101477. protected _parallaxScaleBias: number;
  101478. /**
  101479. * If sets to true, disables all the lights affecting the material.
  101480. */
  101481. protected _disableLighting: boolean;
  101482. /**
  101483. * Number of Simultaneous lights allowed on the material.
  101484. */
  101485. protected _maxSimultaneousLights: number;
  101486. /**
  101487. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101488. */
  101489. protected _invertNormalMapX: boolean;
  101490. /**
  101491. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101492. */
  101493. protected _invertNormalMapY: boolean;
  101494. /**
  101495. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101496. */
  101497. protected _twoSidedLighting: boolean;
  101498. /**
  101499. * Defines the alpha limits in alpha test mode.
  101500. */
  101501. protected _alphaCutOff: number;
  101502. /**
  101503. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101504. */
  101505. protected _forceAlphaTest: boolean;
  101506. /**
  101507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101508. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101509. */
  101510. protected _useAlphaFresnel: boolean;
  101511. /**
  101512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101513. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101514. */
  101515. protected _useLinearAlphaFresnel: boolean;
  101516. /**
  101517. * The transparency mode of the material.
  101518. */
  101519. protected _transparencyMode: Nullable<number>;
  101520. /**
  101521. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101522. * from cos thetav and roughness:
  101523. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101524. */
  101525. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101526. /**
  101527. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101528. */
  101529. protected _forceIrradianceInFragment: boolean;
  101530. /**
  101531. * Force normal to face away from face.
  101532. */
  101533. protected _forceNormalForward: boolean;
  101534. /**
  101535. * Enables specular anti aliasing in the PBR shader.
  101536. * It will both interacts on the Geometry for analytical and IBL lighting.
  101537. * It also prefilter the roughness map based on the bump values.
  101538. */
  101539. protected _enableSpecularAntiAliasing: boolean;
  101540. /**
  101541. * Default configuration related to image processing available in the PBR Material.
  101542. */
  101543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101544. /**
  101545. * Keep track of the image processing observer to allow dispose and replace.
  101546. */
  101547. private _imageProcessingObserver;
  101548. /**
  101549. * Attaches a new image processing configuration to the PBR Material.
  101550. * @param configuration
  101551. */
  101552. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101553. /**
  101554. * Stores the available render targets.
  101555. */
  101556. private _renderTargets;
  101557. /**
  101558. * Sets the global ambient color for the material used in lighting calculations.
  101559. */
  101560. private _globalAmbientColor;
  101561. /**
  101562. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101563. */
  101564. private _useLogarithmicDepth;
  101565. /**
  101566. * If set to true, no lighting calculations will be applied.
  101567. */
  101568. private _unlit;
  101569. private _debugMode;
  101570. /**
  101571. * @hidden
  101572. * This is reserved for the inspector.
  101573. * Defines the material debug mode.
  101574. * It helps seeing only some components of the material while troubleshooting.
  101575. */
  101576. debugMode: number;
  101577. /**
  101578. * @hidden
  101579. * This is reserved for the inspector.
  101580. * Specify from where on screen the debug mode should start.
  101581. * The value goes from -1 (full screen) to 1 (not visible)
  101582. * It helps with side by side comparison against the final render
  101583. * This defaults to -1
  101584. */
  101585. private debugLimit;
  101586. /**
  101587. * @hidden
  101588. * This is reserved for the inspector.
  101589. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101590. * You can use the factor to better multiply the final value.
  101591. */
  101592. private debugFactor;
  101593. /**
  101594. * Defines the clear coat layer parameters for the material.
  101595. */
  101596. readonly clearCoat: PBRClearCoatConfiguration;
  101597. /**
  101598. * Defines the anisotropic parameters for the material.
  101599. */
  101600. readonly anisotropy: PBRAnisotropicConfiguration;
  101601. /**
  101602. * Defines the BRDF parameters for the material.
  101603. */
  101604. readonly brdf: PBRBRDFConfiguration;
  101605. /**
  101606. * Defines the Sheen parameters for the material.
  101607. */
  101608. readonly sheen: PBRSheenConfiguration;
  101609. /**
  101610. * Instantiates a new PBRMaterial instance.
  101611. *
  101612. * @param name The material name
  101613. * @param scene The scene the material will be use in.
  101614. */
  101615. constructor(name: string, scene: Scene);
  101616. /**
  101617. * Gets a boolean indicating that current material needs to register RTT
  101618. */
  101619. readonly hasRenderTargetTextures: boolean;
  101620. /**
  101621. * Gets the name of the material class.
  101622. */
  101623. getClassName(): string;
  101624. /**
  101625. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101626. */
  101627. /**
  101628. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101629. */
  101630. useLogarithmicDepth: boolean;
  101631. /**
  101632. * Gets the current transparency mode.
  101633. */
  101634. /**
  101635. * Sets the transparency mode of the material.
  101636. *
  101637. * | Value | Type | Description |
  101638. * | ----- | ----------------------------------- | ----------- |
  101639. * | 0 | OPAQUE | |
  101640. * | 1 | ALPHATEST | |
  101641. * | 2 | ALPHABLEND | |
  101642. * | 3 | ALPHATESTANDBLEND | |
  101643. *
  101644. */
  101645. transparencyMode: Nullable<number>;
  101646. /**
  101647. * Returns true if alpha blending should be disabled.
  101648. */
  101649. private readonly _disableAlphaBlending;
  101650. /**
  101651. * Specifies whether or not this material should be rendered in alpha blend mode.
  101652. */
  101653. needAlphaBlending(): boolean;
  101654. /**
  101655. * Specifies if the mesh will require alpha blending.
  101656. * @param mesh - BJS mesh.
  101657. */
  101658. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101659. /**
  101660. * Specifies whether or not this material should be rendered in alpha test mode.
  101661. */
  101662. needAlphaTesting(): boolean;
  101663. /**
  101664. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101665. */
  101666. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101667. /**
  101668. * Gets the texture used for the alpha test.
  101669. */
  101670. getAlphaTestTexture(): BaseTexture;
  101671. /**
  101672. * Specifies that the submesh is ready to be used.
  101673. * @param mesh - BJS mesh.
  101674. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101675. * @param useInstances - Specifies that instances should be used.
  101676. * @returns - boolean indicating that the submesh is ready or not.
  101677. */
  101678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101679. /**
  101680. * Specifies if the material uses metallic roughness workflow.
  101681. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101682. */
  101683. isMetallicWorkflow(): boolean;
  101684. private _prepareEffect;
  101685. private _prepareDefines;
  101686. /**
  101687. * Force shader compilation
  101688. */
  101689. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101690. clipPlane: boolean;
  101691. }>): void;
  101692. /**
  101693. * Initializes the uniform buffer layout for the shader.
  101694. */
  101695. buildUniformLayout(): void;
  101696. /**
  101697. * Unbinds the textures.
  101698. */
  101699. unbind(): void;
  101700. /**
  101701. * Binds the submesh data.
  101702. * @param world - The world matrix.
  101703. * @param mesh - The BJS mesh.
  101704. * @param subMesh - A submesh of the BJS mesh.
  101705. */
  101706. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101707. /**
  101708. * Returns the animatable textures.
  101709. * @returns - Array of animatable textures.
  101710. */
  101711. getAnimatables(): IAnimatable[];
  101712. /**
  101713. * Returns the texture used for reflections.
  101714. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101715. */
  101716. private _getReflectionTexture;
  101717. /**
  101718. * Returns the texture used for refraction or null if none is used.
  101719. * @returns - Refection texture if present. If no refraction texture and refraction
  101720. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101721. */
  101722. private _getRefractionTexture;
  101723. /**
  101724. * Returns an array of the actively used textures.
  101725. * @returns - Array of BaseTextures
  101726. */
  101727. getActiveTextures(): BaseTexture[];
  101728. /**
  101729. * Checks to see if a texture is used in the material.
  101730. * @param texture - Base texture to use.
  101731. * @returns - Boolean specifying if a texture is used in the material.
  101732. */
  101733. hasTexture(texture: BaseTexture): boolean;
  101734. /**
  101735. * Disposes the resources of the material.
  101736. * @param forceDisposeEffect - Forces the disposal of effects.
  101737. * @param forceDisposeTextures - Forces the disposal of all textures.
  101738. */
  101739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101740. }
  101741. }
  101742. declare module BABYLON {
  101743. /**
  101744. * The Physically based material of BJS.
  101745. *
  101746. * This offers the main features of a standard PBR material.
  101747. * For more information, please refer to the documentation :
  101748. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101749. */
  101750. export class PBRMaterial extends PBRBaseMaterial {
  101751. /**
  101752. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101753. */
  101754. static readonly PBRMATERIAL_OPAQUE: number;
  101755. /**
  101756. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101757. */
  101758. static readonly PBRMATERIAL_ALPHATEST: number;
  101759. /**
  101760. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101761. */
  101762. static readonly PBRMATERIAL_ALPHABLEND: number;
  101763. /**
  101764. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101765. * They are also discarded below the alpha cutoff threshold to improve performances.
  101766. */
  101767. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101768. /**
  101769. * Defines the default value of how much AO map is occluding the analytical lights
  101770. * (point spot...).
  101771. */
  101772. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101773. /**
  101774. * Intensity of the direct lights e.g. the four lights available in your scene.
  101775. * This impacts both the direct diffuse and specular highlights.
  101776. */
  101777. directIntensity: number;
  101778. /**
  101779. * Intensity of the emissive part of the material.
  101780. * This helps controlling the emissive effect without modifying the emissive color.
  101781. */
  101782. emissiveIntensity: number;
  101783. /**
  101784. * Intensity of the environment e.g. how much the environment will light the object
  101785. * either through harmonics for rough material or through the refelction for shiny ones.
  101786. */
  101787. environmentIntensity: number;
  101788. /**
  101789. * This is a special control allowing the reduction of the specular highlights coming from the
  101790. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101791. */
  101792. specularIntensity: number;
  101793. /**
  101794. * Debug Control allowing disabling the bump map on this material.
  101795. */
  101796. disableBumpMap: boolean;
  101797. /**
  101798. * AKA Diffuse Texture in standard nomenclature.
  101799. */
  101800. albedoTexture: BaseTexture;
  101801. /**
  101802. * AKA Occlusion Texture in other nomenclature.
  101803. */
  101804. ambientTexture: BaseTexture;
  101805. /**
  101806. * AKA Occlusion Texture Intensity in other nomenclature.
  101807. */
  101808. ambientTextureStrength: number;
  101809. /**
  101810. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101811. * 1 means it completely occludes it
  101812. * 0 mean it has no impact
  101813. */
  101814. ambientTextureImpactOnAnalyticalLights: number;
  101815. /**
  101816. * Stores the alpha values in a texture.
  101817. */
  101818. opacityTexture: BaseTexture;
  101819. /**
  101820. * Stores the reflection values in a texture.
  101821. */
  101822. reflectionTexture: Nullable<BaseTexture>;
  101823. /**
  101824. * Stores the emissive values in a texture.
  101825. */
  101826. emissiveTexture: BaseTexture;
  101827. /**
  101828. * AKA Specular texture in other nomenclature.
  101829. */
  101830. reflectivityTexture: BaseTexture;
  101831. /**
  101832. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101833. */
  101834. metallicTexture: BaseTexture;
  101835. /**
  101836. * Specifies the metallic scalar of the metallic/roughness workflow.
  101837. * Can also be used to scale the metalness values of the metallic texture.
  101838. */
  101839. metallic: Nullable<number>;
  101840. /**
  101841. * Specifies the roughness scalar of the metallic/roughness workflow.
  101842. * Can also be used to scale the roughness values of the metallic texture.
  101843. */
  101844. roughness: Nullable<number>;
  101845. /**
  101846. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101847. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101848. */
  101849. microSurfaceTexture: BaseTexture;
  101850. /**
  101851. * Stores surface normal data used to displace a mesh in a texture.
  101852. */
  101853. bumpTexture: BaseTexture;
  101854. /**
  101855. * Stores the pre-calculated light information of a mesh in a texture.
  101856. */
  101857. lightmapTexture: BaseTexture;
  101858. /**
  101859. * Stores the refracted light information in a texture.
  101860. */
  101861. refractionTexture: BaseTexture;
  101862. /**
  101863. * The color of a material in ambient lighting.
  101864. */
  101865. ambientColor: Color3;
  101866. /**
  101867. * AKA Diffuse Color in other nomenclature.
  101868. */
  101869. albedoColor: Color3;
  101870. /**
  101871. * AKA Specular Color in other nomenclature.
  101872. */
  101873. reflectivityColor: Color3;
  101874. /**
  101875. * The color reflected from the material.
  101876. */
  101877. reflectionColor: Color3;
  101878. /**
  101879. * The color emitted from the material.
  101880. */
  101881. emissiveColor: Color3;
  101882. /**
  101883. * AKA Glossiness in other nomenclature.
  101884. */
  101885. microSurface: number;
  101886. /**
  101887. * source material index of refraction (IOR)' / 'destination material IOR.
  101888. */
  101889. indexOfRefraction: number;
  101890. /**
  101891. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101892. */
  101893. invertRefractionY: boolean;
  101894. /**
  101895. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101896. * Materials half opaque for instance using refraction could benefit from this control.
  101897. */
  101898. linkRefractionWithTransparency: boolean;
  101899. /**
  101900. * If true, the light map contains occlusion information instead of lighting info.
  101901. */
  101902. useLightmapAsShadowmap: boolean;
  101903. /**
  101904. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101905. */
  101906. useAlphaFromAlbedoTexture: boolean;
  101907. /**
  101908. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101909. */
  101910. forceAlphaTest: boolean;
  101911. /**
  101912. * Defines the alpha limits in alpha test mode.
  101913. */
  101914. alphaCutOff: number;
  101915. /**
  101916. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101917. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101918. */
  101919. useSpecularOverAlpha: boolean;
  101920. /**
  101921. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101922. */
  101923. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101924. /**
  101925. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101926. */
  101927. useRoughnessFromMetallicTextureAlpha: boolean;
  101928. /**
  101929. * Specifies if the metallic texture contains the roughness information in its green channel.
  101930. */
  101931. useRoughnessFromMetallicTextureGreen: boolean;
  101932. /**
  101933. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101934. */
  101935. useMetallnessFromMetallicTextureBlue: boolean;
  101936. /**
  101937. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101938. */
  101939. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101940. /**
  101941. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101942. */
  101943. useAmbientInGrayScale: boolean;
  101944. /**
  101945. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101946. * The material will try to infer what glossiness each pixel should be.
  101947. */
  101948. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101949. /**
  101950. * BJS is using an harcoded light falloff based on a manually sets up range.
  101951. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101952. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101953. */
  101954. /**
  101955. * BJS is using an harcoded light falloff based on a manually sets up range.
  101956. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101957. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101958. */
  101959. usePhysicalLightFalloff: boolean;
  101960. /**
  101961. * In order to support the falloff compatibility with gltf, a special mode has been added
  101962. * to reproduce the gltf light falloff.
  101963. */
  101964. /**
  101965. * In order to support the falloff compatibility with gltf, a special mode has been added
  101966. * to reproduce the gltf light falloff.
  101967. */
  101968. useGLTFLightFalloff: boolean;
  101969. /**
  101970. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101971. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101972. */
  101973. useRadianceOverAlpha: boolean;
  101974. /**
  101975. * Allows using an object space normal map (instead of tangent space).
  101976. */
  101977. useObjectSpaceNormalMap: boolean;
  101978. /**
  101979. * Allows using the bump map in parallax mode.
  101980. */
  101981. useParallax: boolean;
  101982. /**
  101983. * Allows using the bump map in parallax occlusion mode.
  101984. */
  101985. useParallaxOcclusion: boolean;
  101986. /**
  101987. * Controls the scale bias of the parallax mode.
  101988. */
  101989. parallaxScaleBias: number;
  101990. /**
  101991. * If sets to true, disables all the lights affecting the material.
  101992. */
  101993. disableLighting: boolean;
  101994. /**
  101995. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101996. */
  101997. forceIrradianceInFragment: boolean;
  101998. /**
  101999. * Number of Simultaneous lights allowed on the material.
  102000. */
  102001. maxSimultaneousLights: number;
  102002. /**
  102003. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102004. */
  102005. invertNormalMapX: boolean;
  102006. /**
  102007. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102008. */
  102009. invertNormalMapY: boolean;
  102010. /**
  102011. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102012. */
  102013. twoSidedLighting: boolean;
  102014. /**
  102015. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102016. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102017. */
  102018. useAlphaFresnel: boolean;
  102019. /**
  102020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102021. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102022. */
  102023. useLinearAlphaFresnel: boolean;
  102024. /**
  102025. * Let user defines the brdf lookup texture used for IBL.
  102026. * A default 8bit version is embedded but you could point at :
  102027. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  102028. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102029. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102030. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102031. */
  102032. environmentBRDFTexture: Nullable<BaseTexture>;
  102033. /**
  102034. * Force normal to face away from face.
  102035. */
  102036. forceNormalForward: boolean;
  102037. /**
  102038. * Enables specular anti aliasing in the PBR shader.
  102039. * It will both interacts on the Geometry for analytical and IBL lighting.
  102040. * It also prefilter the roughness map based on the bump values.
  102041. */
  102042. enableSpecularAntiAliasing: boolean;
  102043. /**
  102044. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102045. * makes the reflect vector face the model (under horizon).
  102046. */
  102047. useHorizonOcclusion: boolean;
  102048. /**
  102049. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102050. * too much the area relying on ambient texture to define their ambient occlusion.
  102051. */
  102052. useRadianceOcclusion: boolean;
  102053. /**
  102054. * If set to true, no lighting calculations will be applied.
  102055. */
  102056. unlit: boolean;
  102057. /**
  102058. * Gets the image processing configuration used either in this material.
  102059. */
  102060. /**
  102061. * Sets the Default image processing configuration used either in the this material.
  102062. *
  102063. * If sets to null, the scene one is in use.
  102064. */
  102065. imageProcessingConfiguration: ImageProcessingConfiguration;
  102066. /**
  102067. * Gets wether the color curves effect is enabled.
  102068. */
  102069. /**
  102070. * Sets wether the color curves effect is enabled.
  102071. */
  102072. cameraColorCurvesEnabled: boolean;
  102073. /**
  102074. * Gets wether the color grading effect is enabled.
  102075. */
  102076. /**
  102077. * Gets wether the color grading effect is enabled.
  102078. */
  102079. cameraColorGradingEnabled: boolean;
  102080. /**
  102081. * Gets wether tonemapping is enabled or not.
  102082. */
  102083. /**
  102084. * Sets wether tonemapping is enabled or not
  102085. */
  102086. cameraToneMappingEnabled: boolean;
  102087. /**
  102088. * The camera exposure used on this material.
  102089. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102090. * This corresponds to a photographic exposure.
  102091. */
  102092. /**
  102093. * The camera exposure used on this material.
  102094. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102095. * This corresponds to a photographic exposure.
  102096. */
  102097. cameraExposure: number;
  102098. /**
  102099. * Gets The camera contrast used on this material.
  102100. */
  102101. /**
  102102. * Sets The camera contrast used on this material.
  102103. */
  102104. cameraContrast: number;
  102105. /**
  102106. * Gets the Color Grading 2D Lookup Texture.
  102107. */
  102108. /**
  102109. * Sets the Color Grading 2D Lookup Texture.
  102110. */
  102111. cameraColorGradingTexture: Nullable<BaseTexture>;
  102112. /**
  102113. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102114. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102115. * 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;
  102116. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102117. */
  102118. /**
  102119. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102120. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102121. * 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;
  102122. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102123. */
  102124. cameraColorCurves: Nullable<ColorCurves>;
  102125. /**
  102126. * Instantiates a new PBRMaterial instance.
  102127. *
  102128. * @param name The material name
  102129. * @param scene The scene the material will be use in.
  102130. */
  102131. constructor(name: string, scene: Scene);
  102132. /**
  102133. * Returns the name of this material class.
  102134. */
  102135. getClassName(): string;
  102136. /**
  102137. * Makes a duplicate of the current material.
  102138. * @param name - name to use for the new material.
  102139. */
  102140. clone(name: string): PBRMaterial;
  102141. /**
  102142. * Serializes this PBR Material.
  102143. * @returns - An object with the serialized material.
  102144. */
  102145. serialize(): any;
  102146. /**
  102147. * Parses a PBR Material from a serialized object.
  102148. * @param source - Serialized object.
  102149. * @param scene - BJS scene instance.
  102150. * @param rootUrl - url for the scene object
  102151. * @returns - PBRMaterial
  102152. */
  102153. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102154. }
  102155. }
  102156. declare module BABYLON {
  102157. /**
  102158. * Direct draw surface info
  102159. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102160. */
  102161. export interface DDSInfo {
  102162. /**
  102163. * Width of the texture
  102164. */
  102165. width: number;
  102166. /**
  102167. * Width of the texture
  102168. */
  102169. height: number;
  102170. /**
  102171. * Number of Mipmaps for the texture
  102172. * @see https://en.wikipedia.org/wiki/Mipmap
  102173. */
  102174. mipmapCount: number;
  102175. /**
  102176. * If the textures format is a known fourCC format
  102177. * @see https://www.fourcc.org/
  102178. */
  102179. isFourCC: boolean;
  102180. /**
  102181. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102182. */
  102183. isRGB: boolean;
  102184. /**
  102185. * If the texture is a lumincance format
  102186. */
  102187. isLuminance: boolean;
  102188. /**
  102189. * If this is a cube texture
  102190. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102191. */
  102192. isCube: boolean;
  102193. /**
  102194. * If the texture is a compressed format eg. FOURCC_DXT1
  102195. */
  102196. isCompressed: boolean;
  102197. /**
  102198. * The dxgiFormat of the texture
  102199. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102200. */
  102201. dxgiFormat: number;
  102202. /**
  102203. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102204. */
  102205. textureType: number;
  102206. /**
  102207. * Sphericle polynomial created for the dds texture
  102208. */
  102209. sphericalPolynomial?: SphericalPolynomial;
  102210. }
  102211. /**
  102212. * Class used to provide DDS decompression tools
  102213. */
  102214. export class DDSTools {
  102215. /**
  102216. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102217. */
  102218. static StoreLODInAlphaChannel: boolean;
  102219. /**
  102220. * Gets DDS information from an array buffer
  102221. * @param arrayBuffer defines the array buffer to read data from
  102222. * @returns the DDS information
  102223. */
  102224. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102225. private static _FloatView;
  102226. private static _Int32View;
  102227. private static _ToHalfFloat;
  102228. private static _FromHalfFloat;
  102229. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102230. private static _GetHalfFloatRGBAArrayBuffer;
  102231. private static _GetFloatRGBAArrayBuffer;
  102232. private static _GetFloatAsUIntRGBAArrayBuffer;
  102233. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102234. private static _GetRGBAArrayBuffer;
  102235. private static _ExtractLongWordOrder;
  102236. private static _GetRGBArrayBuffer;
  102237. private static _GetLuminanceArrayBuffer;
  102238. /**
  102239. * Uploads DDS Levels to a Babylon Texture
  102240. * @hidden
  102241. */
  102242. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102243. }
  102244. interface Engine {
  102245. /**
  102246. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102247. * @param rootUrl defines the url where the file to load is located
  102248. * @param scene defines the current scene
  102249. * @param lodScale defines scale to apply to the mip map selection
  102250. * @param lodOffset defines offset to apply to the mip map selection
  102251. * @param onLoad defines an optional callback raised when the texture is loaded
  102252. * @param onError defines an optional callback raised if there is an issue to load the texture
  102253. * @param format defines the format of the data
  102254. * @param forcedExtension defines the extension to use to pick the right loader
  102255. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102256. * @returns the cube texture as an InternalTexture
  102257. */
  102258. 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;
  102259. }
  102260. }
  102261. declare module BABYLON {
  102262. /**
  102263. * Implementation of the DDS Texture Loader.
  102264. * @hidden
  102265. */
  102266. export class _DDSTextureLoader implements IInternalTextureLoader {
  102267. /**
  102268. * Defines wether the loader supports cascade loading the different faces.
  102269. */
  102270. readonly supportCascades: boolean;
  102271. /**
  102272. * This returns if the loader support the current file information.
  102273. * @param extension defines the file extension of the file being loaded
  102274. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102275. * @param fallback defines the fallback internal texture if any
  102276. * @param isBase64 defines whether the texture is encoded as a base64
  102277. * @param isBuffer defines whether the texture data are stored as a buffer
  102278. * @returns true if the loader can load the specified file
  102279. */
  102280. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102281. /**
  102282. * Transform the url before loading if required.
  102283. * @param rootUrl the url of the texture
  102284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102285. * @returns the transformed texture
  102286. */
  102287. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102288. /**
  102289. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102290. * @param rootUrl the url of the texture
  102291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102292. * @returns the fallback texture
  102293. */
  102294. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102295. /**
  102296. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102297. * @param data contains the texture data
  102298. * @param texture defines the BabylonJS internal texture
  102299. * @param createPolynomials will be true if polynomials have been requested
  102300. * @param onLoad defines the callback to trigger once the texture is ready
  102301. * @param onError defines the callback to trigger in case of error
  102302. */
  102303. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102304. /**
  102305. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102306. * @param data contains the texture data
  102307. * @param texture defines the BabylonJS internal texture
  102308. * @param callback defines the method to call once ready to upload
  102309. */
  102310. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102311. }
  102312. }
  102313. declare module BABYLON {
  102314. /** @hidden */
  102315. export var rgbdEncodePixelShader: {
  102316. name: string;
  102317. shader: string;
  102318. };
  102319. }
  102320. declare module BABYLON {
  102321. /** @hidden */
  102322. export var rgbdDecodePixelShader: {
  102323. name: string;
  102324. shader: string;
  102325. };
  102326. }
  102327. declare module BABYLON {
  102328. /**
  102329. * Raw texture data and descriptor sufficient for WebGL texture upload
  102330. */
  102331. export interface EnvironmentTextureInfo {
  102332. /**
  102333. * Version of the environment map
  102334. */
  102335. version: number;
  102336. /**
  102337. * Width of image
  102338. */
  102339. width: number;
  102340. /**
  102341. * Irradiance information stored in the file.
  102342. */
  102343. irradiance: any;
  102344. /**
  102345. * Specular information stored in the file.
  102346. */
  102347. specular: any;
  102348. }
  102349. /**
  102350. * Sets of helpers addressing the serialization and deserialization of environment texture
  102351. * stored in a BabylonJS env file.
  102352. * Those files are usually stored as .env files.
  102353. */
  102354. export class EnvironmentTextureTools {
  102355. /**
  102356. * Magic number identifying the env file.
  102357. */
  102358. private static _MagicBytes;
  102359. /**
  102360. * Gets the environment info from an env file.
  102361. * @param data The array buffer containing the .env bytes.
  102362. * @returns the environment file info (the json header) if successfully parsed.
  102363. */
  102364. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102365. /**
  102366. * Creates an environment texture from a loaded cube texture.
  102367. * @param texture defines the cube texture to convert in env file
  102368. * @return a promise containing the environment data if succesfull.
  102369. */
  102370. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102371. /**
  102372. * Creates a JSON representation of the spherical data.
  102373. * @param texture defines the texture containing the polynomials
  102374. * @return the JSON representation of the spherical info
  102375. */
  102376. private static _CreateEnvTextureIrradiance;
  102377. /**
  102378. * Uploads the texture info contained in the env file to the GPU.
  102379. * @param texture defines the internal texture to upload to
  102380. * @param arrayBuffer defines the buffer cotaining the data to load
  102381. * @param info defines the texture info retrieved through the GetEnvInfo method
  102382. * @returns a promise
  102383. */
  102384. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102385. /**
  102386. * Uploads the levels of image data to the GPU.
  102387. * @param texture defines the internal texture to upload to
  102388. * @param imageData defines the array buffer views of image data [mipmap][face]
  102389. * @returns a promise
  102390. */
  102391. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102392. /**
  102393. * Uploads spherical polynomials information to the texture.
  102394. * @param texture defines the texture we are trying to upload the information to
  102395. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102396. */
  102397. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102398. /** @hidden */
  102399. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102400. }
  102401. }
  102402. declare module BABYLON {
  102403. /**
  102404. * Implementation of the ENV Texture Loader.
  102405. * @hidden
  102406. */
  102407. export class _ENVTextureLoader implements IInternalTextureLoader {
  102408. /**
  102409. * Defines wether the loader supports cascade loading the different faces.
  102410. */
  102411. readonly supportCascades: boolean;
  102412. /**
  102413. * This returns if the loader support the current file information.
  102414. * @param extension defines the file extension of the file being loaded
  102415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102416. * @param fallback defines the fallback internal texture if any
  102417. * @param isBase64 defines whether the texture is encoded as a base64
  102418. * @param isBuffer defines whether the texture data are stored as a buffer
  102419. * @returns true if the loader can load the specified file
  102420. */
  102421. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102422. /**
  102423. * Transform the url before loading if required.
  102424. * @param rootUrl the url of the texture
  102425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102426. * @returns the transformed texture
  102427. */
  102428. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102429. /**
  102430. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102431. * @param rootUrl the url of the texture
  102432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102433. * @returns the fallback texture
  102434. */
  102435. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102436. /**
  102437. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102438. * @param data contains the texture data
  102439. * @param texture defines the BabylonJS internal texture
  102440. * @param createPolynomials will be true if polynomials have been requested
  102441. * @param onLoad defines the callback to trigger once the texture is ready
  102442. * @param onError defines the callback to trigger in case of error
  102443. */
  102444. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102445. /**
  102446. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102447. * @param data contains the texture data
  102448. * @param texture defines the BabylonJS internal texture
  102449. * @param callback defines the method to call once ready to upload
  102450. */
  102451. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102452. }
  102453. }
  102454. declare module BABYLON {
  102455. /**
  102456. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102457. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102458. */
  102459. export class KhronosTextureContainer {
  102460. /** contents of the KTX container file */
  102461. arrayBuffer: any;
  102462. private static HEADER_LEN;
  102463. private static COMPRESSED_2D;
  102464. private static COMPRESSED_3D;
  102465. private static TEX_2D;
  102466. private static TEX_3D;
  102467. /**
  102468. * Gets the openGL type
  102469. */
  102470. glType: number;
  102471. /**
  102472. * Gets the openGL type size
  102473. */
  102474. glTypeSize: number;
  102475. /**
  102476. * Gets the openGL format
  102477. */
  102478. glFormat: number;
  102479. /**
  102480. * Gets the openGL internal format
  102481. */
  102482. glInternalFormat: number;
  102483. /**
  102484. * Gets the base internal format
  102485. */
  102486. glBaseInternalFormat: number;
  102487. /**
  102488. * Gets image width in pixel
  102489. */
  102490. pixelWidth: number;
  102491. /**
  102492. * Gets image height in pixel
  102493. */
  102494. pixelHeight: number;
  102495. /**
  102496. * Gets image depth in pixels
  102497. */
  102498. pixelDepth: number;
  102499. /**
  102500. * Gets the number of array elements
  102501. */
  102502. numberOfArrayElements: number;
  102503. /**
  102504. * Gets the number of faces
  102505. */
  102506. numberOfFaces: number;
  102507. /**
  102508. * Gets the number of mipmap levels
  102509. */
  102510. numberOfMipmapLevels: number;
  102511. /**
  102512. * Gets the bytes of key value data
  102513. */
  102514. bytesOfKeyValueData: number;
  102515. /**
  102516. * Gets the load type
  102517. */
  102518. loadType: number;
  102519. /**
  102520. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102521. */
  102522. isInvalid: boolean;
  102523. /**
  102524. * Creates a new KhronosTextureContainer
  102525. * @param arrayBuffer contents of the KTX container file
  102526. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102527. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102528. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102529. */
  102530. constructor(
  102531. /** contents of the KTX container file */
  102532. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102533. /**
  102534. * Uploads KTX content to a Babylon Texture.
  102535. * It is assumed that the texture has already been created & is currently bound
  102536. * @hidden
  102537. */
  102538. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102539. private _upload2DCompressedLevels;
  102540. }
  102541. }
  102542. declare module BABYLON {
  102543. /**
  102544. * Implementation of the KTX Texture Loader.
  102545. * @hidden
  102546. */
  102547. export class _KTXTextureLoader implements IInternalTextureLoader {
  102548. /**
  102549. * Defines wether the loader supports cascade loading the different faces.
  102550. */
  102551. readonly supportCascades: boolean;
  102552. /**
  102553. * This returns if the loader support the current file information.
  102554. * @param extension defines the file extension of the file being loaded
  102555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102556. * @param fallback defines the fallback internal texture if any
  102557. * @param isBase64 defines whether the texture is encoded as a base64
  102558. * @param isBuffer defines whether the texture data are stored as a buffer
  102559. * @returns true if the loader can load the specified file
  102560. */
  102561. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102562. /**
  102563. * Transform the url before loading if required.
  102564. * @param rootUrl the url of the texture
  102565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102566. * @returns the transformed texture
  102567. */
  102568. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102569. /**
  102570. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102571. * @param rootUrl the url of the texture
  102572. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102573. * @returns the fallback texture
  102574. */
  102575. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102576. /**
  102577. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102578. * @param data contains the texture data
  102579. * @param texture defines the BabylonJS internal texture
  102580. * @param createPolynomials will be true if polynomials have been requested
  102581. * @param onLoad defines the callback to trigger once the texture is ready
  102582. * @param onError defines the callback to trigger in case of error
  102583. */
  102584. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102585. /**
  102586. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102587. * @param data contains the texture data
  102588. * @param texture defines the BabylonJS internal texture
  102589. * @param callback defines the method to call once ready to upload
  102590. */
  102591. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102592. }
  102593. }
  102594. declare module BABYLON {
  102595. /** @hidden */
  102596. export var _forceSceneHelpersToBundle: boolean;
  102597. interface Scene {
  102598. /**
  102599. * Creates a default light for the scene.
  102600. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102601. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102602. */
  102603. createDefaultLight(replace?: boolean): void;
  102604. /**
  102605. * Creates a default camera for the scene.
  102606. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102607. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102608. * @param replace has default false, when true replaces the active camera in the scene
  102609. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102610. */
  102611. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102612. /**
  102613. * Creates a default camera and a default light.
  102614. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102615. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102616. * @param replace has the default false, when true replaces the active camera/light in the scene
  102617. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102618. */
  102619. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102620. /**
  102621. * Creates a new sky box
  102622. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102623. * @param environmentTexture defines the texture to use as environment texture
  102624. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102625. * @param scale defines the overall scale of the skybox
  102626. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102627. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102628. * @returns a new mesh holding the sky box
  102629. */
  102630. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102631. /**
  102632. * Creates a new environment
  102633. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102634. * @param options defines the options you can use to configure the environment
  102635. * @returns the new EnvironmentHelper
  102636. */
  102637. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102638. /**
  102639. * Creates a new VREXperienceHelper
  102640. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102641. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102642. * @returns a new VREXperienceHelper
  102643. */
  102644. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102645. /**
  102646. * Creates a new XREXperienceHelper
  102647. * @see http://doc.babylonjs.com/how_to/webxr
  102648. * @returns a promise for a new XREXperienceHelper
  102649. */
  102650. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102651. }
  102652. }
  102653. declare module BABYLON {
  102654. /**
  102655. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102656. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102657. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102658. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102659. */
  102660. export class VideoDome extends TransformNode {
  102661. /**
  102662. * Define the video source as a Monoscopic panoramic 360 video.
  102663. */
  102664. static readonly MODE_MONOSCOPIC: number;
  102665. /**
  102666. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102667. */
  102668. static readonly MODE_TOPBOTTOM: number;
  102669. /**
  102670. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102671. */
  102672. static readonly MODE_SIDEBYSIDE: number;
  102673. private _useDirectMapping;
  102674. /**
  102675. * The video texture being displayed on the sphere
  102676. */
  102677. protected _videoTexture: VideoTexture;
  102678. /**
  102679. * Gets the video texture being displayed on the sphere
  102680. */
  102681. readonly videoTexture: VideoTexture;
  102682. /**
  102683. * The skybox material
  102684. */
  102685. protected _material: BackgroundMaterial;
  102686. /**
  102687. * The surface used for the skybox
  102688. */
  102689. protected _mesh: Mesh;
  102690. /**
  102691. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102692. * Also see the options.resolution property.
  102693. */
  102694. fovMultiplier: number;
  102695. private _videoMode;
  102696. /**
  102697. * Gets or set the current video mode for the video. It can be:
  102698. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102699. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102700. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102701. */
  102702. videoMode: number;
  102703. /**
  102704. * Oberserver used in Stereoscopic VR Mode.
  102705. */
  102706. private _onBeforeCameraRenderObserver;
  102707. /**
  102708. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102709. * @param name Element's name, child elements will append suffixes for their own names.
  102710. * @param urlsOrVideo defines the url(s) or the video element to use
  102711. * @param options An object containing optional or exposed sub element properties
  102712. */
  102713. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102714. resolution?: number;
  102715. clickToPlay?: boolean;
  102716. autoPlay?: boolean;
  102717. loop?: boolean;
  102718. size?: number;
  102719. poster?: string;
  102720. faceForward?: boolean;
  102721. useDirectMapping?: boolean;
  102722. }, scene: Scene);
  102723. private _changeVideoMode;
  102724. /**
  102725. * Releases resources associated with this node.
  102726. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102727. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102728. */
  102729. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102730. }
  102731. }
  102732. declare module BABYLON {
  102733. /**
  102734. * This class can be used to get instrumentation data from a Babylon engine
  102735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102736. */
  102737. export class EngineInstrumentation implements IDisposable {
  102738. /**
  102739. * Define the instrumented engine.
  102740. */
  102741. engine: Engine;
  102742. private _captureGPUFrameTime;
  102743. private _gpuFrameTimeToken;
  102744. private _gpuFrameTime;
  102745. private _captureShaderCompilationTime;
  102746. private _shaderCompilationTime;
  102747. private _onBeginFrameObserver;
  102748. private _onEndFrameObserver;
  102749. private _onBeforeShaderCompilationObserver;
  102750. private _onAfterShaderCompilationObserver;
  102751. /**
  102752. * Gets the perf counter used for GPU frame time
  102753. */
  102754. readonly gpuFrameTimeCounter: PerfCounter;
  102755. /**
  102756. * Gets the GPU frame time capture status
  102757. */
  102758. /**
  102759. * Enable or disable the GPU frame time capture
  102760. */
  102761. captureGPUFrameTime: boolean;
  102762. /**
  102763. * Gets the perf counter used for shader compilation time
  102764. */
  102765. readonly shaderCompilationTimeCounter: PerfCounter;
  102766. /**
  102767. * Gets the shader compilation time capture status
  102768. */
  102769. /**
  102770. * Enable or disable the shader compilation time capture
  102771. */
  102772. captureShaderCompilationTime: boolean;
  102773. /**
  102774. * Instantiates a new engine instrumentation.
  102775. * This class can be used to get instrumentation data from a Babylon engine
  102776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102777. * @param engine Defines the engine to instrument
  102778. */
  102779. constructor(
  102780. /**
  102781. * Define the instrumented engine.
  102782. */
  102783. engine: Engine);
  102784. /**
  102785. * Dispose and release associated resources.
  102786. */
  102787. dispose(): void;
  102788. }
  102789. }
  102790. declare module BABYLON {
  102791. /**
  102792. * This class can be used to get instrumentation data from a Babylon engine
  102793. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102794. */
  102795. export class SceneInstrumentation implements IDisposable {
  102796. /**
  102797. * Defines the scene to instrument
  102798. */
  102799. scene: Scene;
  102800. private _captureActiveMeshesEvaluationTime;
  102801. private _activeMeshesEvaluationTime;
  102802. private _captureRenderTargetsRenderTime;
  102803. private _renderTargetsRenderTime;
  102804. private _captureFrameTime;
  102805. private _frameTime;
  102806. private _captureRenderTime;
  102807. private _renderTime;
  102808. private _captureInterFrameTime;
  102809. private _interFrameTime;
  102810. private _captureParticlesRenderTime;
  102811. private _particlesRenderTime;
  102812. private _captureSpritesRenderTime;
  102813. private _spritesRenderTime;
  102814. private _capturePhysicsTime;
  102815. private _physicsTime;
  102816. private _captureAnimationsTime;
  102817. private _animationsTime;
  102818. private _captureCameraRenderTime;
  102819. private _cameraRenderTime;
  102820. private _onBeforeActiveMeshesEvaluationObserver;
  102821. private _onAfterActiveMeshesEvaluationObserver;
  102822. private _onBeforeRenderTargetsRenderObserver;
  102823. private _onAfterRenderTargetsRenderObserver;
  102824. private _onAfterRenderObserver;
  102825. private _onBeforeDrawPhaseObserver;
  102826. private _onAfterDrawPhaseObserver;
  102827. private _onBeforeAnimationsObserver;
  102828. private _onBeforeParticlesRenderingObserver;
  102829. private _onAfterParticlesRenderingObserver;
  102830. private _onBeforeSpritesRenderingObserver;
  102831. private _onAfterSpritesRenderingObserver;
  102832. private _onBeforePhysicsObserver;
  102833. private _onAfterPhysicsObserver;
  102834. private _onAfterAnimationsObserver;
  102835. private _onBeforeCameraRenderObserver;
  102836. private _onAfterCameraRenderObserver;
  102837. /**
  102838. * Gets the perf counter used for active meshes evaluation time
  102839. */
  102840. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102841. /**
  102842. * Gets the active meshes evaluation time capture status
  102843. */
  102844. /**
  102845. * Enable or disable the active meshes evaluation time capture
  102846. */
  102847. captureActiveMeshesEvaluationTime: boolean;
  102848. /**
  102849. * Gets the perf counter used for render targets render time
  102850. */
  102851. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102852. /**
  102853. * Gets the render targets render time capture status
  102854. */
  102855. /**
  102856. * Enable or disable the render targets render time capture
  102857. */
  102858. captureRenderTargetsRenderTime: boolean;
  102859. /**
  102860. * Gets the perf counter used for particles render time
  102861. */
  102862. readonly particlesRenderTimeCounter: PerfCounter;
  102863. /**
  102864. * Gets the particles render time capture status
  102865. */
  102866. /**
  102867. * Enable or disable the particles render time capture
  102868. */
  102869. captureParticlesRenderTime: boolean;
  102870. /**
  102871. * Gets the perf counter used for sprites render time
  102872. */
  102873. readonly spritesRenderTimeCounter: PerfCounter;
  102874. /**
  102875. * Gets the sprites render time capture status
  102876. */
  102877. /**
  102878. * Enable or disable the sprites render time capture
  102879. */
  102880. captureSpritesRenderTime: boolean;
  102881. /**
  102882. * Gets the perf counter used for physics time
  102883. */
  102884. readonly physicsTimeCounter: PerfCounter;
  102885. /**
  102886. * Gets the physics time capture status
  102887. */
  102888. /**
  102889. * Enable or disable the physics time capture
  102890. */
  102891. capturePhysicsTime: boolean;
  102892. /**
  102893. * Gets the perf counter used for animations time
  102894. */
  102895. readonly animationsTimeCounter: PerfCounter;
  102896. /**
  102897. * Gets the animations time capture status
  102898. */
  102899. /**
  102900. * Enable or disable the animations time capture
  102901. */
  102902. captureAnimationsTime: boolean;
  102903. /**
  102904. * Gets the perf counter used for frame time capture
  102905. */
  102906. readonly frameTimeCounter: PerfCounter;
  102907. /**
  102908. * Gets the frame time capture status
  102909. */
  102910. /**
  102911. * Enable or disable the frame time capture
  102912. */
  102913. captureFrameTime: boolean;
  102914. /**
  102915. * Gets the perf counter used for inter-frames time capture
  102916. */
  102917. readonly interFrameTimeCounter: PerfCounter;
  102918. /**
  102919. * Gets the inter-frames time capture status
  102920. */
  102921. /**
  102922. * Enable or disable the inter-frames time capture
  102923. */
  102924. captureInterFrameTime: boolean;
  102925. /**
  102926. * Gets the perf counter used for render time capture
  102927. */
  102928. readonly renderTimeCounter: PerfCounter;
  102929. /**
  102930. * Gets the render time capture status
  102931. */
  102932. /**
  102933. * Enable or disable the render time capture
  102934. */
  102935. captureRenderTime: boolean;
  102936. /**
  102937. * Gets the perf counter used for camera render time capture
  102938. */
  102939. readonly cameraRenderTimeCounter: PerfCounter;
  102940. /**
  102941. * Gets the camera render time capture status
  102942. */
  102943. /**
  102944. * Enable or disable the camera render time capture
  102945. */
  102946. captureCameraRenderTime: boolean;
  102947. /**
  102948. * Gets the perf counter used for draw calls
  102949. */
  102950. readonly drawCallsCounter: PerfCounter;
  102951. /**
  102952. * Gets the perf counter used for texture collisions
  102953. */
  102954. readonly textureCollisionsCounter: PerfCounter;
  102955. /**
  102956. * Instantiates a new scene instrumentation.
  102957. * This class can be used to get instrumentation data from a Babylon engine
  102958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102959. * @param scene Defines the scene to instrument
  102960. */
  102961. constructor(
  102962. /**
  102963. * Defines the scene to instrument
  102964. */
  102965. scene: Scene);
  102966. /**
  102967. * Dispose and release associated resources.
  102968. */
  102969. dispose(): void;
  102970. }
  102971. }
  102972. declare module BABYLON {
  102973. /** @hidden */
  102974. export var glowMapGenerationPixelShader: {
  102975. name: string;
  102976. shader: string;
  102977. };
  102978. }
  102979. declare module BABYLON {
  102980. /** @hidden */
  102981. export var glowMapGenerationVertexShader: {
  102982. name: string;
  102983. shader: string;
  102984. };
  102985. }
  102986. declare module BABYLON {
  102987. /**
  102988. * Effect layer options. This helps customizing the behaviour
  102989. * of the effect layer.
  102990. */
  102991. export interface IEffectLayerOptions {
  102992. /**
  102993. * Multiplication factor apply to the canvas size to compute the render target size
  102994. * used to generated the objects (the smaller the faster).
  102995. */
  102996. mainTextureRatio: number;
  102997. /**
  102998. * Enforces a fixed size texture to ensure effect stability across devices.
  102999. */
  103000. mainTextureFixedSize?: number;
  103001. /**
  103002. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103003. */
  103004. alphaBlendingMode: number;
  103005. /**
  103006. * The camera attached to the layer.
  103007. */
  103008. camera: Nullable<Camera>;
  103009. /**
  103010. * The rendering group to draw the layer in.
  103011. */
  103012. renderingGroupId: number;
  103013. }
  103014. /**
  103015. * The effect layer Helps adding post process effect blended with the main pass.
  103016. *
  103017. * This can be for instance use to generate glow or higlight effects on the scene.
  103018. *
  103019. * The effect layer class can not be used directly and is intented to inherited from to be
  103020. * customized per effects.
  103021. */
  103022. export abstract class EffectLayer {
  103023. private _vertexBuffers;
  103024. private _indexBuffer;
  103025. private _cachedDefines;
  103026. private _effectLayerMapGenerationEffect;
  103027. private _effectLayerOptions;
  103028. private _mergeEffect;
  103029. protected _scene: Scene;
  103030. protected _engine: Engine;
  103031. protected _maxSize: number;
  103032. protected _mainTextureDesiredSize: ISize;
  103033. protected _mainTexture: RenderTargetTexture;
  103034. protected _shouldRender: boolean;
  103035. protected _postProcesses: PostProcess[];
  103036. protected _textures: BaseTexture[];
  103037. protected _emissiveTextureAndColor: {
  103038. texture: Nullable<BaseTexture>;
  103039. color: Color4;
  103040. };
  103041. /**
  103042. * The name of the layer
  103043. */
  103044. name: string;
  103045. /**
  103046. * The clear color of the texture used to generate the glow map.
  103047. */
  103048. neutralColor: Color4;
  103049. /**
  103050. * Specifies wether the highlight layer is enabled or not.
  103051. */
  103052. isEnabled: boolean;
  103053. /**
  103054. * Gets the camera attached to the layer.
  103055. */
  103056. readonly camera: Nullable<Camera>;
  103057. /**
  103058. * Gets the rendering group id the layer should render in.
  103059. */
  103060. readonly renderingGroupId: number;
  103061. /**
  103062. * An event triggered when the effect layer has been disposed.
  103063. */
  103064. onDisposeObservable: Observable<EffectLayer>;
  103065. /**
  103066. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  103067. */
  103068. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  103069. /**
  103070. * An event triggered when the generated texture is being merged in the scene.
  103071. */
  103072. onBeforeComposeObservable: Observable<EffectLayer>;
  103073. /**
  103074. * An event triggered when the generated texture has been merged in the scene.
  103075. */
  103076. onAfterComposeObservable: Observable<EffectLayer>;
  103077. /**
  103078. * An event triggered when the efffect layer changes its size.
  103079. */
  103080. onSizeChangedObservable: Observable<EffectLayer>;
  103081. /** @hidden */
  103082. static _SceneComponentInitialization: (scene: Scene) => void;
  103083. /**
  103084. * Instantiates a new effect Layer and references it in the scene.
  103085. * @param name The name of the layer
  103086. * @param scene The scene to use the layer in
  103087. */
  103088. constructor(
  103089. /** The Friendly of the effect in the scene */
  103090. name: string, scene: Scene);
  103091. /**
  103092. * Get the effect name of the layer.
  103093. * @return The effect name
  103094. */
  103095. abstract getEffectName(): string;
  103096. /**
  103097. * Checks for the readiness of the element composing the layer.
  103098. * @param subMesh the mesh to check for
  103099. * @param useInstances specify wether or not to use instances to render the mesh
  103100. * @return true if ready otherwise, false
  103101. */
  103102. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103103. /**
  103104. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103105. * @returns true if the effect requires stencil during the main canvas render pass.
  103106. */
  103107. abstract needStencil(): boolean;
  103108. /**
  103109. * Create the merge effect. This is the shader use to blit the information back
  103110. * to the main canvas at the end of the scene rendering.
  103111. * @returns The effect containing the shader used to merge the effect on the main canvas
  103112. */
  103113. protected abstract _createMergeEffect(): Effect;
  103114. /**
  103115. * Creates the render target textures and post processes used in the effect layer.
  103116. */
  103117. protected abstract _createTextureAndPostProcesses(): void;
  103118. /**
  103119. * Implementation specific of rendering the generating effect on the main canvas.
  103120. * @param effect The effect used to render through
  103121. */
  103122. protected abstract _internalRender(effect: Effect): void;
  103123. /**
  103124. * Sets the required values for both the emissive texture and and the main color.
  103125. */
  103126. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103127. /**
  103128. * Free any resources and references associated to a mesh.
  103129. * Internal use
  103130. * @param mesh The mesh to free.
  103131. */
  103132. abstract _disposeMesh(mesh: Mesh): void;
  103133. /**
  103134. * Serializes this layer (Glow or Highlight for example)
  103135. * @returns a serialized layer object
  103136. */
  103137. abstract serialize?(): any;
  103138. /**
  103139. * Initializes the effect layer with the required options.
  103140. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  103141. */
  103142. protected _init(options: Partial<IEffectLayerOptions>): void;
  103143. /**
  103144. * Generates the index buffer of the full screen quad blending to the main canvas.
  103145. */
  103146. private _generateIndexBuffer;
  103147. /**
  103148. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103149. */
  103150. private _genrateVertexBuffer;
  103151. /**
  103152. * Sets the main texture desired size which is the closest power of two
  103153. * of the engine canvas size.
  103154. */
  103155. private _setMainTextureSize;
  103156. /**
  103157. * Creates the main texture for the effect layer.
  103158. */
  103159. protected _createMainTexture(): void;
  103160. /**
  103161. * Adds specific effects defines.
  103162. * @param defines The defines to add specifics to.
  103163. */
  103164. protected _addCustomEffectDefines(defines: string[]): void;
  103165. /**
  103166. * Checks for the readiness of the element composing the layer.
  103167. * @param subMesh the mesh to check for
  103168. * @param useInstances specify wether or not to use instances to render the mesh
  103169. * @param emissiveTexture the associated emissive texture used to generate the glow
  103170. * @return true if ready otherwise, false
  103171. */
  103172. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  103173. /**
  103174. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  103175. */
  103176. render(): void;
  103177. /**
  103178. * Determine if a given mesh will be used in the current effect.
  103179. * @param mesh mesh to test
  103180. * @returns true if the mesh will be used
  103181. */
  103182. hasMesh(mesh: AbstractMesh): boolean;
  103183. /**
  103184. * Returns true if the layer contains information to display, otherwise false.
  103185. * @returns true if the glow layer should be rendered
  103186. */
  103187. shouldRender(): boolean;
  103188. /**
  103189. * Returns true if the mesh should render, otherwise false.
  103190. * @param mesh The mesh to render
  103191. * @returns true if it should render otherwise false
  103192. */
  103193. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  103194. /**
  103195. * Returns true if the mesh can be rendered, otherwise false.
  103196. * @param mesh The mesh to render
  103197. * @param material The material used on the mesh
  103198. * @returns true if it can be rendered otherwise false
  103199. */
  103200. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103201. /**
  103202. * Returns true if the mesh should render, otherwise false.
  103203. * @param mesh The mesh to render
  103204. * @returns true if it should render otherwise false
  103205. */
  103206. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  103207. /**
  103208. * Renders the submesh passed in parameter to the generation map.
  103209. */
  103210. protected _renderSubMesh(subMesh: SubMesh): void;
  103211. /**
  103212. * Rebuild the required buffers.
  103213. * @hidden Internal use only.
  103214. */
  103215. _rebuild(): void;
  103216. /**
  103217. * Dispose only the render target textures and post process.
  103218. */
  103219. private _disposeTextureAndPostProcesses;
  103220. /**
  103221. * Dispose the highlight layer and free resources.
  103222. */
  103223. dispose(): void;
  103224. /**
  103225. * Gets the class name of the effect layer
  103226. * @returns the string with the class name of the effect layer
  103227. */
  103228. getClassName(): string;
  103229. /**
  103230. * Creates an effect layer from parsed effect layer data
  103231. * @param parsedEffectLayer defines effect layer data
  103232. * @param scene defines the current scene
  103233. * @param rootUrl defines the root URL containing the effect layer information
  103234. * @returns a parsed effect Layer
  103235. */
  103236. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  103237. }
  103238. }
  103239. declare module BABYLON {
  103240. interface AbstractScene {
  103241. /**
  103242. * The list of effect layers (highlights/glow) added to the scene
  103243. * @see http://doc.babylonjs.com/how_to/highlight_layer
  103244. * @see http://doc.babylonjs.com/how_to/glow_layer
  103245. */
  103246. effectLayers: Array<EffectLayer>;
  103247. /**
  103248. * Removes the given effect layer from this scene.
  103249. * @param toRemove defines the effect layer to remove
  103250. * @returns the index of the removed effect layer
  103251. */
  103252. removeEffectLayer(toRemove: EffectLayer): number;
  103253. /**
  103254. * Adds the given effect layer to this scene
  103255. * @param newEffectLayer defines the effect layer to add
  103256. */
  103257. addEffectLayer(newEffectLayer: EffectLayer): void;
  103258. }
  103259. /**
  103260. * Defines the layer scene component responsible to manage any effect layers
  103261. * in a given scene.
  103262. */
  103263. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  103264. /**
  103265. * The component name helpfull to identify the component in the list of scene components.
  103266. */
  103267. readonly name: string;
  103268. /**
  103269. * The scene the component belongs to.
  103270. */
  103271. scene: Scene;
  103272. private _engine;
  103273. private _renderEffects;
  103274. private _needStencil;
  103275. private _previousStencilState;
  103276. /**
  103277. * Creates a new instance of the component for the given scene
  103278. * @param scene Defines the scene to register the component in
  103279. */
  103280. constructor(scene: Scene);
  103281. /**
  103282. * Registers the component in a given scene
  103283. */
  103284. register(): void;
  103285. /**
  103286. * Rebuilds the elements related to this component in case of
  103287. * context lost for instance.
  103288. */
  103289. rebuild(): void;
  103290. /**
  103291. * Serializes the component data to the specified json object
  103292. * @param serializationObject The object to serialize to
  103293. */
  103294. serialize(serializationObject: any): void;
  103295. /**
  103296. * Adds all the element from the container to the scene
  103297. * @param container the container holding the elements
  103298. */
  103299. addFromContainer(container: AbstractScene): void;
  103300. /**
  103301. * Removes all the elements in the container from the scene
  103302. * @param container contains the elements to remove
  103303. */
  103304. removeFromContainer(container: AbstractScene): void;
  103305. /**
  103306. * Disposes the component and the associated ressources.
  103307. */
  103308. dispose(): void;
  103309. private _isReadyForMesh;
  103310. private _renderMainTexture;
  103311. private _setStencil;
  103312. private _setStencilBack;
  103313. private _draw;
  103314. private _drawCamera;
  103315. private _drawRenderingGroup;
  103316. }
  103317. }
  103318. declare module BABYLON {
  103319. /** @hidden */
  103320. export var glowMapMergePixelShader: {
  103321. name: string;
  103322. shader: string;
  103323. };
  103324. }
  103325. declare module BABYLON {
  103326. /** @hidden */
  103327. export var glowMapMergeVertexShader: {
  103328. name: string;
  103329. shader: string;
  103330. };
  103331. }
  103332. declare module BABYLON {
  103333. interface AbstractScene {
  103334. /**
  103335. * Return a the first highlight layer of the scene with a given name.
  103336. * @param name The name of the highlight layer to look for.
  103337. * @return The highlight layer if found otherwise null.
  103338. */
  103339. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  103340. }
  103341. /**
  103342. * Glow layer options. This helps customizing the behaviour
  103343. * of the glow layer.
  103344. */
  103345. export interface IGlowLayerOptions {
  103346. /**
  103347. * Multiplication factor apply to the canvas size to compute the render target size
  103348. * used to generated the glowing objects (the smaller the faster).
  103349. */
  103350. mainTextureRatio: number;
  103351. /**
  103352. * Enforces a fixed size texture to ensure resize independant blur.
  103353. */
  103354. mainTextureFixedSize?: number;
  103355. /**
  103356. * How big is the kernel of the blur texture.
  103357. */
  103358. blurKernelSize: number;
  103359. /**
  103360. * The camera attached to the layer.
  103361. */
  103362. camera: Nullable<Camera>;
  103363. /**
  103364. * Enable MSAA by chosing the number of samples.
  103365. */
  103366. mainTextureSamples?: number;
  103367. /**
  103368. * The rendering group to draw the layer in.
  103369. */
  103370. renderingGroupId: number;
  103371. }
  103372. /**
  103373. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103374. *
  103375. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103376. * glowy meshes to your scene.
  103377. *
  103378. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103379. */
  103380. export class GlowLayer extends EffectLayer {
  103381. /**
  103382. * Effect Name of the layer.
  103383. */
  103384. static readonly EffectName: string;
  103385. /**
  103386. * The default blur kernel size used for the glow.
  103387. */
  103388. static DefaultBlurKernelSize: number;
  103389. /**
  103390. * The default texture size ratio used for the glow.
  103391. */
  103392. static DefaultTextureRatio: number;
  103393. /**
  103394. * Sets the kernel size of the blur.
  103395. */
  103396. /**
  103397. * Gets the kernel size of the blur.
  103398. */
  103399. blurKernelSize: number;
  103400. /**
  103401. * Sets the glow intensity.
  103402. */
  103403. /**
  103404. * Gets the glow intensity.
  103405. */
  103406. intensity: number;
  103407. private _options;
  103408. private _intensity;
  103409. private _horizontalBlurPostprocess1;
  103410. private _verticalBlurPostprocess1;
  103411. private _horizontalBlurPostprocess2;
  103412. private _verticalBlurPostprocess2;
  103413. private _blurTexture1;
  103414. private _blurTexture2;
  103415. private _postProcesses1;
  103416. private _postProcesses2;
  103417. private _includedOnlyMeshes;
  103418. private _excludedMeshes;
  103419. /**
  103420. * Callback used to let the user override the color selection on a per mesh basis
  103421. */
  103422. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103423. /**
  103424. * Callback used to let the user override the texture selection on a per mesh basis
  103425. */
  103426. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103427. /**
  103428. * Instantiates a new glow Layer and references it to the scene.
  103429. * @param name The name of the layer
  103430. * @param scene The scene to use the layer in
  103431. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103432. */
  103433. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103434. /**
  103435. * Get the effect name of the layer.
  103436. * @return The effect name
  103437. */
  103438. getEffectName(): string;
  103439. /**
  103440. * Create the merge effect. This is the shader use to blit the information back
  103441. * to the main canvas at the end of the scene rendering.
  103442. */
  103443. protected _createMergeEffect(): Effect;
  103444. /**
  103445. * Creates the render target textures and post processes used in the glow layer.
  103446. */
  103447. protected _createTextureAndPostProcesses(): void;
  103448. /**
  103449. * Checks for the readiness of the element composing the layer.
  103450. * @param subMesh the mesh to check for
  103451. * @param useInstances specify wether or not to use instances to render the mesh
  103452. * @param emissiveTexture the associated emissive texture used to generate the glow
  103453. * @return true if ready otherwise, false
  103454. */
  103455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103456. /**
  103457. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103458. */
  103459. needStencil(): boolean;
  103460. /**
  103461. * Returns true if the mesh can be rendered, otherwise false.
  103462. * @param mesh The mesh to render
  103463. * @param material The material used on the mesh
  103464. * @returns true if it can be rendered otherwise false
  103465. */
  103466. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103467. /**
  103468. * Implementation specific of rendering the generating effect on the main canvas.
  103469. * @param effect The effect used to render through
  103470. */
  103471. protected _internalRender(effect: Effect): void;
  103472. /**
  103473. * Sets the required values for both the emissive texture and and the main color.
  103474. */
  103475. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103476. /**
  103477. * Returns true if the mesh should render, otherwise false.
  103478. * @param mesh The mesh to render
  103479. * @returns true if it should render otherwise false
  103480. */
  103481. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103482. /**
  103483. * Adds specific effects defines.
  103484. * @param defines The defines to add specifics to.
  103485. */
  103486. protected _addCustomEffectDefines(defines: string[]): void;
  103487. /**
  103488. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103489. * @param mesh The mesh to exclude from the glow layer
  103490. */
  103491. addExcludedMesh(mesh: Mesh): void;
  103492. /**
  103493. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103494. * @param mesh The mesh to remove
  103495. */
  103496. removeExcludedMesh(mesh: Mesh): void;
  103497. /**
  103498. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103499. * @param mesh The mesh to include in the glow layer
  103500. */
  103501. addIncludedOnlyMesh(mesh: Mesh): void;
  103502. /**
  103503. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103504. * @param mesh The mesh to remove
  103505. */
  103506. removeIncludedOnlyMesh(mesh: Mesh): void;
  103507. /**
  103508. * Determine if a given mesh will be used in the glow layer
  103509. * @param mesh The mesh to test
  103510. * @returns true if the mesh will be highlighted by the current glow layer
  103511. */
  103512. hasMesh(mesh: AbstractMesh): boolean;
  103513. /**
  103514. * Free any resources and references associated to a mesh.
  103515. * Internal use
  103516. * @param mesh The mesh to free.
  103517. * @hidden
  103518. */
  103519. _disposeMesh(mesh: Mesh): void;
  103520. /**
  103521. * Gets the class name of the effect layer
  103522. * @returns the string with the class name of the effect layer
  103523. */
  103524. getClassName(): string;
  103525. /**
  103526. * Serializes this glow layer
  103527. * @returns a serialized glow layer object
  103528. */
  103529. serialize(): any;
  103530. /**
  103531. * Creates a Glow Layer from parsed glow layer data
  103532. * @param parsedGlowLayer defines glow layer data
  103533. * @param scene defines the current scene
  103534. * @param rootUrl defines the root URL containing the glow layer information
  103535. * @returns a parsed Glow Layer
  103536. */
  103537. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103538. }
  103539. }
  103540. declare module BABYLON {
  103541. /** @hidden */
  103542. export var glowBlurPostProcessPixelShader: {
  103543. name: string;
  103544. shader: string;
  103545. };
  103546. }
  103547. declare module BABYLON {
  103548. interface AbstractScene {
  103549. /**
  103550. * Return a the first highlight layer of the scene with a given name.
  103551. * @param name The name of the highlight layer to look for.
  103552. * @return The highlight layer if found otherwise null.
  103553. */
  103554. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103555. }
  103556. /**
  103557. * Highlight layer options. This helps customizing the behaviour
  103558. * of the highlight layer.
  103559. */
  103560. export interface IHighlightLayerOptions {
  103561. /**
  103562. * Multiplication factor apply to the canvas size to compute the render target size
  103563. * used to generated the glowing objects (the smaller the faster).
  103564. */
  103565. mainTextureRatio: number;
  103566. /**
  103567. * Enforces a fixed size texture to ensure resize independant blur.
  103568. */
  103569. mainTextureFixedSize?: number;
  103570. /**
  103571. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103572. * of the picture to blur (the smaller the faster).
  103573. */
  103574. blurTextureSizeRatio: number;
  103575. /**
  103576. * How big in texel of the blur texture is the vertical blur.
  103577. */
  103578. blurVerticalSize: number;
  103579. /**
  103580. * How big in texel of the blur texture is the horizontal blur.
  103581. */
  103582. blurHorizontalSize: number;
  103583. /**
  103584. * Alpha blending mode used to apply the blur. Default is combine.
  103585. */
  103586. alphaBlendingMode: number;
  103587. /**
  103588. * The camera attached to the layer.
  103589. */
  103590. camera: Nullable<Camera>;
  103591. /**
  103592. * Should we display highlight as a solid stroke?
  103593. */
  103594. isStroke?: boolean;
  103595. /**
  103596. * The rendering group to draw the layer in.
  103597. */
  103598. renderingGroupId: number;
  103599. }
  103600. /**
  103601. * The highlight layer Helps adding a glow effect around a mesh.
  103602. *
  103603. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103604. * glowy meshes to your scene.
  103605. *
  103606. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103607. */
  103608. export class HighlightLayer extends EffectLayer {
  103609. name: string;
  103610. /**
  103611. * Effect Name of the highlight layer.
  103612. */
  103613. static readonly EffectName: string;
  103614. /**
  103615. * The neutral color used during the preparation of the glow effect.
  103616. * This is black by default as the blend operation is a blend operation.
  103617. */
  103618. static NeutralColor: Color4;
  103619. /**
  103620. * Stencil value used for glowing meshes.
  103621. */
  103622. static GlowingMeshStencilReference: number;
  103623. /**
  103624. * Stencil value used for the other meshes in the scene.
  103625. */
  103626. static NormalMeshStencilReference: number;
  103627. /**
  103628. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103629. */
  103630. innerGlow: boolean;
  103631. /**
  103632. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103633. */
  103634. outerGlow: boolean;
  103635. /**
  103636. * Specifies the horizontal size of the blur.
  103637. */
  103638. /**
  103639. * Gets the horizontal size of the blur.
  103640. */
  103641. blurHorizontalSize: number;
  103642. /**
  103643. * Specifies the vertical size of the blur.
  103644. */
  103645. /**
  103646. * Gets the vertical size of the blur.
  103647. */
  103648. blurVerticalSize: number;
  103649. /**
  103650. * An event triggered when the highlight layer is being blurred.
  103651. */
  103652. onBeforeBlurObservable: Observable<HighlightLayer>;
  103653. /**
  103654. * An event triggered when the highlight layer has been blurred.
  103655. */
  103656. onAfterBlurObservable: Observable<HighlightLayer>;
  103657. private _instanceGlowingMeshStencilReference;
  103658. private _options;
  103659. private _downSamplePostprocess;
  103660. private _horizontalBlurPostprocess;
  103661. private _verticalBlurPostprocess;
  103662. private _blurTexture;
  103663. private _meshes;
  103664. private _excludedMeshes;
  103665. /**
  103666. * Instantiates a new highlight Layer and references it to the scene..
  103667. * @param name The name of the layer
  103668. * @param scene The scene to use the layer in
  103669. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103670. */
  103671. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103672. /**
  103673. * Get the effect name of the layer.
  103674. * @return The effect name
  103675. */
  103676. getEffectName(): string;
  103677. /**
  103678. * Create the merge effect. This is the shader use to blit the information back
  103679. * to the main canvas at the end of the scene rendering.
  103680. */
  103681. protected _createMergeEffect(): Effect;
  103682. /**
  103683. * Creates the render target textures and post processes used in the highlight layer.
  103684. */
  103685. protected _createTextureAndPostProcesses(): void;
  103686. /**
  103687. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103688. */
  103689. needStencil(): boolean;
  103690. /**
  103691. * Checks for the readiness of the element composing the layer.
  103692. * @param subMesh the mesh to check for
  103693. * @param useInstances specify wether or not to use instances to render the mesh
  103694. * @param emissiveTexture the associated emissive texture used to generate the glow
  103695. * @return true if ready otherwise, false
  103696. */
  103697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103698. /**
  103699. * Implementation specific of rendering the generating effect on the main canvas.
  103700. * @param effect The effect used to render through
  103701. */
  103702. protected _internalRender(effect: Effect): void;
  103703. /**
  103704. * Returns true if the layer contains information to display, otherwise false.
  103705. */
  103706. shouldRender(): boolean;
  103707. /**
  103708. * Returns true if the mesh should render, otherwise false.
  103709. * @param mesh The mesh to render
  103710. * @returns true if it should render otherwise false
  103711. */
  103712. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103713. /**
  103714. * Sets the required values for both the emissive texture and and the main color.
  103715. */
  103716. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103717. /**
  103718. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103719. * @param mesh The mesh to exclude from the highlight layer
  103720. */
  103721. addExcludedMesh(mesh: Mesh): void;
  103722. /**
  103723. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103724. * @param mesh The mesh to highlight
  103725. */
  103726. removeExcludedMesh(mesh: Mesh): void;
  103727. /**
  103728. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103729. * @param mesh mesh to test
  103730. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103731. */
  103732. hasMesh(mesh: AbstractMesh): boolean;
  103733. /**
  103734. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103735. * @param mesh The mesh to highlight
  103736. * @param color The color of the highlight
  103737. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103738. */
  103739. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103740. /**
  103741. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103742. * @param mesh The mesh to highlight
  103743. */
  103744. removeMesh(mesh: Mesh): void;
  103745. /**
  103746. * Force the stencil to the normal expected value for none glowing parts
  103747. */
  103748. private _defaultStencilReference;
  103749. /**
  103750. * Free any resources and references associated to a mesh.
  103751. * Internal use
  103752. * @param mesh The mesh to free.
  103753. * @hidden
  103754. */
  103755. _disposeMesh(mesh: Mesh): void;
  103756. /**
  103757. * Dispose the highlight layer and free resources.
  103758. */
  103759. dispose(): void;
  103760. /**
  103761. * Gets the class name of the effect layer
  103762. * @returns the string with the class name of the effect layer
  103763. */
  103764. getClassName(): string;
  103765. /**
  103766. * Serializes this Highlight layer
  103767. * @returns a serialized Highlight layer object
  103768. */
  103769. serialize(): any;
  103770. /**
  103771. * Creates a Highlight layer from parsed Highlight layer data
  103772. * @param parsedHightlightLayer defines the Highlight layer data
  103773. * @param scene defines the current scene
  103774. * @param rootUrl defines the root URL containing the Highlight layer information
  103775. * @returns a parsed Highlight layer
  103776. */
  103777. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103778. }
  103779. }
  103780. declare module BABYLON {
  103781. /** @hidden */
  103782. export var lensFlarePixelShader: {
  103783. name: string;
  103784. shader: string;
  103785. };
  103786. }
  103787. declare module BABYLON {
  103788. /** @hidden */
  103789. export var lensFlareVertexShader: {
  103790. name: string;
  103791. shader: string;
  103792. };
  103793. }
  103794. declare module BABYLON {
  103795. /**
  103796. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103797. * It is usually composed of several `lensFlare`.
  103798. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103799. */
  103800. export class LensFlareSystem {
  103801. /**
  103802. * Define the name of the lens flare system
  103803. */
  103804. name: string;
  103805. /**
  103806. * List of lens flares used in this system.
  103807. */
  103808. lensFlares: LensFlare[];
  103809. /**
  103810. * Define a limit from the border the lens flare can be visible.
  103811. */
  103812. borderLimit: number;
  103813. /**
  103814. * Define a viewport border we do not want to see the lens flare in.
  103815. */
  103816. viewportBorder: number;
  103817. /**
  103818. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103819. */
  103820. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103821. /**
  103822. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103823. */
  103824. layerMask: number;
  103825. /**
  103826. * Define the id of the lens flare system in the scene.
  103827. * (equal to name by default)
  103828. */
  103829. id: string;
  103830. private _scene;
  103831. private _emitter;
  103832. private _vertexBuffers;
  103833. private _indexBuffer;
  103834. private _effect;
  103835. private _positionX;
  103836. private _positionY;
  103837. private _isEnabled;
  103838. /** @hidden */
  103839. static _SceneComponentInitialization: (scene: Scene) => void;
  103840. /**
  103841. * Instantiates a lens flare system.
  103842. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103843. * It is usually composed of several `lensFlare`.
  103844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103845. * @param name Define the name of the lens flare system in the scene
  103846. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103847. * @param scene Define the scene the lens flare system belongs to
  103848. */
  103849. constructor(
  103850. /**
  103851. * Define the name of the lens flare system
  103852. */
  103853. name: string, emitter: any, scene: Scene);
  103854. /**
  103855. * Define if the lens flare system is enabled.
  103856. */
  103857. isEnabled: boolean;
  103858. /**
  103859. * Get the scene the effects belongs to.
  103860. * @returns the scene holding the lens flare system
  103861. */
  103862. getScene(): Scene;
  103863. /**
  103864. * Get the emitter of the lens flare system.
  103865. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103866. * @returns the emitter of the lens flare system
  103867. */
  103868. getEmitter(): any;
  103869. /**
  103870. * Set the emitter of the lens flare system.
  103871. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103872. * @param newEmitter Define the new emitter of the system
  103873. */
  103874. setEmitter(newEmitter: any): void;
  103875. /**
  103876. * Get the lens flare system emitter position.
  103877. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103878. * @returns the position
  103879. */
  103880. getEmitterPosition(): Vector3;
  103881. /**
  103882. * @hidden
  103883. */
  103884. computeEffectivePosition(globalViewport: Viewport): boolean;
  103885. /** @hidden */
  103886. _isVisible(): boolean;
  103887. /**
  103888. * @hidden
  103889. */
  103890. render(): boolean;
  103891. /**
  103892. * Dispose and release the lens flare with its associated resources.
  103893. */
  103894. dispose(): void;
  103895. /**
  103896. * Parse a lens flare system from a JSON repressentation
  103897. * @param parsedLensFlareSystem Define the JSON to parse
  103898. * @param scene Define the scene the parsed system should be instantiated in
  103899. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103900. * @returns the parsed system
  103901. */
  103902. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103903. /**
  103904. * Serialize the current Lens Flare System into a JSON representation.
  103905. * @returns the serialized JSON
  103906. */
  103907. serialize(): any;
  103908. }
  103909. }
  103910. declare module BABYLON {
  103911. /**
  103912. * This represents one of the lens effect in a `lensFlareSystem`.
  103913. * It controls one of the indiviual texture used in the effect.
  103914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103915. */
  103916. export class LensFlare {
  103917. /**
  103918. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103919. */
  103920. size: number;
  103921. /**
  103922. * 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.
  103923. */
  103924. position: number;
  103925. /**
  103926. * Define the lens color.
  103927. */
  103928. color: Color3;
  103929. /**
  103930. * Define the lens texture.
  103931. */
  103932. texture: Nullable<Texture>;
  103933. /**
  103934. * Define the alpha mode to render this particular lens.
  103935. */
  103936. alphaMode: number;
  103937. private _system;
  103938. /**
  103939. * Creates a new Lens Flare.
  103940. * This represents one of the lens effect in a `lensFlareSystem`.
  103941. * It controls one of the indiviual texture used in the effect.
  103942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103943. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103944. * @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.
  103945. * @param color Define the lens color
  103946. * @param imgUrl Define the lens texture url
  103947. * @param system Define the `lensFlareSystem` this flare is part of
  103948. * @returns The newly created Lens Flare
  103949. */
  103950. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103951. /**
  103952. * Instantiates a new Lens Flare.
  103953. * This represents one of the lens effect in a `lensFlareSystem`.
  103954. * It controls one of the indiviual texture used in the effect.
  103955. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103956. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103957. * @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.
  103958. * @param color Define the lens color
  103959. * @param imgUrl Define the lens texture url
  103960. * @param system Define the `lensFlareSystem` this flare is part of
  103961. */
  103962. constructor(
  103963. /**
  103964. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103965. */
  103966. size: number,
  103967. /**
  103968. * 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.
  103969. */
  103970. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103971. /**
  103972. * Dispose and release the lens flare with its associated resources.
  103973. */
  103974. dispose(): void;
  103975. }
  103976. }
  103977. declare module BABYLON {
  103978. interface AbstractScene {
  103979. /**
  103980. * The list of lens flare system added to the scene
  103981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103982. */
  103983. lensFlareSystems: Array<LensFlareSystem>;
  103984. /**
  103985. * Removes the given lens flare system from this scene.
  103986. * @param toRemove The lens flare system to remove
  103987. * @returns The index of the removed lens flare system
  103988. */
  103989. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103990. /**
  103991. * Adds the given lens flare system to this scene
  103992. * @param newLensFlareSystem The lens flare system to add
  103993. */
  103994. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103995. /**
  103996. * Gets a lens flare system using its name
  103997. * @param name defines the name to look for
  103998. * @returns the lens flare system or null if not found
  103999. */
  104000. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104001. /**
  104002. * Gets a lens flare system using its id
  104003. * @param id defines the id to look for
  104004. * @returns the lens flare system or null if not found
  104005. */
  104006. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104007. }
  104008. /**
  104009. * Defines the lens flare scene component responsible to manage any lens flares
  104010. * in a given scene.
  104011. */
  104012. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  104013. /**
  104014. * The component name helpfull to identify the component in the list of scene components.
  104015. */
  104016. readonly name: string;
  104017. /**
  104018. * The scene the component belongs to.
  104019. */
  104020. scene: Scene;
  104021. /**
  104022. * Creates a new instance of the component for the given scene
  104023. * @param scene Defines the scene to register the component in
  104024. */
  104025. constructor(scene: Scene);
  104026. /**
  104027. * Registers the component in a given scene
  104028. */
  104029. register(): void;
  104030. /**
  104031. * Rebuilds the elements related to this component in case of
  104032. * context lost for instance.
  104033. */
  104034. rebuild(): void;
  104035. /**
  104036. * Adds all the element from the container to the scene
  104037. * @param container the container holding the elements
  104038. */
  104039. addFromContainer(container: AbstractScene): void;
  104040. /**
  104041. * Removes all the elements in the container from the scene
  104042. * @param container contains the elements to remove
  104043. */
  104044. removeFromContainer(container: AbstractScene): void;
  104045. /**
  104046. * Serializes the component data to the specified json object
  104047. * @param serializationObject The object to serialize to
  104048. */
  104049. serialize(serializationObject: any): void;
  104050. /**
  104051. * Disposes the component and the associated ressources.
  104052. */
  104053. dispose(): void;
  104054. private _draw;
  104055. }
  104056. }
  104057. declare module BABYLON {
  104058. /**
  104059. * Defines the shadow generator component responsible to manage any shadow generators
  104060. * in a given scene.
  104061. */
  104062. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  104063. /**
  104064. * The component name helpfull to identify the component in the list of scene components.
  104065. */
  104066. readonly name: string;
  104067. /**
  104068. * The scene the component belongs to.
  104069. */
  104070. scene: Scene;
  104071. /**
  104072. * Creates a new instance of the component for the given scene
  104073. * @param scene Defines the scene to register the component in
  104074. */
  104075. constructor(scene: Scene);
  104076. /**
  104077. * Registers the component in a given scene
  104078. */
  104079. register(): void;
  104080. /**
  104081. * Rebuilds the elements related to this component in case of
  104082. * context lost for instance.
  104083. */
  104084. rebuild(): void;
  104085. /**
  104086. * Serializes the component data to the specified json object
  104087. * @param serializationObject The object to serialize to
  104088. */
  104089. serialize(serializationObject: any): void;
  104090. /**
  104091. * Adds all the element from the container to the scene
  104092. * @param container the container holding the elements
  104093. */
  104094. addFromContainer(container: AbstractScene): void;
  104095. /**
  104096. * Removes all the elements in the container from the scene
  104097. * @param container contains the elements to remove
  104098. */
  104099. removeFromContainer(container: AbstractScene): void;
  104100. /**
  104101. * Rebuilds the elements related to this component in case of
  104102. * context lost for instance.
  104103. */
  104104. dispose(): void;
  104105. private _gatherRenderTargets;
  104106. }
  104107. }
  104108. declare module BABYLON {
  104109. /**
  104110. * A directional light is defined by a direction (what a surprise!).
  104111. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  104112. * 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.
  104113. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104114. */
  104115. export class DirectionalLight extends ShadowLight {
  104116. private _shadowFrustumSize;
  104117. /**
  104118. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  104119. */
  104120. /**
  104121. * Specifies a fix frustum size for the shadow generation.
  104122. */
  104123. shadowFrustumSize: number;
  104124. private _shadowOrthoScale;
  104125. /**
  104126. * Gets the shadow projection scale against the optimal computed one.
  104127. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104128. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104129. */
  104130. /**
  104131. * Sets the shadow projection scale against the optimal computed one.
  104132. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104133. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104134. */
  104135. shadowOrthoScale: number;
  104136. /**
  104137. * Automatically compute the projection matrix to best fit (including all the casters)
  104138. * on each frame.
  104139. */
  104140. autoUpdateExtends: boolean;
  104141. private _orthoLeft;
  104142. private _orthoRight;
  104143. private _orthoTop;
  104144. private _orthoBottom;
  104145. /**
  104146. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104147. * The directional light is emitted from everywhere in the given direction.
  104148. * It can cast shadows.
  104149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104150. * @param name The friendly name of the light
  104151. * @param direction The direction of the light
  104152. * @param scene The scene the light belongs to
  104153. */
  104154. constructor(name: string, direction: Vector3, scene: Scene);
  104155. /**
  104156. * Returns the string "DirectionalLight".
  104157. * @return The class name
  104158. */
  104159. getClassName(): string;
  104160. /**
  104161. * Returns the integer 1.
  104162. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104163. */
  104164. getTypeID(): number;
  104165. /**
  104166. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104167. * Returns the DirectionalLight Shadow projection matrix.
  104168. */
  104169. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104170. /**
  104171. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  104172. * Returns the DirectionalLight Shadow projection matrix.
  104173. */
  104174. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  104175. /**
  104176. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  104177. * Returns the DirectionalLight Shadow projection matrix.
  104178. */
  104179. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104180. protected _buildUniformLayout(): void;
  104181. /**
  104182. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  104183. * @param effect The effect to update
  104184. * @param lightIndex The index of the light in the effect to update
  104185. * @returns The directional light
  104186. */
  104187. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  104188. /**
  104189. * Gets the minZ used for shadow according to both the scene and the light.
  104190. *
  104191. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104192. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104193. * @param activeCamera The camera we are returning the min for
  104194. * @returns the depth min z
  104195. */
  104196. getDepthMinZ(activeCamera: Camera): number;
  104197. /**
  104198. * Gets the maxZ used for shadow according to both the scene and the light.
  104199. *
  104200. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104201. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104202. * @param activeCamera The camera we are returning the max for
  104203. * @returns the depth max z
  104204. */
  104205. getDepthMaxZ(activeCamera: Camera): number;
  104206. /**
  104207. * Prepares the list of defines specific to the light type.
  104208. * @param defines the list of defines
  104209. * @param lightIndex defines the index of the light for the effect
  104210. */
  104211. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104212. }
  104213. }
  104214. declare module BABYLON {
  104215. /**
  104216. * A point light is a light defined by an unique point in world space.
  104217. * The light is emitted in every direction from this point.
  104218. * A good example of a point light is a standard light bulb.
  104219. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104220. */
  104221. export class PointLight extends ShadowLight {
  104222. private _shadowAngle;
  104223. /**
  104224. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104225. * This specifies what angle the shadow will use to be created.
  104226. *
  104227. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104228. */
  104229. /**
  104230. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104231. * This specifies what angle the shadow will use to be created.
  104232. *
  104233. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104234. */
  104235. shadowAngle: number;
  104236. /**
  104237. * Gets the direction if it has been set.
  104238. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104239. */
  104240. /**
  104241. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104242. */
  104243. direction: Vector3;
  104244. /**
  104245. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  104246. * A PointLight emits the light in every direction.
  104247. * It can cast shadows.
  104248. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  104249. * ```javascript
  104250. * var pointLight = new PointLight("pl", camera.position, scene);
  104251. * ```
  104252. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104253. * @param name The light friendly name
  104254. * @param position The position of the point light in the scene
  104255. * @param scene The scene the lights belongs to
  104256. */
  104257. constructor(name: string, position: Vector3, scene: Scene);
  104258. /**
  104259. * Returns the string "PointLight"
  104260. * @returns the class name
  104261. */
  104262. getClassName(): string;
  104263. /**
  104264. * Returns the integer 0.
  104265. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104266. */
  104267. getTypeID(): number;
  104268. /**
  104269. * Specifies wether or not the shadowmap should be a cube texture.
  104270. * @returns true if the shadowmap needs to be a cube texture.
  104271. */
  104272. needCube(): boolean;
  104273. /**
  104274. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  104275. * @param faceIndex The index of the face we are computed the direction to generate shadow
  104276. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  104277. */
  104278. getShadowDirection(faceIndex?: number): Vector3;
  104279. /**
  104280. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  104281. * - fov = PI / 2
  104282. * - aspect ratio : 1.0
  104283. * - z-near and far equal to the active camera minZ and maxZ.
  104284. * Returns the PointLight.
  104285. */
  104286. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104287. protected _buildUniformLayout(): void;
  104288. /**
  104289. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  104290. * @param effect The effect to update
  104291. * @param lightIndex The index of the light in the effect to update
  104292. * @returns The point light
  104293. */
  104294. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  104295. /**
  104296. * Prepares the list of defines specific to the light type.
  104297. * @param defines the list of defines
  104298. * @param lightIndex defines the index of the light for the effect
  104299. */
  104300. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104301. }
  104302. }
  104303. declare module BABYLON {
  104304. /**
  104305. * A spot light is defined by a position, a direction, an angle, and an exponent.
  104306. * These values define a cone of light starting from the position, emitting toward the direction.
  104307. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  104308. * and the exponent defines the speed of the decay of the light with distance (reach).
  104309. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104310. */
  104311. export class SpotLight extends ShadowLight {
  104312. private _angle;
  104313. private _innerAngle;
  104314. private _cosHalfAngle;
  104315. private _lightAngleScale;
  104316. private _lightAngleOffset;
  104317. /**
  104318. * Gets the cone angle of the spot light in Radians.
  104319. */
  104320. /**
  104321. * Sets the cone angle of the spot light in Radians.
  104322. */
  104323. angle: number;
  104324. /**
  104325. * Only used in gltf falloff mode, this defines the angle where
  104326. * the directional falloff will start before cutting at angle which could be seen
  104327. * as outer angle.
  104328. */
  104329. /**
  104330. * Only used in gltf falloff mode, this defines the angle where
  104331. * the directional falloff will start before cutting at angle which could be seen
  104332. * as outer angle.
  104333. */
  104334. innerAngle: number;
  104335. private _shadowAngleScale;
  104336. /**
  104337. * Allows scaling the angle of the light for shadow generation only.
  104338. */
  104339. /**
  104340. * Allows scaling the angle of the light for shadow generation only.
  104341. */
  104342. shadowAngleScale: number;
  104343. /**
  104344. * The light decay speed with the distance from the emission spot.
  104345. */
  104346. exponent: number;
  104347. private _projectionTextureMatrix;
  104348. /**
  104349. * Allows reading the projecton texture
  104350. */
  104351. readonly projectionTextureMatrix: Matrix;
  104352. protected _projectionTextureLightNear: number;
  104353. /**
  104354. * Gets the near clip of the Spotlight for texture projection.
  104355. */
  104356. /**
  104357. * Sets the near clip of the Spotlight for texture projection.
  104358. */
  104359. projectionTextureLightNear: number;
  104360. protected _projectionTextureLightFar: number;
  104361. /**
  104362. * Gets the far clip of the Spotlight for texture projection.
  104363. */
  104364. /**
  104365. * Sets the far clip of the Spotlight for texture projection.
  104366. */
  104367. projectionTextureLightFar: number;
  104368. protected _projectionTextureUpDirection: Vector3;
  104369. /**
  104370. * Gets the Up vector of the Spotlight for texture projection.
  104371. */
  104372. /**
  104373. * Sets the Up vector of the Spotlight for texture projection.
  104374. */
  104375. projectionTextureUpDirection: Vector3;
  104376. private _projectionTexture;
  104377. /**
  104378. * Gets the projection texture of the light.
  104379. */
  104380. /**
  104381. * Sets the projection texture of the light.
  104382. */
  104383. projectionTexture: Nullable<BaseTexture>;
  104384. private _projectionTextureViewLightDirty;
  104385. private _projectionTextureProjectionLightDirty;
  104386. private _projectionTextureDirty;
  104387. private _projectionTextureViewTargetVector;
  104388. private _projectionTextureViewLightMatrix;
  104389. private _projectionTextureProjectionLightMatrix;
  104390. private _projectionTextureScalingMatrix;
  104391. /**
  104392. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104393. * It can cast shadows.
  104394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104395. * @param name The light friendly name
  104396. * @param position The position of the spot light in the scene
  104397. * @param direction The direction of the light in the scene
  104398. * @param angle The cone angle of the light in Radians
  104399. * @param exponent The light decay speed with the distance from the emission spot
  104400. * @param scene The scene the lights belongs to
  104401. */
  104402. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104403. /**
  104404. * Returns the string "SpotLight".
  104405. * @returns the class name
  104406. */
  104407. getClassName(): string;
  104408. /**
  104409. * Returns the integer 2.
  104410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104411. */
  104412. getTypeID(): number;
  104413. /**
  104414. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104415. */
  104416. protected _setDirection(value: Vector3): void;
  104417. /**
  104418. * Overrides the position setter to recompute the projection texture view light Matrix.
  104419. */
  104420. protected _setPosition(value: Vector3): void;
  104421. /**
  104422. * 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.
  104423. * Returns the SpotLight.
  104424. */
  104425. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104426. protected _computeProjectionTextureViewLightMatrix(): void;
  104427. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104428. /**
  104429. * Main function for light texture projection matrix computing.
  104430. */
  104431. protected _computeProjectionTextureMatrix(): void;
  104432. protected _buildUniformLayout(): void;
  104433. private _computeAngleValues;
  104434. /**
  104435. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104436. * @param effect The effect to update
  104437. * @param lightIndex The index of the light in the effect to update
  104438. * @returns The spot light
  104439. */
  104440. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104441. /**
  104442. * Disposes the light and the associated resources.
  104443. */
  104444. dispose(): void;
  104445. /**
  104446. * Prepares the list of defines specific to the light type.
  104447. * @param defines the list of defines
  104448. * @param lightIndex defines the index of the light for the effect
  104449. */
  104450. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104451. }
  104452. }
  104453. declare module BABYLON {
  104454. /**
  104455. * Header information of HDR texture files.
  104456. */
  104457. export interface HDRInfo {
  104458. /**
  104459. * The height of the texture in pixels.
  104460. */
  104461. height: number;
  104462. /**
  104463. * The width of the texture in pixels.
  104464. */
  104465. width: number;
  104466. /**
  104467. * The index of the beginning of the data in the binary file.
  104468. */
  104469. dataPosition: number;
  104470. }
  104471. /**
  104472. * This groups tools to convert HDR texture to native colors array.
  104473. */
  104474. export class HDRTools {
  104475. private static Ldexp;
  104476. private static Rgbe2float;
  104477. private static readStringLine;
  104478. /**
  104479. * Reads header information from an RGBE texture stored in a native array.
  104480. * More information on this format are available here:
  104481. * https://en.wikipedia.org/wiki/RGBE_image_format
  104482. *
  104483. * @param uint8array The binary file stored in native array.
  104484. * @return The header information.
  104485. */
  104486. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104487. /**
  104488. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104489. * This RGBE texture needs to store the information as a panorama.
  104490. *
  104491. * More information on this format are available here:
  104492. * https://en.wikipedia.org/wiki/RGBE_image_format
  104493. *
  104494. * @param buffer The binary file stored in an array buffer.
  104495. * @param size The expected size of the extracted cubemap.
  104496. * @return The Cube Map information.
  104497. */
  104498. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104499. /**
  104500. * Returns the pixels data extracted from an RGBE texture.
  104501. * This pixels will be stored left to right up to down in the R G B order in one array.
  104502. *
  104503. * More information on this format are available here:
  104504. * https://en.wikipedia.org/wiki/RGBE_image_format
  104505. *
  104506. * @param uint8array The binary file stored in an array buffer.
  104507. * @param hdrInfo The header information of the file.
  104508. * @return The pixels data in RGB right to left up to down order.
  104509. */
  104510. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104511. private static RGBE_ReadPixels_RLE;
  104512. }
  104513. }
  104514. declare module BABYLON {
  104515. /**
  104516. * This represents a texture coming from an HDR input.
  104517. *
  104518. * The only supported format is currently panorama picture stored in RGBE format.
  104519. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104520. */
  104521. export class HDRCubeTexture extends BaseTexture {
  104522. private static _facesMapping;
  104523. private _generateHarmonics;
  104524. private _noMipmap;
  104525. private _textureMatrix;
  104526. private _size;
  104527. private _onLoad;
  104528. private _onError;
  104529. /**
  104530. * The texture URL.
  104531. */
  104532. url: string;
  104533. /**
  104534. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104535. */
  104536. coordinatesMode: number;
  104537. protected _isBlocking: boolean;
  104538. /**
  104539. * Sets wether or not the texture is blocking during loading.
  104540. */
  104541. /**
  104542. * Gets wether or not the texture is blocking during loading.
  104543. */
  104544. isBlocking: boolean;
  104545. protected _rotationY: number;
  104546. /**
  104547. * Sets texture matrix rotation angle around Y axis in radians.
  104548. */
  104549. /**
  104550. * Gets texture matrix rotation angle around Y axis radians.
  104551. */
  104552. rotationY: number;
  104553. /**
  104554. * Gets or sets the center of the bounding box associated with the cube texture
  104555. * It must define where the camera used to render the texture was set
  104556. */
  104557. boundingBoxPosition: Vector3;
  104558. private _boundingBoxSize;
  104559. /**
  104560. * Gets or sets the size of the bounding box associated with the cube texture
  104561. * When defined, the cubemap will switch to local mode
  104562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104563. * @example https://www.babylonjs-playground.com/#RNASML
  104564. */
  104565. boundingBoxSize: Vector3;
  104566. /**
  104567. * Instantiates an HDRTexture from the following parameters.
  104568. *
  104569. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104570. * @param scene The scene the texture will be used in
  104571. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104572. * @param noMipmap Forces to not generate the mipmap if true
  104573. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104574. * @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)
  104575. * @param reserved Reserved flag for internal use.
  104576. */
  104577. 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>);
  104578. /**
  104579. * Get the current class name of the texture useful for serialization or dynamic coding.
  104580. * @returns "HDRCubeTexture"
  104581. */
  104582. getClassName(): string;
  104583. /**
  104584. * Occurs when the file is raw .hdr file.
  104585. */
  104586. private loadTexture;
  104587. clone(): HDRCubeTexture;
  104588. delayLoad(): void;
  104589. /**
  104590. * Get the texture reflection matrix used to rotate/transform the reflection.
  104591. * @returns the reflection matrix
  104592. */
  104593. getReflectionTextureMatrix(): Matrix;
  104594. /**
  104595. * Set the texture reflection matrix used to rotate/transform the reflection.
  104596. * @param value Define the reflection matrix to set
  104597. */
  104598. setReflectionTextureMatrix(value: Matrix): void;
  104599. /**
  104600. * Parses a JSON representation of an HDR Texture in order to create the texture
  104601. * @param parsedTexture Define the JSON representation
  104602. * @param scene Define the scene the texture should be created in
  104603. * @param rootUrl Define the root url in case we need to load relative dependencies
  104604. * @returns the newly created texture after parsing
  104605. */
  104606. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104607. serialize(): any;
  104608. }
  104609. }
  104610. declare module BABYLON {
  104611. /**
  104612. * Class used to control physics engine
  104613. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104614. */
  104615. export class PhysicsEngine implements IPhysicsEngine {
  104616. private _physicsPlugin;
  104617. /**
  104618. * Global value used to control the smallest number supported by the simulation
  104619. */
  104620. static Epsilon: number;
  104621. private _impostors;
  104622. private _joints;
  104623. /**
  104624. * Gets the gravity vector used by the simulation
  104625. */
  104626. gravity: Vector3;
  104627. /**
  104628. * Factory used to create the default physics plugin.
  104629. * @returns The default physics plugin
  104630. */
  104631. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104632. /**
  104633. * Creates a new Physics Engine
  104634. * @param gravity defines the gravity vector used by the simulation
  104635. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104636. */
  104637. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104638. /**
  104639. * Sets the gravity vector used by the simulation
  104640. * @param gravity defines the gravity vector to use
  104641. */
  104642. setGravity(gravity: Vector3): void;
  104643. /**
  104644. * Set the time step of the physics engine.
  104645. * Default is 1/60.
  104646. * To slow it down, enter 1/600 for example.
  104647. * To speed it up, 1/30
  104648. * @param newTimeStep defines the new timestep to apply to this world.
  104649. */
  104650. setTimeStep(newTimeStep?: number): void;
  104651. /**
  104652. * Get the time step of the physics engine.
  104653. * @returns the current time step
  104654. */
  104655. getTimeStep(): number;
  104656. /**
  104657. * Release all resources
  104658. */
  104659. dispose(): void;
  104660. /**
  104661. * Gets the name of the current physics plugin
  104662. * @returns the name of the plugin
  104663. */
  104664. getPhysicsPluginName(): string;
  104665. /**
  104666. * Adding a new impostor for the impostor tracking.
  104667. * This will be done by the impostor itself.
  104668. * @param impostor the impostor to add
  104669. */
  104670. addImpostor(impostor: PhysicsImpostor): void;
  104671. /**
  104672. * Remove an impostor from the engine.
  104673. * This impostor and its mesh will not longer be updated by the physics engine.
  104674. * @param impostor the impostor to remove
  104675. */
  104676. removeImpostor(impostor: PhysicsImpostor): void;
  104677. /**
  104678. * Add a joint to the physics engine
  104679. * @param mainImpostor defines the main impostor to which the joint is added.
  104680. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104681. * @param joint defines the joint that will connect both impostors.
  104682. */
  104683. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104684. /**
  104685. * Removes a joint from the simulation
  104686. * @param mainImpostor defines the impostor used with the joint
  104687. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104688. * @param joint defines the joint to remove
  104689. */
  104690. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104691. /**
  104692. * Called by the scene. No need to call it.
  104693. * @param delta defines the timespam between frames
  104694. */
  104695. _step(delta: number): void;
  104696. /**
  104697. * Gets the current plugin used to run the simulation
  104698. * @returns current plugin
  104699. */
  104700. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104701. /**
  104702. * Gets the list of physic impostors
  104703. * @returns an array of PhysicsImpostor
  104704. */
  104705. getImpostors(): Array<PhysicsImpostor>;
  104706. /**
  104707. * Gets the impostor for a physics enabled object
  104708. * @param object defines the object impersonated by the impostor
  104709. * @returns the PhysicsImpostor or null if not found
  104710. */
  104711. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104712. /**
  104713. * Gets the impostor for a physics body object
  104714. * @param body defines physics body used by the impostor
  104715. * @returns the PhysicsImpostor or null if not found
  104716. */
  104717. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104718. }
  104719. }
  104720. declare module BABYLON {
  104721. /** @hidden */
  104722. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104723. private _useDeltaForWorldStep;
  104724. world: any;
  104725. name: string;
  104726. private _physicsMaterials;
  104727. private _fixedTimeStep;
  104728. BJSCANNON: any;
  104729. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104730. setGravity(gravity: Vector3): void;
  104731. setTimeStep(timeStep: number): void;
  104732. getTimeStep(): number;
  104733. executeStep(delta: number): void;
  104734. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104735. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104737. private _processChildMeshes;
  104738. removePhysicsBody(impostor: PhysicsImpostor): void;
  104739. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104740. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104741. private _addMaterial;
  104742. private _checkWithEpsilon;
  104743. private _createShape;
  104744. private _createHeightmap;
  104745. private _minus90X;
  104746. private _plus90X;
  104747. private _tmpPosition;
  104748. private _tmpDeltaPosition;
  104749. private _tmpUnityRotation;
  104750. private _updatePhysicsBodyTransformation;
  104751. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104752. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104753. isSupported(): boolean;
  104754. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104755. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104756. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104758. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104759. getBodyMass(impostor: PhysicsImpostor): number;
  104760. getBodyFriction(impostor: PhysicsImpostor): number;
  104761. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104762. getBodyRestitution(impostor: PhysicsImpostor): number;
  104763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104764. sleepBody(impostor: PhysicsImpostor): void;
  104765. wakeUpBody(impostor: PhysicsImpostor): void;
  104766. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104767. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104768. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104769. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104770. getRadius(impostor: PhysicsImpostor): number;
  104771. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104772. dispose(): void;
  104773. private _extendNamespace;
  104774. }
  104775. }
  104776. declare module BABYLON {
  104777. /** @hidden */
  104778. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104779. world: any;
  104780. name: string;
  104781. BJSOIMO: any;
  104782. constructor(iterations?: number, oimoInjection?: any);
  104783. setGravity(gravity: Vector3): void;
  104784. setTimeStep(timeStep: number): void;
  104785. getTimeStep(): number;
  104786. private _tmpImpostorsArray;
  104787. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104788. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104789. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104790. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104791. private _tmpPositionVector;
  104792. removePhysicsBody(impostor: PhysicsImpostor): void;
  104793. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104794. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104795. isSupported(): boolean;
  104796. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104797. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104798. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104800. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104801. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104802. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104803. getBodyMass(impostor: PhysicsImpostor): number;
  104804. getBodyFriction(impostor: PhysicsImpostor): number;
  104805. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104806. getBodyRestitution(impostor: PhysicsImpostor): number;
  104807. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104808. sleepBody(impostor: PhysicsImpostor): void;
  104809. wakeUpBody(impostor: PhysicsImpostor): void;
  104810. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104811. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104812. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104813. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104814. getRadius(impostor: PhysicsImpostor): number;
  104815. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104816. dispose(): void;
  104817. }
  104818. }
  104819. declare module BABYLON {
  104820. interface AbstractScene {
  104821. /**
  104822. * The list of reflection probes added to the scene
  104823. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104824. */
  104825. reflectionProbes: Array<ReflectionProbe>;
  104826. /**
  104827. * Removes the given reflection probe from this scene.
  104828. * @param toRemove The reflection probe to remove
  104829. * @returns The index of the removed reflection probe
  104830. */
  104831. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104832. /**
  104833. * Adds the given reflection probe to this scene.
  104834. * @param newReflectionProbe The reflection probe to add
  104835. */
  104836. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104837. }
  104838. /**
  104839. * Class used to generate realtime reflection / refraction cube textures
  104840. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104841. */
  104842. export class ReflectionProbe {
  104843. /** defines the name of the probe */
  104844. name: string;
  104845. private _scene;
  104846. private _renderTargetTexture;
  104847. private _projectionMatrix;
  104848. private _viewMatrix;
  104849. private _target;
  104850. private _add;
  104851. private _attachedMesh;
  104852. private _invertYAxis;
  104853. /** Gets or sets probe position (center of the cube map) */
  104854. position: Vector3;
  104855. /**
  104856. * Creates a new reflection probe
  104857. * @param name defines the name of the probe
  104858. * @param size defines the texture resolution (for each face)
  104859. * @param scene defines the hosting scene
  104860. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104861. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104862. */
  104863. constructor(
  104864. /** defines the name of the probe */
  104865. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104866. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104867. samples: number;
  104868. /** Gets or sets the refresh rate to use (on every frame by default) */
  104869. refreshRate: number;
  104870. /**
  104871. * Gets the hosting scene
  104872. * @returns a Scene
  104873. */
  104874. getScene(): Scene;
  104875. /** Gets the internal CubeTexture used to render to */
  104876. readonly cubeTexture: RenderTargetTexture;
  104877. /** Gets the list of meshes to render */
  104878. readonly renderList: Nullable<AbstractMesh[]>;
  104879. /**
  104880. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104881. * @param mesh defines the mesh to attach to
  104882. */
  104883. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104884. /**
  104885. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104886. * @param renderingGroupId The rendering group id corresponding to its index
  104887. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104888. */
  104889. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104890. /**
  104891. * Clean all associated resources
  104892. */
  104893. dispose(): void;
  104894. /**
  104895. * Converts the reflection probe information to a readable string for debug purpose.
  104896. * @param fullDetails Supports for multiple levels of logging within scene loading
  104897. * @returns the human readable reflection probe info
  104898. */
  104899. toString(fullDetails?: boolean): string;
  104900. /**
  104901. * Get the class name of the relfection probe.
  104902. * @returns "ReflectionProbe"
  104903. */
  104904. getClassName(): string;
  104905. /**
  104906. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104907. * @returns The JSON representation of the texture
  104908. */
  104909. serialize(): any;
  104910. /**
  104911. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104912. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104913. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104914. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104915. * @returns The parsed reflection probe if successful
  104916. */
  104917. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104918. }
  104919. }
  104920. declare module BABYLON {
  104921. /** @hidden */
  104922. export var _BabylonLoaderRegistered: boolean;
  104923. }
  104924. declare module BABYLON {
  104925. /**
  104926. * The Physically based simple base material of BJS.
  104927. *
  104928. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104929. * It is used as the base class for both the specGloss and metalRough conventions.
  104930. */
  104931. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104932. /**
  104933. * Number of Simultaneous lights allowed on the material.
  104934. */
  104935. maxSimultaneousLights: number;
  104936. /**
  104937. * If sets to true, disables all the lights affecting the material.
  104938. */
  104939. disableLighting: boolean;
  104940. /**
  104941. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104942. */
  104943. environmentTexture: BaseTexture;
  104944. /**
  104945. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104946. */
  104947. invertNormalMapX: boolean;
  104948. /**
  104949. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104950. */
  104951. invertNormalMapY: boolean;
  104952. /**
  104953. * Normal map used in the model.
  104954. */
  104955. normalTexture: BaseTexture;
  104956. /**
  104957. * Emissivie color used to self-illuminate the model.
  104958. */
  104959. emissiveColor: Color3;
  104960. /**
  104961. * Emissivie texture used to self-illuminate the model.
  104962. */
  104963. emissiveTexture: BaseTexture;
  104964. /**
  104965. * Occlusion Channel Strenght.
  104966. */
  104967. occlusionStrength: number;
  104968. /**
  104969. * Occlusion Texture of the material (adding extra occlusion effects).
  104970. */
  104971. occlusionTexture: BaseTexture;
  104972. /**
  104973. * Defines the alpha limits in alpha test mode.
  104974. */
  104975. alphaCutOff: number;
  104976. /**
  104977. * Gets the current double sided mode.
  104978. */
  104979. /**
  104980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104981. */
  104982. doubleSided: boolean;
  104983. /**
  104984. * Stores the pre-calculated light information of a mesh in a texture.
  104985. */
  104986. lightmapTexture: BaseTexture;
  104987. /**
  104988. * If true, the light map contains occlusion information instead of lighting info.
  104989. */
  104990. useLightmapAsShadowmap: boolean;
  104991. /**
  104992. * Instantiates a new PBRMaterial instance.
  104993. *
  104994. * @param name The material name
  104995. * @param scene The scene the material will be use in.
  104996. */
  104997. constructor(name: string, scene: Scene);
  104998. getClassName(): string;
  104999. }
  105000. }
  105001. declare module BABYLON {
  105002. /**
  105003. * The PBR material of BJS following the metal roughness convention.
  105004. *
  105005. * This fits to the PBR convention in the GLTF definition:
  105006. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  105007. */
  105008. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  105009. /**
  105010. * The base color has two different interpretations depending on the value of metalness.
  105011. * When the material is a metal, the base color is the specific measured reflectance value
  105012. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  105013. * of the material.
  105014. */
  105015. baseColor: Color3;
  105016. /**
  105017. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  105018. * well as opacity information in the alpha channel.
  105019. */
  105020. baseTexture: BaseTexture;
  105021. /**
  105022. * Specifies the metallic scalar value of the material.
  105023. * Can also be used to scale the metalness values of the metallic texture.
  105024. */
  105025. metallic: number;
  105026. /**
  105027. * Specifies the roughness scalar value of the material.
  105028. * Can also be used to scale the roughness values of the metallic texture.
  105029. */
  105030. roughness: number;
  105031. /**
  105032. * Texture containing both the metallic value in the B channel and the
  105033. * roughness value in the G channel to keep better precision.
  105034. */
  105035. metallicRoughnessTexture: BaseTexture;
  105036. /**
  105037. * Instantiates a new PBRMetalRoughnessMaterial instance.
  105038. *
  105039. * @param name The material name
  105040. * @param scene The scene the material will be use in.
  105041. */
  105042. constructor(name: string, scene: Scene);
  105043. /**
  105044. * Return the currrent class name of the material.
  105045. */
  105046. getClassName(): string;
  105047. /**
  105048. * Makes a duplicate of the current material.
  105049. * @param name - name to use for the new material.
  105050. */
  105051. clone(name: string): PBRMetallicRoughnessMaterial;
  105052. /**
  105053. * Serialize the material to a parsable JSON object.
  105054. */
  105055. serialize(): any;
  105056. /**
  105057. * Parses a JSON object correponding to the serialize function.
  105058. */
  105059. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  105060. }
  105061. }
  105062. declare module BABYLON {
  105063. /**
  105064. * The PBR material of BJS following the specular glossiness convention.
  105065. *
  105066. * This fits to the PBR convention in the GLTF definition:
  105067. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  105068. */
  105069. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  105070. /**
  105071. * Specifies the diffuse color of the material.
  105072. */
  105073. diffuseColor: Color3;
  105074. /**
  105075. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  105076. * channel.
  105077. */
  105078. diffuseTexture: BaseTexture;
  105079. /**
  105080. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  105081. */
  105082. specularColor: Color3;
  105083. /**
  105084. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  105085. */
  105086. glossiness: number;
  105087. /**
  105088. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  105089. */
  105090. specularGlossinessTexture: BaseTexture;
  105091. /**
  105092. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  105093. *
  105094. * @param name The material name
  105095. * @param scene The scene the material will be use in.
  105096. */
  105097. constructor(name: string, scene: Scene);
  105098. /**
  105099. * Return the currrent class name of the material.
  105100. */
  105101. getClassName(): string;
  105102. /**
  105103. * Makes a duplicate of the current material.
  105104. * @param name - name to use for the new material.
  105105. */
  105106. clone(name: string): PBRSpecularGlossinessMaterial;
  105107. /**
  105108. * Serialize the material to a parsable JSON object.
  105109. */
  105110. serialize(): any;
  105111. /**
  105112. * Parses a JSON object correponding to the serialize function.
  105113. */
  105114. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  105115. }
  105116. }
  105117. declare module BABYLON {
  105118. /**
  105119. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  105120. * It can help converting any input color in a desired output one. This can then be used to create effects
  105121. * from sepia, black and white to sixties or futuristic rendering...
  105122. *
  105123. * The only supported format is currently 3dl.
  105124. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  105125. */
  105126. export class ColorGradingTexture extends BaseTexture {
  105127. /**
  105128. * The current texture matrix. (will always be identity in color grading texture)
  105129. */
  105130. private _textureMatrix;
  105131. /**
  105132. * The texture URL.
  105133. */
  105134. url: string;
  105135. /**
  105136. * Empty line regex stored for GC.
  105137. */
  105138. private static _noneEmptyLineRegex;
  105139. private _engine;
  105140. /**
  105141. * Instantiates a ColorGradingTexture from the following parameters.
  105142. *
  105143. * @param url The location of the color gradind data (currently only supporting 3dl)
  105144. * @param scene The scene the texture will be used in
  105145. */
  105146. constructor(url: string, scene: Scene);
  105147. /**
  105148. * Returns the texture matrix used in most of the material.
  105149. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  105150. */
  105151. getTextureMatrix(): Matrix;
  105152. /**
  105153. * Occurs when the file being loaded is a .3dl LUT file.
  105154. */
  105155. private load3dlTexture;
  105156. /**
  105157. * Starts the loading process of the texture.
  105158. */
  105159. private loadTexture;
  105160. /**
  105161. * Clones the color gradind texture.
  105162. */
  105163. clone(): ColorGradingTexture;
  105164. /**
  105165. * Called during delayed load for textures.
  105166. */
  105167. delayLoad(): void;
  105168. /**
  105169. * Parses a color grading texture serialized by Babylon.
  105170. * @param parsedTexture The texture information being parsedTexture
  105171. * @param scene The scene to load the texture in
  105172. * @param rootUrl The root url of the data assets to load
  105173. * @return A color gradind texture
  105174. */
  105175. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  105176. /**
  105177. * Serializes the LUT texture to json format.
  105178. */
  105179. serialize(): any;
  105180. }
  105181. }
  105182. declare module BABYLON {
  105183. /**
  105184. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  105185. */
  105186. export class EquiRectangularCubeTexture extends BaseTexture {
  105187. /** The six faces of the cube. */
  105188. private static _FacesMapping;
  105189. private _noMipmap;
  105190. private _onLoad;
  105191. private _onError;
  105192. /** The size of the cubemap. */
  105193. private _size;
  105194. /** The buffer of the image. */
  105195. private _buffer;
  105196. /** The width of the input image. */
  105197. private _width;
  105198. /** The height of the input image. */
  105199. private _height;
  105200. /** The URL to the image. */
  105201. url: string;
  105202. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  105203. coordinatesMode: number;
  105204. /**
  105205. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  105206. * @param url The location of the image
  105207. * @param scene The scene the texture will be used in
  105208. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105209. * @param noMipmap Forces to not generate the mipmap if true
  105210. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  105211. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  105212. * @param onLoad — defines a callback called when texture is loaded
  105213. * @param onError — defines a callback called if there is an error
  105214. */
  105215. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  105216. /**
  105217. * Load the image data, by putting the image on a canvas and extracting its buffer.
  105218. */
  105219. private loadImage;
  105220. /**
  105221. * Convert the image buffer into a cubemap and create a CubeTexture.
  105222. */
  105223. private loadTexture;
  105224. /**
  105225. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  105226. * @param buffer The ArrayBuffer that should be converted.
  105227. * @returns The buffer as Float32Array.
  105228. */
  105229. private getFloat32ArrayFromArrayBuffer;
  105230. /**
  105231. * Get the current class name of the texture useful for serialization or dynamic coding.
  105232. * @returns "EquiRectangularCubeTexture"
  105233. */
  105234. getClassName(): string;
  105235. /**
  105236. * Create a clone of the current EquiRectangularCubeTexture and return it.
  105237. * @returns A clone of the current EquiRectangularCubeTexture.
  105238. */
  105239. clone(): EquiRectangularCubeTexture;
  105240. }
  105241. }
  105242. declare module BABYLON {
  105243. /**
  105244. * Based on jsTGALoader - Javascript loader for TGA file
  105245. * By Vincent Thibault
  105246. * @see http://blog.robrowser.com/javascript-tga-loader.html
  105247. */
  105248. export class TGATools {
  105249. private static _TYPE_INDEXED;
  105250. private static _TYPE_RGB;
  105251. private static _TYPE_GREY;
  105252. private static _TYPE_RLE_INDEXED;
  105253. private static _TYPE_RLE_RGB;
  105254. private static _TYPE_RLE_GREY;
  105255. private static _ORIGIN_MASK;
  105256. private static _ORIGIN_SHIFT;
  105257. private static _ORIGIN_BL;
  105258. private static _ORIGIN_BR;
  105259. private static _ORIGIN_UL;
  105260. private static _ORIGIN_UR;
  105261. /**
  105262. * Gets the header of a TGA file
  105263. * @param data defines the TGA data
  105264. * @returns the header
  105265. */
  105266. static GetTGAHeader(data: Uint8Array): any;
  105267. /**
  105268. * Uploads TGA content to a Babylon Texture
  105269. * @hidden
  105270. */
  105271. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  105272. /** @hidden */
  105273. 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;
  105274. /** @hidden */
  105275. 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;
  105276. /** @hidden */
  105277. 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;
  105278. /** @hidden */
  105279. 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;
  105280. /** @hidden */
  105281. 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;
  105282. /** @hidden */
  105283. 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;
  105284. }
  105285. }
  105286. declare module BABYLON {
  105287. /**
  105288. * Implementation of the TGA Texture Loader.
  105289. * @hidden
  105290. */
  105291. export class _TGATextureLoader implements IInternalTextureLoader {
  105292. /**
  105293. * Defines wether the loader supports cascade loading the different faces.
  105294. */
  105295. readonly supportCascades: boolean;
  105296. /**
  105297. * This returns if the loader support the current file information.
  105298. * @param extension defines the file extension of the file being loaded
  105299. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105300. * @param fallback defines the fallback internal texture if any
  105301. * @param isBase64 defines whether the texture is encoded as a base64
  105302. * @param isBuffer defines whether the texture data are stored as a buffer
  105303. * @returns true if the loader can load the specified file
  105304. */
  105305. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105306. /**
  105307. * Transform the url before loading if required.
  105308. * @param rootUrl the url of the texture
  105309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105310. * @returns the transformed texture
  105311. */
  105312. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105313. /**
  105314. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105315. * @param rootUrl the url of the texture
  105316. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105317. * @returns the fallback texture
  105318. */
  105319. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105320. /**
  105321. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105322. * @param data contains the texture data
  105323. * @param texture defines the BabylonJS internal texture
  105324. * @param createPolynomials will be true if polynomials have been requested
  105325. * @param onLoad defines the callback to trigger once the texture is ready
  105326. * @param onError defines the callback to trigger in case of error
  105327. */
  105328. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105329. /**
  105330. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105331. * @param data contains the texture data
  105332. * @param texture defines the BabylonJS internal texture
  105333. * @param callback defines the method to call once ready to upload
  105334. */
  105335. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105336. }
  105337. }
  105338. declare module BABYLON {
  105339. /**
  105340. * 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.
  105341. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105342. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105343. */
  105344. export class CustomProceduralTexture extends ProceduralTexture {
  105345. private _animate;
  105346. private _time;
  105347. private _config;
  105348. private _texturePath;
  105349. /**
  105350. * Instantiates a new Custom Procedural Texture.
  105351. * 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.
  105352. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105353. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105354. * @param name Define the name of the texture
  105355. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  105356. * @param size Define the size of the texture to create
  105357. * @param scene Define the scene the texture belongs to
  105358. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  105359. * @param generateMipMaps Define if the texture should creates mip maps or not
  105360. */
  105361. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105362. private _loadJson;
  105363. /**
  105364. * Is the texture ready to be used ? (rendered at least once)
  105365. * @returns true if ready, otherwise, false.
  105366. */
  105367. isReady(): boolean;
  105368. /**
  105369. * Render the texture to its associated render target.
  105370. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  105371. */
  105372. render(useCameraPostProcess?: boolean): void;
  105373. /**
  105374. * Update the list of dependant textures samplers in the shader.
  105375. */
  105376. updateTextures(): void;
  105377. /**
  105378. * Update the uniform values of the procedural texture in the shader.
  105379. */
  105380. updateShaderUniforms(): void;
  105381. /**
  105382. * Define if the texture animates or not.
  105383. */
  105384. animate: boolean;
  105385. }
  105386. }
  105387. declare module BABYLON {
  105388. /** @hidden */
  105389. export var noisePixelShader: {
  105390. name: string;
  105391. shader: string;
  105392. };
  105393. }
  105394. declare module BABYLON {
  105395. /**
  105396. * Class used to generate noise procedural textures
  105397. */
  105398. export class NoiseProceduralTexture extends ProceduralTexture {
  105399. private _time;
  105400. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  105401. brightness: number;
  105402. /** Defines the number of octaves to process */
  105403. octaves: number;
  105404. /** Defines the level of persistence (0.8 by default) */
  105405. persistence: number;
  105406. /** Gets or sets animation speed factor (default is 1) */
  105407. animationSpeedFactor: number;
  105408. /**
  105409. * Creates a new NoiseProceduralTexture
  105410. * @param name defines the name fo the texture
  105411. * @param size defines the size of the texture (default is 256)
  105412. * @param scene defines the hosting scene
  105413. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  105414. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  105415. */
  105416. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105417. private _updateShaderUniforms;
  105418. protected _getDefines(): string;
  105419. /** Generate the current state of the procedural texture */
  105420. render(useCameraPostProcess?: boolean): void;
  105421. /**
  105422. * Serializes this noise procedural texture
  105423. * @returns a serialized noise procedural texture object
  105424. */
  105425. serialize(): any;
  105426. /**
  105427. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105428. * @param parsedTexture defines parsed texture data
  105429. * @param scene defines the current scene
  105430. * @param rootUrl defines the root URL containing noise procedural texture information
  105431. * @returns a parsed NoiseProceduralTexture
  105432. */
  105433. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105434. }
  105435. }
  105436. declare module BABYLON {
  105437. /**
  105438. * Raw cube texture where the raw buffers are passed in
  105439. */
  105440. export class RawCubeTexture extends CubeTexture {
  105441. /**
  105442. * Creates a cube texture where the raw buffers are passed in.
  105443. * @param scene defines the scene the texture is attached to
  105444. * @param data defines the array of data to use to create each face
  105445. * @param size defines the size of the textures
  105446. * @param format defines the format of the data
  105447. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105448. * @param generateMipMaps defines if the engine should generate the mip levels
  105449. * @param invertY defines if data must be stored with Y axis inverted
  105450. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105451. * @param compression defines the compression used (null by default)
  105452. */
  105453. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105454. /**
  105455. * Updates the raw cube texture.
  105456. * @param data defines the data to store
  105457. * @param format defines the data format
  105458. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105459. * @param invertY defines if data must be stored with Y axis inverted
  105460. * @param compression defines the compression used (null by default)
  105461. * @param level defines which level of the texture to update
  105462. */
  105463. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105464. /**
  105465. * Updates a raw cube texture with RGBD encoded data.
  105466. * @param data defines the array of data [mipmap][face] to use to create each face
  105467. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105470. * @returns a promsie that resolves when the operation is complete
  105471. */
  105472. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105473. /**
  105474. * Clones the raw cube texture.
  105475. * @return a new cube texture
  105476. */
  105477. clone(): CubeTexture;
  105478. /** @hidden */
  105479. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105480. }
  105481. }
  105482. declare module BABYLON {
  105483. /**
  105484. * Class used to store 3D textures containing user data
  105485. */
  105486. export class RawTexture3D extends Texture {
  105487. /** Gets or sets the texture format to use */
  105488. format: number;
  105489. private _engine;
  105490. /**
  105491. * Create a new RawTexture3D
  105492. * @param data defines the data of the texture
  105493. * @param width defines the width of the texture
  105494. * @param height defines the height of the texture
  105495. * @param depth defines the depth of the texture
  105496. * @param format defines the texture format to use
  105497. * @param scene defines the hosting scene
  105498. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105499. * @param invertY defines if texture must be stored with Y axis inverted
  105500. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105501. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105502. */
  105503. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105504. /** Gets or sets the texture format to use */
  105505. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105506. /**
  105507. * Update the texture with new data
  105508. * @param data defines the data to store in the texture
  105509. */
  105510. update(data: ArrayBufferView): void;
  105511. }
  105512. }
  105513. declare module BABYLON {
  105514. /**
  105515. * Creates a refraction texture used by refraction channel of the standard material.
  105516. * It is like a mirror but to see through a material.
  105517. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105518. */
  105519. export class RefractionTexture extends RenderTargetTexture {
  105520. /**
  105521. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105522. * 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.
  105523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105524. */
  105525. refractionPlane: Plane;
  105526. /**
  105527. * Define how deep under the surface we should see.
  105528. */
  105529. depth: number;
  105530. /**
  105531. * Creates a refraction texture used by refraction channel of the standard material.
  105532. * It is like a mirror but to see through a material.
  105533. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105534. * @param name Define the texture name
  105535. * @param size Define the size of the underlying texture
  105536. * @param scene Define the scene the refraction belongs to
  105537. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105538. */
  105539. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105540. /**
  105541. * Clone the refraction texture.
  105542. * @returns the cloned texture
  105543. */
  105544. clone(): RefractionTexture;
  105545. /**
  105546. * Serialize the texture to a JSON representation you could use in Parse later on
  105547. * @returns the serialized JSON representation
  105548. */
  105549. serialize(): any;
  105550. }
  105551. }
  105552. declare module BABYLON {
  105553. /**
  105554. * Configuration for Draco compression
  105555. */
  105556. export interface IDracoCompressionConfiguration {
  105557. /**
  105558. * Configuration for the decoder.
  105559. */
  105560. decoder?: {
  105561. /**
  105562. * The url to the WebAssembly module.
  105563. */
  105564. wasmUrl?: string;
  105565. /**
  105566. * The url to the WebAssembly binary.
  105567. */
  105568. wasmBinaryUrl?: string;
  105569. /**
  105570. * The url to the fallback JavaScript module.
  105571. */
  105572. fallbackUrl?: string;
  105573. };
  105574. }
  105575. /**
  105576. * Draco compression (https://google.github.io/draco/)
  105577. *
  105578. * This class wraps the Draco module.
  105579. *
  105580. * **Encoder**
  105581. *
  105582. * The encoder is not currently implemented.
  105583. *
  105584. * **Decoder**
  105585. *
  105586. * 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.
  105587. *
  105588. * To update the configuration, use the following code:
  105589. * ```javascript
  105590. * DracoCompression.Configuration = {
  105591. * decoder: {
  105592. * wasmUrl: "<url to the WebAssembly library>",
  105593. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105594. * fallbackUrl: "<url to the fallback JavaScript library>",
  105595. * }
  105596. * };
  105597. * ```
  105598. *
  105599. * 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.
  105600. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105601. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105602. *
  105603. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105604. * ```javascript
  105605. * var dracoCompression = new DracoCompression();
  105606. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105607. * [VertexBuffer.PositionKind]: 0
  105608. * });
  105609. * ```
  105610. *
  105611. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105612. */
  105613. export class DracoCompression implements IDisposable {
  105614. private static _DecoderModulePromise;
  105615. /**
  105616. * The configuration. Defaults to the following urls:
  105617. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105618. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105619. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105620. */
  105621. static Configuration: IDracoCompressionConfiguration;
  105622. /**
  105623. * Returns true if the decoder is available.
  105624. */
  105625. static readonly DecoderAvailable: boolean;
  105626. /**
  105627. * Constructor
  105628. */
  105629. constructor();
  105630. /**
  105631. * Stop all async operations and release resources.
  105632. */
  105633. dispose(): void;
  105634. /**
  105635. * Decode Draco compressed mesh data to vertex data.
  105636. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105637. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105638. * @returns A promise that resolves with the decoded vertex data
  105639. */
  105640. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105641. [kind: string]: number;
  105642. }): Promise<VertexData>;
  105643. private static _GetDecoderModule;
  105644. private static _LoadScriptAsync;
  105645. private static _LoadFileAsync;
  105646. }
  105647. }
  105648. declare module BABYLON {
  105649. /**
  105650. * Class for building Constructive Solid Geometry
  105651. */
  105652. export class CSG {
  105653. private polygons;
  105654. /**
  105655. * The world matrix
  105656. */
  105657. matrix: Matrix;
  105658. /**
  105659. * Stores the position
  105660. */
  105661. position: Vector3;
  105662. /**
  105663. * Stores the rotation
  105664. */
  105665. rotation: Vector3;
  105666. /**
  105667. * Stores the rotation quaternion
  105668. */
  105669. rotationQuaternion: Nullable<Quaternion>;
  105670. /**
  105671. * Stores the scaling vector
  105672. */
  105673. scaling: Vector3;
  105674. /**
  105675. * Convert the Mesh to CSG
  105676. * @param mesh The Mesh to convert to CSG
  105677. * @returns A new CSG from the Mesh
  105678. */
  105679. static FromMesh(mesh: Mesh): CSG;
  105680. /**
  105681. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105682. * @param polygons Polygons used to construct a CSG solid
  105683. */
  105684. private static FromPolygons;
  105685. /**
  105686. * Clones, or makes a deep copy, of the CSG
  105687. * @returns A new CSG
  105688. */
  105689. clone(): CSG;
  105690. /**
  105691. * Unions this CSG with another CSG
  105692. * @param csg The CSG to union against this CSG
  105693. * @returns The unioned CSG
  105694. */
  105695. union(csg: CSG): CSG;
  105696. /**
  105697. * Unions this CSG with another CSG in place
  105698. * @param csg The CSG to union against this CSG
  105699. */
  105700. unionInPlace(csg: CSG): void;
  105701. /**
  105702. * Subtracts this CSG with another CSG
  105703. * @param csg The CSG to subtract against this CSG
  105704. * @returns A new CSG
  105705. */
  105706. subtract(csg: CSG): CSG;
  105707. /**
  105708. * Subtracts this CSG with another CSG in place
  105709. * @param csg The CSG to subtact against this CSG
  105710. */
  105711. subtractInPlace(csg: CSG): void;
  105712. /**
  105713. * Intersect this CSG with another CSG
  105714. * @param csg The CSG to intersect against this CSG
  105715. * @returns A new CSG
  105716. */
  105717. intersect(csg: CSG): CSG;
  105718. /**
  105719. * Intersects this CSG with another CSG in place
  105720. * @param csg The CSG to intersect against this CSG
  105721. */
  105722. intersectInPlace(csg: CSG): void;
  105723. /**
  105724. * Return a new CSG solid with solid and empty space switched. This solid is
  105725. * not modified.
  105726. * @returns A new CSG solid with solid and empty space switched
  105727. */
  105728. inverse(): CSG;
  105729. /**
  105730. * Inverses the CSG in place
  105731. */
  105732. inverseInPlace(): void;
  105733. /**
  105734. * This is used to keep meshes transformations so they can be restored
  105735. * when we build back a Babylon Mesh
  105736. * NB : All CSG operations are performed in world coordinates
  105737. * @param csg The CSG to copy the transform attributes from
  105738. * @returns This CSG
  105739. */
  105740. copyTransformAttributes(csg: CSG): CSG;
  105741. /**
  105742. * Build Raw mesh from CSG
  105743. * Coordinates here are in world space
  105744. * @param name The name of the mesh geometry
  105745. * @param scene The Scene
  105746. * @param keepSubMeshes Specifies if the submeshes should be kept
  105747. * @returns A new Mesh
  105748. */
  105749. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105750. /**
  105751. * Build Mesh from CSG taking material and transforms into account
  105752. * @param name The name of the Mesh
  105753. * @param material The material of the Mesh
  105754. * @param scene The Scene
  105755. * @param keepSubMeshes Specifies if submeshes should be kept
  105756. * @returns The new Mesh
  105757. */
  105758. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. /**
  105763. * Class used to create a trail following a mesh
  105764. */
  105765. export class TrailMesh extends Mesh {
  105766. private _generator;
  105767. private _autoStart;
  105768. private _running;
  105769. private _diameter;
  105770. private _length;
  105771. private _sectionPolygonPointsCount;
  105772. private _sectionVectors;
  105773. private _sectionNormalVectors;
  105774. private _beforeRenderObserver;
  105775. /**
  105776. * @constructor
  105777. * @param name The value used by scene.getMeshByName() to do a lookup.
  105778. * @param generator The mesh to generate a trail.
  105779. * @param scene The scene to add this mesh to.
  105780. * @param diameter Diameter of trailing mesh. Default is 1.
  105781. * @param length Length of trailing mesh. Default is 60.
  105782. * @param autoStart Automatically start trailing mesh. Default true.
  105783. */
  105784. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105785. /**
  105786. * "TrailMesh"
  105787. * @returns "TrailMesh"
  105788. */
  105789. getClassName(): string;
  105790. private _createMesh;
  105791. /**
  105792. * Start trailing mesh.
  105793. */
  105794. start(): void;
  105795. /**
  105796. * Stop trailing mesh.
  105797. */
  105798. stop(): void;
  105799. /**
  105800. * Update trailing mesh geometry.
  105801. */
  105802. update(): void;
  105803. /**
  105804. * Returns a new TrailMesh object.
  105805. * @param name is a string, the name given to the new mesh
  105806. * @param newGenerator use new generator object for cloned trail mesh
  105807. * @returns a new mesh
  105808. */
  105809. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105810. /**
  105811. * Serializes this trail mesh
  105812. * @param serializationObject object to write serialization to
  105813. */
  105814. serialize(serializationObject: any): void;
  105815. /**
  105816. * Parses a serialized trail mesh
  105817. * @param parsedMesh the serialized mesh
  105818. * @param scene the scene to create the trail mesh in
  105819. * @returns the created trail mesh
  105820. */
  105821. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105822. }
  105823. }
  105824. declare module BABYLON {
  105825. /**
  105826. * Class containing static functions to help procedurally build meshes
  105827. */
  105828. export class RibbonBuilder {
  105829. /**
  105830. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105831. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105832. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105833. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105834. * * 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
  105835. * * 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
  105836. * * 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
  105837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105840. * * 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
  105841. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105842. * * 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
  105843. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105845. * @param name defines the name of the mesh
  105846. * @param options defines the options used to create the mesh
  105847. * @param scene defines the hosting scene
  105848. * @returns the ribbon mesh
  105849. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105851. */
  105852. static CreateRibbon(name: string, options: {
  105853. pathArray: Vector3[][];
  105854. closeArray?: boolean;
  105855. closePath?: boolean;
  105856. offset?: number;
  105857. updatable?: boolean;
  105858. sideOrientation?: number;
  105859. frontUVs?: Vector4;
  105860. backUVs?: Vector4;
  105861. instance?: Mesh;
  105862. invertUV?: boolean;
  105863. uvs?: Vector2[];
  105864. colors?: Color4[];
  105865. }, scene?: Nullable<Scene>): Mesh;
  105866. }
  105867. }
  105868. declare module BABYLON {
  105869. /**
  105870. * Class containing static functions to help procedurally build meshes
  105871. */
  105872. export class TorusKnotBuilder {
  105873. /**
  105874. * Creates a torus knot mesh
  105875. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105876. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105877. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105878. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105882. * @param name defines the name of the mesh
  105883. * @param options defines the options used to create the mesh
  105884. * @param scene defines the hosting scene
  105885. * @returns the torus knot mesh
  105886. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105887. */
  105888. static CreateTorusKnot(name: string, options: {
  105889. radius?: number;
  105890. tube?: number;
  105891. radialSegments?: number;
  105892. tubularSegments?: number;
  105893. p?: number;
  105894. q?: number;
  105895. updatable?: boolean;
  105896. sideOrientation?: number;
  105897. frontUVs?: Vector4;
  105898. backUVs?: Vector4;
  105899. }, scene: any): Mesh;
  105900. }
  105901. }
  105902. declare module BABYLON {
  105903. /**
  105904. * Polygon
  105905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105906. */
  105907. export class Polygon {
  105908. /**
  105909. * Creates a rectangle
  105910. * @param xmin bottom X coord
  105911. * @param ymin bottom Y coord
  105912. * @param xmax top X coord
  105913. * @param ymax top Y coord
  105914. * @returns points that make the resulting rectation
  105915. */
  105916. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105917. /**
  105918. * Creates a circle
  105919. * @param radius radius of circle
  105920. * @param cx scale in x
  105921. * @param cy scale in y
  105922. * @param numberOfSides number of sides that make up the circle
  105923. * @returns points that make the resulting circle
  105924. */
  105925. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105926. /**
  105927. * Creates a polygon from input string
  105928. * @param input Input polygon data
  105929. * @returns the parsed points
  105930. */
  105931. static Parse(input: string): Vector2[];
  105932. /**
  105933. * Starts building a polygon from x and y coordinates
  105934. * @param x x coordinate
  105935. * @param y y coordinate
  105936. * @returns the started path2
  105937. */
  105938. static StartingAt(x: number, y: number): Path2;
  105939. }
  105940. /**
  105941. * Builds a polygon
  105942. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105943. */
  105944. export class PolygonMeshBuilder {
  105945. private _points;
  105946. private _outlinepoints;
  105947. private _holes;
  105948. private _name;
  105949. private _scene;
  105950. private _epoints;
  105951. private _eholes;
  105952. private _addToepoint;
  105953. /**
  105954. * Babylon reference to the earcut plugin.
  105955. */
  105956. bjsEarcut: any;
  105957. /**
  105958. * Creates a PolygonMeshBuilder
  105959. * @param name name of the builder
  105960. * @param contours Path of the polygon
  105961. * @param scene scene to add to when creating the mesh
  105962. * @param earcutInjection can be used to inject your own earcut reference
  105963. */
  105964. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  105965. /**
  105966. * Adds a whole within the polygon
  105967. * @param hole Array of points defining the hole
  105968. * @returns this
  105969. */
  105970. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105971. /**
  105972. * Creates the polygon
  105973. * @param updatable If the mesh should be updatable
  105974. * @param depth The depth of the mesh created
  105975. * @returns the created mesh
  105976. */
  105977. build(updatable?: boolean, depth?: number): Mesh;
  105978. /**
  105979. * Creates the polygon
  105980. * @param depth The depth of the mesh created
  105981. * @returns the created VertexData
  105982. */
  105983. buildVertexData(depth?: number): VertexData;
  105984. /**
  105985. * Adds a side to the polygon
  105986. * @param positions points that make the polygon
  105987. * @param normals normals of the polygon
  105988. * @param uvs uvs of the polygon
  105989. * @param indices indices of the polygon
  105990. * @param bounds bounds of the polygon
  105991. * @param points points of the polygon
  105992. * @param depth depth of the polygon
  105993. * @param flip flip of the polygon
  105994. */
  105995. private addSide;
  105996. }
  105997. }
  105998. declare module BABYLON {
  105999. /**
  106000. * Class containing static functions to help procedurally build meshes
  106001. */
  106002. export class PolygonBuilder {
  106003. /**
  106004. * Creates a polygon mesh
  106005. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106006. * * 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
  106007. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106010. * * Remember you can only change the shape positions, not their number when updating a polygon
  106011. * @param name defines the name of the mesh
  106012. * @param options defines the options used to create the mesh
  106013. * @param scene defines the hosting scene
  106014. * @param earcutInjection can be used to inject your own earcut reference
  106015. * @returns the polygon mesh
  106016. */
  106017. static CreatePolygon(name: string, options: {
  106018. shape: Vector3[];
  106019. holes?: Vector3[][];
  106020. depth?: number;
  106021. faceUV?: Vector4[];
  106022. faceColors?: Color4[];
  106023. updatable?: boolean;
  106024. sideOrientation?: number;
  106025. frontUVs?: Vector4;
  106026. backUVs?: Vector4;
  106027. }, scene: Scene, earcutInjection?: any): Mesh;
  106028. /**
  106029. * Creates an extruded polygon mesh, with depth in the Y direction.
  106030. * * 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)
  106031. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106032. * @param name defines the name of the mesh
  106033. * @param options defines the options used to create the mesh
  106034. * @param scene defines the hosting scene
  106035. * @param earcutInjection can be used to inject your own earcut reference
  106036. * @returns the polygon mesh
  106037. */
  106038. static ExtrudePolygon(name: string, options: {
  106039. shape: Vector3[];
  106040. holes?: Vector3[][];
  106041. depth?: number;
  106042. faceUV?: Vector4[];
  106043. faceColors?: Color4[];
  106044. updatable?: boolean;
  106045. sideOrientation?: number;
  106046. frontUVs?: Vector4;
  106047. backUVs?: Vector4;
  106048. }, scene: Scene, earcutInjection?: any): Mesh;
  106049. }
  106050. }
  106051. declare module BABYLON {
  106052. /**
  106053. * Class containing static functions to help procedurally build meshes
  106054. */
  106055. export class ShapeBuilder {
  106056. /**
  106057. * 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.
  106058. * * 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.
  106059. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106060. * * 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.
  106061. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106062. * * 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
  106063. * * 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
  106064. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106069. * @param name defines the name of the mesh
  106070. * @param options defines the options used to create the mesh
  106071. * @param scene defines the hosting scene
  106072. * @returns the extruded shape mesh
  106073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106075. */
  106076. static ExtrudeShape(name: string, options: {
  106077. shape: Vector3[];
  106078. path: Vector3[];
  106079. scale?: number;
  106080. rotation?: number;
  106081. cap?: number;
  106082. updatable?: boolean;
  106083. sideOrientation?: number;
  106084. frontUVs?: Vector4;
  106085. backUVs?: Vector4;
  106086. instance?: Mesh;
  106087. invertUV?: boolean;
  106088. }, scene?: Nullable<Scene>): Mesh;
  106089. /**
  106090. * Creates an custom extruded shape mesh.
  106091. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106092. * * 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.
  106093. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106094. * * 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
  106095. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106096. * * 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
  106097. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106098. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106099. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106100. * * 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
  106101. * * 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
  106102. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106107. * @param name defines the name of the mesh
  106108. * @param options defines the options used to create the mesh
  106109. * @param scene defines the hosting scene
  106110. * @returns the custom extruded shape mesh
  106111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106112. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106114. */
  106115. static ExtrudeShapeCustom(name: string, options: {
  106116. shape: Vector3[];
  106117. path: Vector3[];
  106118. scaleFunction?: any;
  106119. rotationFunction?: any;
  106120. ribbonCloseArray?: boolean;
  106121. ribbonClosePath?: boolean;
  106122. cap?: number;
  106123. updatable?: boolean;
  106124. sideOrientation?: number;
  106125. frontUVs?: Vector4;
  106126. backUVs?: Vector4;
  106127. instance?: Mesh;
  106128. invertUV?: boolean;
  106129. }, scene: Scene): Mesh;
  106130. private static _ExtrudeShapeGeneric;
  106131. }
  106132. }
  106133. declare module BABYLON {
  106134. /**
  106135. * Class containing static functions to help procedurally build meshes
  106136. */
  106137. export class LatheBuilder {
  106138. /**
  106139. * Creates lathe mesh.
  106140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106141. * * 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
  106142. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106143. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106144. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106145. * * 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
  106146. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106147. * * 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
  106148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106152. * @param name defines the name of the mesh
  106153. * @param options defines the options used to create the mesh
  106154. * @param scene defines the hosting scene
  106155. * @returns the lathe mesh
  106156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106157. */
  106158. static CreateLathe(name: string, options: {
  106159. shape: Vector3[];
  106160. radius?: number;
  106161. tessellation?: number;
  106162. clip?: number;
  106163. arc?: number;
  106164. closed?: boolean;
  106165. updatable?: boolean;
  106166. sideOrientation?: number;
  106167. frontUVs?: Vector4;
  106168. backUVs?: Vector4;
  106169. cap?: number;
  106170. invertUV?: boolean;
  106171. }, scene: Scene): Mesh;
  106172. }
  106173. }
  106174. declare module BABYLON {
  106175. /**
  106176. * Class containing static functions to help procedurally build meshes
  106177. */
  106178. export class TubeBuilder {
  106179. /**
  106180. * Creates a tube mesh.
  106181. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106182. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106183. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106184. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106185. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106186. * * 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)
  106187. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106188. * * 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
  106189. * * 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
  106190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106194. * @param name defines the name of the mesh
  106195. * @param options defines the options used to create the mesh
  106196. * @param scene defines the hosting scene
  106197. * @returns the tube mesh
  106198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106199. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106200. */
  106201. static CreateTube(name: string, options: {
  106202. path: Vector3[];
  106203. radius?: number;
  106204. tessellation?: number;
  106205. radiusFunction?: {
  106206. (i: number, distance: number): number;
  106207. };
  106208. cap?: number;
  106209. arc?: number;
  106210. updatable?: boolean;
  106211. sideOrientation?: number;
  106212. frontUVs?: Vector4;
  106213. backUVs?: Vector4;
  106214. instance?: Mesh;
  106215. invertUV?: boolean;
  106216. }, scene: Scene): Mesh;
  106217. }
  106218. }
  106219. declare module BABYLON {
  106220. /**
  106221. * Class containing static functions to help procedurally build meshes
  106222. */
  106223. export class IcoSphereBuilder {
  106224. /**
  106225. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106226. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106227. * * 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`)
  106228. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106229. * * 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
  106230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106233. * @param name defines the name of the mesh
  106234. * @param options defines the options used to create the mesh
  106235. * @param scene defines the hosting scene
  106236. * @returns the icosahedron mesh
  106237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106238. */
  106239. static CreateIcoSphere(name: string, options: {
  106240. radius?: number;
  106241. radiusX?: number;
  106242. radiusY?: number;
  106243. radiusZ?: number;
  106244. flat?: boolean;
  106245. subdivisions?: number;
  106246. sideOrientation?: number;
  106247. frontUVs?: Vector4;
  106248. backUVs?: Vector4;
  106249. updatable?: boolean;
  106250. }, scene: Scene): Mesh;
  106251. }
  106252. }
  106253. declare module BABYLON {
  106254. /**
  106255. * Class containing static functions to help procedurally build meshes
  106256. */
  106257. export class DecalBuilder {
  106258. /**
  106259. * Creates a decal mesh.
  106260. * 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
  106261. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106262. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106263. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106264. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106265. * @param name defines the name of the mesh
  106266. * @param sourceMesh defines the mesh where the decal must be applied
  106267. * @param options defines the options used to create the mesh
  106268. * @param scene defines the hosting scene
  106269. * @returns the decal mesh
  106270. * @see https://doc.babylonjs.com/how_to/decals
  106271. */
  106272. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106273. position?: Vector3;
  106274. normal?: Vector3;
  106275. size?: Vector3;
  106276. angle?: number;
  106277. }): Mesh;
  106278. }
  106279. }
  106280. declare module BABYLON {
  106281. /**
  106282. * Class containing static functions to help procedurally build meshes
  106283. */
  106284. export class MeshBuilder {
  106285. /**
  106286. * Creates a box mesh
  106287. * * The parameter `size` sets the size (float) of each box side (default 1)
  106288. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106289. * * 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)
  106290. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106294. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106295. * @param name defines the name of the mesh
  106296. * @param options defines the options used to create the mesh
  106297. * @param scene defines the hosting scene
  106298. * @returns the box mesh
  106299. */
  106300. static CreateBox(name: string, options: {
  106301. size?: number;
  106302. width?: number;
  106303. height?: number;
  106304. depth?: number;
  106305. faceUV?: Vector4[];
  106306. faceColors?: Color4[];
  106307. sideOrientation?: number;
  106308. frontUVs?: Vector4;
  106309. backUVs?: Vector4;
  106310. updatable?: boolean;
  106311. }, scene?: Nullable<Scene>): Mesh;
  106312. /**
  106313. * Creates a sphere mesh
  106314. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106315. * * 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`)
  106316. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106317. * * 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
  106318. * * 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)
  106319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106322. * @param name defines the name of the mesh
  106323. * @param options defines the options used to create the mesh
  106324. * @param scene defines the hosting scene
  106325. * @returns the sphere mesh
  106326. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106327. */
  106328. static CreateSphere(name: string, options: {
  106329. segments?: number;
  106330. diameter?: number;
  106331. diameterX?: number;
  106332. diameterY?: number;
  106333. diameterZ?: number;
  106334. arc?: number;
  106335. slice?: number;
  106336. sideOrientation?: number;
  106337. frontUVs?: Vector4;
  106338. backUVs?: Vector4;
  106339. updatable?: boolean;
  106340. }, scene: any): Mesh;
  106341. /**
  106342. * Creates a plane polygonal mesh. By default, this is a disc
  106343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106344. * * 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
  106345. * * 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
  106346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106349. * @param name defines the name of the mesh
  106350. * @param options defines the options used to create the mesh
  106351. * @param scene defines the hosting scene
  106352. * @returns the plane polygonal mesh
  106353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106354. */
  106355. static CreateDisc(name: string, options: {
  106356. radius?: number;
  106357. tessellation?: number;
  106358. arc?: number;
  106359. updatable?: boolean;
  106360. sideOrientation?: number;
  106361. frontUVs?: Vector4;
  106362. backUVs?: Vector4;
  106363. }, scene?: Nullable<Scene>): Mesh;
  106364. /**
  106365. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106366. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106367. * * 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`)
  106368. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106369. * * 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
  106370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106373. * @param name defines the name of the mesh
  106374. * @param options defines the options used to create the mesh
  106375. * @param scene defines the hosting scene
  106376. * @returns the icosahedron mesh
  106377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106378. */
  106379. static CreateIcoSphere(name: string, options: {
  106380. radius?: number;
  106381. radiusX?: number;
  106382. radiusY?: number;
  106383. radiusZ?: number;
  106384. flat?: boolean;
  106385. subdivisions?: number;
  106386. sideOrientation?: number;
  106387. frontUVs?: Vector4;
  106388. backUVs?: Vector4;
  106389. updatable?: boolean;
  106390. }, scene: Scene): Mesh;
  106391. /**
  106392. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106393. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106394. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106395. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106396. * * 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
  106397. * * 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
  106398. * * 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
  106399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106402. * * 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
  106403. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106404. * * 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
  106405. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106407. * @param name defines the name of the mesh
  106408. * @param options defines the options used to create the mesh
  106409. * @param scene defines the hosting scene
  106410. * @returns the ribbon mesh
  106411. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106413. */
  106414. static CreateRibbon(name: string, options: {
  106415. pathArray: Vector3[][];
  106416. closeArray?: boolean;
  106417. closePath?: boolean;
  106418. offset?: number;
  106419. updatable?: boolean;
  106420. sideOrientation?: number;
  106421. frontUVs?: Vector4;
  106422. backUVs?: Vector4;
  106423. instance?: Mesh;
  106424. invertUV?: boolean;
  106425. uvs?: Vector2[];
  106426. colors?: Color4[];
  106427. }, scene?: Nullable<Scene>): Mesh;
  106428. /**
  106429. * Creates a cylinder or a cone mesh
  106430. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106431. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106432. * * 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.
  106433. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106434. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106435. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106436. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106437. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106438. * * 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).
  106439. * * 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
  106440. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106441. * * 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
  106442. * * 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.
  106443. * * If `enclose` is false, a ring surface is one element.
  106444. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106445. * * 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
  106446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106449. * @param name defines the name of the mesh
  106450. * @param options defines the options used to create the mesh
  106451. * @param scene defines the hosting scene
  106452. * @returns the cylinder mesh
  106453. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106454. */
  106455. static CreateCylinder(name: string, options: {
  106456. height?: number;
  106457. diameterTop?: number;
  106458. diameterBottom?: number;
  106459. diameter?: number;
  106460. tessellation?: number;
  106461. subdivisions?: number;
  106462. arc?: number;
  106463. faceColors?: Color4[];
  106464. faceUV?: Vector4[];
  106465. updatable?: boolean;
  106466. hasRings?: boolean;
  106467. enclose?: boolean;
  106468. sideOrientation?: number;
  106469. frontUVs?: Vector4;
  106470. backUVs?: Vector4;
  106471. }, scene: any): Mesh;
  106472. /**
  106473. * Creates a torus mesh
  106474. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106475. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106476. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106480. * @param name defines the name of the mesh
  106481. * @param options defines the options used to create the mesh
  106482. * @param scene defines the hosting scene
  106483. * @returns the torus mesh
  106484. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106485. */
  106486. static CreateTorus(name: string, options: {
  106487. diameter?: number;
  106488. thickness?: number;
  106489. tessellation?: number;
  106490. updatable?: boolean;
  106491. sideOrientation?: number;
  106492. frontUVs?: Vector4;
  106493. backUVs?: Vector4;
  106494. }, scene: any): Mesh;
  106495. /**
  106496. * Creates a torus knot mesh
  106497. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106498. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106499. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106500. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106504. * @param name defines the name of the mesh
  106505. * @param options defines the options used to create the mesh
  106506. * @param scene defines the hosting scene
  106507. * @returns the torus knot mesh
  106508. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106509. */
  106510. static CreateTorusKnot(name: string, options: {
  106511. radius?: number;
  106512. tube?: number;
  106513. radialSegments?: number;
  106514. tubularSegments?: number;
  106515. p?: number;
  106516. q?: number;
  106517. updatable?: boolean;
  106518. sideOrientation?: number;
  106519. frontUVs?: Vector4;
  106520. backUVs?: Vector4;
  106521. }, scene: any): Mesh;
  106522. /**
  106523. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106524. * * 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
  106525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106526. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106527. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106528. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106529. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106530. * * 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
  106531. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106534. * @param name defines the name of the new line system
  106535. * @param options defines the options used to create the line system
  106536. * @param scene defines the hosting scene
  106537. * @returns a new line system mesh
  106538. */
  106539. static CreateLineSystem(name: string, options: {
  106540. lines: Vector3[][];
  106541. updatable?: boolean;
  106542. instance?: Nullable<LinesMesh>;
  106543. colors?: Nullable<Color4[][]>;
  106544. useVertexAlpha?: boolean;
  106545. }, scene: Nullable<Scene>): LinesMesh;
  106546. /**
  106547. * Creates a line mesh
  106548. * 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
  106549. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106550. * * The parameter `points` is an array successive Vector3
  106551. * * 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
  106552. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106553. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106554. * * When updating an instance, remember that only point positions can change, not the number of points
  106555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106557. * @param name defines the name of the new line system
  106558. * @param options defines the options used to create the line system
  106559. * @param scene defines the hosting scene
  106560. * @returns a new line mesh
  106561. */
  106562. static CreateLines(name: string, options: {
  106563. points: Vector3[];
  106564. updatable?: boolean;
  106565. instance?: Nullable<LinesMesh>;
  106566. colors?: Color4[];
  106567. useVertexAlpha?: boolean;
  106568. }, scene?: Nullable<Scene>): LinesMesh;
  106569. /**
  106570. * Creates a dashed line mesh
  106571. * * 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
  106572. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106573. * * The parameter `points` is an array successive Vector3
  106574. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106575. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106576. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106577. * * 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
  106578. * * When updating an instance, remember that only point positions can change, not the number of points
  106579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106580. * @param name defines the name of the mesh
  106581. * @param options defines the options used to create the mesh
  106582. * @param scene defines the hosting scene
  106583. * @returns the dashed line mesh
  106584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106585. */
  106586. static CreateDashedLines(name: string, options: {
  106587. points: Vector3[];
  106588. dashSize?: number;
  106589. gapSize?: number;
  106590. dashNb?: number;
  106591. updatable?: boolean;
  106592. instance?: LinesMesh;
  106593. }, scene?: Nullable<Scene>): LinesMesh;
  106594. /**
  106595. * 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.
  106596. * * 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.
  106597. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106598. * * 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.
  106599. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106600. * * 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
  106601. * * 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
  106602. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106605. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106607. * @param name defines the name of the mesh
  106608. * @param options defines the options used to create the mesh
  106609. * @param scene defines the hosting scene
  106610. * @returns the extruded shape mesh
  106611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106613. */
  106614. static ExtrudeShape(name: string, options: {
  106615. shape: Vector3[];
  106616. path: Vector3[];
  106617. scale?: number;
  106618. rotation?: number;
  106619. cap?: number;
  106620. updatable?: boolean;
  106621. sideOrientation?: number;
  106622. frontUVs?: Vector4;
  106623. backUVs?: Vector4;
  106624. instance?: Mesh;
  106625. invertUV?: boolean;
  106626. }, scene?: Nullable<Scene>): Mesh;
  106627. /**
  106628. * Creates an custom extruded shape mesh.
  106629. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106630. * * 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.
  106631. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106632. * * 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
  106633. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106634. * * 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
  106635. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106636. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106637. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106638. * * 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
  106639. * * 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
  106640. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106643. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106645. * @param name defines the name of the mesh
  106646. * @param options defines the options used to create the mesh
  106647. * @param scene defines the hosting scene
  106648. * @returns the custom extruded shape mesh
  106649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106652. */
  106653. static ExtrudeShapeCustom(name: string, options: {
  106654. shape: Vector3[];
  106655. path: Vector3[];
  106656. scaleFunction?: any;
  106657. rotationFunction?: any;
  106658. ribbonCloseArray?: boolean;
  106659. ribbonClosePath?: boolean;
  106660. cap?: number;
  106661. updatable?: boolean;
  106662. sideOrientation?: number;
  106663. frontUVs?: Vector4;
  106664. backUVs?: Vector4;
  106665. instance?: Mesh;
  106666. invertUV?: boolean;
  106667. }, scene: Scene): Mesh;
  106668. /**
  106669. * Creates lathe mesh.
  106670. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106671. * * 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
  106672. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106673. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106674. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106675. * * 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
  106676. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106677. * * 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
  106678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106682. * @param name defines the name of the mesh
  106683. * @param options defines the options used to create the mesh
  106684. * @param scene defines the hosting scene
  106685. * @returns the lathe mesh
  106686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106687. */
  106688. static CreateLathe(name: string, options: {
  106689. shape: Vector3[];
  106690. radius?: number;
  106691. tessellation?: number;
  106692. clip?: number;
  106693. arc?: number;
  106694. closed?: boolean;
  106695. updatable?: boolean;
  106696. sideOrientation?: number;
  106697. frontUVs?: Vector4;
  106698. backUVs?: Vector4;
  106699. cap?: number;
  106700. invertUV?: boolean;
  106701. }, scene: Scene): Mesh;
  106702. /**
  106703. * Creates a plane mesh
  106704. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106705. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106706. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106710. * @param name defines the name of the mesh
  106711. * @param options defines the options used to create the mesh
  106712. * @param scene defines the hosting scene
  106713. * @returns the plane mesh
  106714. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106715. */
  106716. static CreatePlane(name: string, options: {
  106717. size?: number;
  106718. width?: number;
  106719. height?: number;
  106720. sideOrientation?: number;
  106721. frontUVs?: Vector4;
  106722. backUVs?: Vector4;
  106723. updatable?: boolean;
  106724. sourcePlane?: Plane;
  106725. }, scene: Scene): Mesh;
  106726. /**
  106727. * Creates a ground mesh
  106728. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106729. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106731. * @param name defines the name of the mesh
  106732. * @param options defines the options used to create the mesh
  106733. * @param scene defines the hosting scene
  106734. * @returns the ground mesh
  106735. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106736. */
  106737. static CreateGround(name: string, options: {
  106738. width?: number;
  106739. height?: number;
  106740. subdivisions?: number;
  106741. subdivisionsX?: number;
  106742. subdivisionsY?: number;
  106743. updatable?: boolean;
  106744. }, scene: any): Mesh;
  106745. /**
  106746. * Creates a tiled ground mesh
  106747. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106748. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106749. * * 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
  106750. * * 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
  106751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106752. * @param name defines the name of the mesh
  106753. * @param options defines the options used to create the mesh
  106754. * @param scene defines the hosting scene
  106755. * @returns the tiled ground mesh
  106756. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106757. */
  106758. static CreateTiledGround(name: string, options: {
  106759. xmin: number;
  106760. zmin: number;
  106761. xmax: number;
  106762. zmax: number;
  106763. subdivisions?: {
  106764. w: number;
  106765. h: number;
  106766. };
  106767. precision?: {
  106768. w: number;
  106769. h: number;
  106770. };
  106771. updatable?: boolean;
  106772. }, scene: Scene): Mesh;
  106773. /**
  106774. * Creates a ground mesh from a height map
  106775. * * The parameter `url` sets the URL of the height map image resource.
  106776. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106777. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106778. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106779. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106780. * * 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.
  106781. * * 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).
  106782. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106784. * @param name defines the name of the mesh
  106785. * @param url defines the url to the height map
  106786. * @param options defines the options used to create the mesh
  106787. * @param scene defines the hosting scene
  106788. * @returns the ground mesh
  106789. * @see https://doc.babylonjs.com/babylon101/height_map
  106790. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106791. */
  106792. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106793. width?: number;
  106794. height?: number;
  106795. subdivisions?: number;
  106796. minHeight?: number;
  106797. maxHeight?: number;
  106798. colorFilter?: Color3;
  106799. alphaFilter?: number;
  106800. updatable?: boolean;
  106801. onReady?: (mesh: GroundMesh) => void;
  106802. }, scene: Scene): GroundMesh;
  106803. /**
  106804. * Creates a polygon mesh
  106805. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106806. * * 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
  106807. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106810. * * Remember you can only change the shape positions, not their number when updating a polygon
  106811. * @param name defines the name of the mesh
  106812. * @param options defines the options used to create the mesh
  106813. * @param scene defines the hosting scene
  106814. * @param earcutInjection can be used to inject your own earcut reference
  106815. * @returns the polygon mesh
  106816. */
  106817. static CreatePolygon(name: string, options: {
  106818. shape: Vector3[];
  106819. holes?: Vector3[][];
  106820. depth?: number;
  106821. faceUV?: Vector4[];
  106822. faceColors?: Color4[];
  106823. updatable?: boolean;
  106824. sideOrientation?: number;
  106825. frontUVs?: Vector4;
  106826. backUVs?: Vector4;
  106827. }, scene: Scene, earcutInjection?: any): Mesh;
  106828. /**
  106829. * Creates an extruded polygon mesh, with depth in the Y direction.
  106830. * * 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)
  106831. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106832. * @param name defines the name of the mesh
  106833. * @param options defines the options used to create the mesh
  106834. * @param scene defines the hosting scene
  106835. * @param earcutInjection can be used to inject your own earcut reference
  106836. * @returns the polygon mesh
  106837. */
  106838. static ExtrudePolygon(name: string, options: {
  106839. shape: Vector3[];
  106840. holes?: Vector3[][];
  106841. depth?: number;
  106842. faceUV?: Vector4[];
  106843. faceColors?: Color4[];
  106844. updatable?: boolean;
  106845. sideOrientation?: number;
  106846. frontUVs?: Vector4;
  106847. backUVs?: Vector4;
  106848. }, scene: Scene, earcutInjection?: any): Mesh;
  106849. /**
  106850. * Creates a tube mesh.
  106851. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106852. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106853. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106854. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106855. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106856. * * 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)
  106857. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106858. * * 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
  106859. * * 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
  106860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106864. * @param name defines the name of the mesh
  106865. * @param options defines the options used to create the mesh
  106866. * @param scene defines the hosting scene
  106867. * @returns the tube mesh
  106868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106869. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106870. */
  106871. static CreateTube(name: string, options: {
  106872. path: Vector3[];
  106873. radius?: number;
  106874. tessellation?: number;
  106875. radiusFunction?: {
  106876. (i: number, distance: number): number;
  106877. };
  106878. cap?: number;
  106879. arc?: number;
  106880. updatable?: boolean;
  106881. sideOrientation?: number;
  106882. frontUVs?: Vector4;
  106883. backUVs?: Vector4;
  106884. instance?: Mesh;
  106885. invertUV?: boolean;
  106886. }, scene: Scene): Mesh;
  106887. /**
  106888. * Creates a polyhedron mesh
  106889. * * 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
  106890. * * The parameter `size` (positive float, default 1) sets the polygon size
  106891. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106892. * * 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`
  106893. * * 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
  106894. * * 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)`)
  106895. * * 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
  106896. * * 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
  106897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106900. * @param name defines the name of the mesh
  106901. * @param options defines the options used to create the mesh
  106902. * @param scene defines the hosting scene
  106903. * @returns the polyhedron mesh
  106904. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106905. */
  106906. static CreatePolyhedron(name: string, options: {
  106907. type?: number;
  106908. size?: number;
  106909. sizeX?: number;
  106910. sizeY?: number;
  106911. sizeZ?: number;
  106912. custom?: any;
  106913. faceUV?: Vector4[];
  106914. faceColors?: Color4[];
  106915. flat?: boolean;
  106916. updatable?: boolean;
  106917. sideOrientation?: number;
  106918. frontUVs?: Vector4;
  106919. backUVs?: Vector4;
  106920. }, scene: Scene): Mesh;
  106921. /**
  106922. * Creates a decal mesh.
  106923. * 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
  106924. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106925. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106926. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106927. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106928. * @param name defines the name of the mesh
  106929. * @param sourceMesh defines the mesh where the decal must be applied
  106930. * @param options defines the options used to create the mesh
  106931. * @param scene defines the hosting scene
  106932. * @returns the decal mesh
  106933. * @see https://doc.babylonjs.com/how_to/decals
  106934. */
  106935. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106936. position?: Vector3;
  106937. normal?: Vector3;
  106938. size?: Vector3;
  106939. angle?: number;
  106940. }): Mesh;
  106941. }
  106942. }
  106943. declare module BABYLON {
  106944. /**
  106945. * A simplifier interface for future simplification implementations
  106946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106947. */
  106948. export interface ISimplifier {
  106949. /**
  106950. * Simplification of a given mesh according to the given settings.
  106951. * Since this requires computation, it is assumed that the function runs async.
  106952. * @param settings The settings of the simplification, including quality and distance
  106953. * @param successCallback A callback that will be called after the mesh was simplified.
  106954. * @param errorCallback in case of an error, this callback will be called. optional.
  106955. */
  106956. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106957. }
  106958. /**
  106959. * Expected simplification settings.
  106960. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106961. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106962. */
  106963. export interface ISimplificationSettings {
  106964. /**
  106965. * Gets or sets the expected quality
  106966. */
  106967. quality: number;
  106968. /**
  106969. * Gets or sets the distance when this optimized version should be used
  106970. */
  106971. distance: number;
  106972. /**
  106973. * Gets an already optimized mesh
  106974. */
  106975. optimizeMesh?: boolean;
  106976. }
  106977. /**
  106978. * Class used to specify simplification options
  106979. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106980. */
  106981. export class SimplificationSettings implements ISimplificationSettings {
  106982. /** expected quality */
  106983. quality: number;
  106984. /** distance when this optimized version should be used */
  106985. distance: number;
  106986. /** already optimized mesh */
  106987. optimizeMesh?: boolean | undefined;
  106988. /**
  106989. * Creates a SimplificationSettings
  106990. * @param quality expected quality
  106991. * @param distance distance when this optimized version should be used
  106992. * @param optimizeMesh already optimized mesh
  106993. */
  106994. constructor(
  106995. /** expected quality */
  106996. quality: number,
  106997. /** distance when this optimized version should be used */
  106998. distance: number,
  106999. /** already optimized mesh */
  107000. optimizeMesh?: boolean | undefined);
  107001. }
  107002. /**
  107003. * Interface used to define a simplification task
  107004. */
  107005. export interface ISimplificationTask {
  107006. /**
  107007. * Array of settings
  107008. */
  107009. settings: Array<ISimplificationSettings>;
  107010. /**
  107011. * Simplification type
  107012. */
  107013. simplificationType: SimplificationType;
  107014. /**
  107015. * Mesh to simplify
  107016. */
  107017. mesh: Mesh;
  107018. /**
  107019. * Callback called on success
  107020. */
  107021. successCallback?: () => void;
  107022. /**
  107023. * Defines if parallel processing can be used
  107024. */
  107025. parallelProcessing: boolean;
  107026. }
  107027. /**
  107028. * Queue used to order the simplification tasks
  107029. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107030. */
  107031. export class SimplificationQueue {
  107032. private _simplificationArray;
  107033. /**
  107034. * Gets a boolean indicating that the process is still running
  107035. */
  107036. running: boolean;
  107037. /**
  107038. * Creates a new queue
  107039. */
  107040. constructor();
  107041. /**
  107042. * Adds a new simplification task
  107043. * @param task defines a task to add
  107044. */
  107045. addTask(task: ISimplificationTask): void;
  107046. /**
  107047. * Execute next task
  107048. */
  107049. executeNext(): void;
  107050. /**
  107051. * Execute a simplification task
  107052. * @param task defines the task to run
  107053. */
  107054. runSimplification(task: ISimplificationTask): void;
  107055. private getSimplifier;
  107056. }
  107057. /**
  107058. * The implemented types of simplification
  107059. * At the moment only Quadratic Error Decimation is implemented
  107060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107061. */
  107062. export enum SimplificationType {
  107063. /** Quadratic error decimation */
  107064. QUADRATIC = 0
  107065. }
  107066. }
  107067. declare module BABYLON {
  107068. interface Scene {
  107069. /** @hidden (Backing field) */
  107070. _simplificationQueue: SimplificationQueue;
  107071. /**
  107072. * Gets or sets the simplification queue attached to the scene
  107073. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107074. */
  107075. simplificationQueue: SimplificationQueue;
  107076. }
  107077. interface Mesh {
  107078. /**
  107079. * Simplify the mesh according to the given array of settings.
  107080. * Function will return immediately and will simplify async
  107081. * @param settings a collection of simplification settings
  107082. * @param parallelProcessing should all levels calculate parallel or one after the other
  107083. * @param simplificationType the type of simplification to run
  107084. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  107085. * @returns the current mesh
  107086. */
  107087. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  107088. }
  107089. /**
  107090. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  107091. * created in a scene
  107092. */
  107093. export class SimplicationQueueSceneComponent implements ISceneComponent {
  107094. /**
  107095. * The component name helpfull to identify the component in the list of scene components.
  107096. */
  107097. readonly name: string;
  107098. /**
  107099. * The scene the component belongs to.
  107100. */
  107101. scene: Scene;
  107102. /**
  107103. * Creates a new instance of the component for the given scene
  107104. * @param scene Defines the scene to register the component in
  107105. */
  107106. constructor(scene: Scene);
  107107. /**
  107108. * Registers the component in a given scene
  107109. */
  107110. register(): void;
  107111. /**
  107112. * Rebuilds the elements related to this component in case of
  107113. * context lost for instance.
  107114. */
  107115. rebuild(): void;
  107116. /**
  107117. * Disposes the component and the associated ressources
  107118. */
  107119. dispose(): void;
  107120. private _beforeCameraUpdate;
  107121. }
  107122. }
  107123. declare module BABYLON {
  107124. /**
  107125. * Class used to enable access to IndexedDB
  107126. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107127. */
  107128. export class Database implements IOfflineProvider {
  107129. private _callbackManifestChecked;
  107130. private _currentSceneUrl;
  107131. private _db;
  107132. private _enableSceneOffline;
  107133. private _enableTexturesOffline;
  107134. private _manifestVersionFound;
  107135. private _mustUpdateRessources;
  107136. private _hasReachedQuota;
  107137. private _isSupported;
  107138. private _idbFactory;
  107139. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  107140. private static IsUASupportingBlobStorage;
  107141. /**
  107142. * Gets a boolean indicating if Database storate is enabled (off by default)
  107143. */
  107144. static IDBStorageEnabled: boolean;
  107145. /**
  107146. * Gets a boolean indicating if scene must be saved in the database
  107147. */
  107148. readonly enableSceneOffline: boolean;
  107149. /**
  107150. * Gets a boolean indicating if textures must be saved in the database
  107151. */
  107152. readonly enableTexturesOffline: boolean;
  107153. /**
  107154. * Creates a new Database
  107155. * @param urlToScene defines the url to load the scene
  107156. * @param callbackManifestChecked defines the callback to use when manifest is checked
  107157. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  107158. */
  107159. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  107160. private static _ParseURL;
  107161. private static _ReturnFullUrlLocation;
  107162. private _checkManifestFile;
  107163. /**
  107164. * Open the database and make it available
  107165. * @param successCallback defines the callback to call on success
  107166. * @param errorCallback defines the callback to call on error
  107167. */
  107168. open(successCallback: () => void, errorCallback: () => void): void;
  107169. /**
  107170. * Loads an image from the database
  107171. * @param url defines the url to load from
  107172. * @param image defines the target DOM image
  107173. */
  107174. loadImage(url: string, image: HTMLImageElement): void;
  107175. private _loadImageFromDBAsync;
  107176. private _saveImageIntoDBAsync;
  107177. private _checkVersionFromDB;
  107178. private _loadVersionFromDBAsync;
  107179. private _saveVersionIntoDBAsync;
  107180. /**
  107181. * Loads a file from database
  107182. * @param url defines the URL to load from
  107183. * @param sceneLoaded defines a callback to call on success
  107184. * @param progressCallBack defines a callback to call when progress changed
  107185. * @param errorCallback defines a callback to call on error
  107186. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  107187. */
  107188. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  107189. private _loadFileAsync;
  107190. private _saveFileAsync;
  107191. /**
  107192. * Validates if xhr data is correct
  107193. * @param xhr defines the request to validate
  107194. * @param dataType defines the expected data type
  107195. * @returns true if data is correct
  107196. */
  107197. private static _ValidateXHRData;
  107198. }
  107199. }
  107200. declare module BABYLON {
  107201. /** @hidden */
  107202. export var gpuUpdateParticlesPixelShader: {
  107203. name: string;
  107204. shader: string;
  107205. };
  107206. }
  107207. declare module BABYLON {
  107208. /** @hidden */
  107209. export var gpuUpdateParticlesVertexShader: {
  107210. name: string;
  107211. shader: string;
  107212. };
  107213. }
  107214. declare module BABYLON {
  107215. /** @hidden */
  107216. export var clipPlaneFragmentDeclaration2: {
  107217. name: string;
  107218. shader: string;
  107219. };
  107220. }
  107221. declare module BABYLON {
  107222. /** @hidden */
  107223. export var gpuRenderParticlesPixelShader: {
  107224. name: string;
  107225. shader: string;
  107226. };
  107227. }
  107228. declare module BABYLON {
  107229. /** @hidden */
  107230. export var clipPlaneVertexDeclaration2: {
  107231. name: string;
  107232. shader: string;
  107233. };
  107234. }
  107235. declare module BABYLON {
  107236. /** @hidden */
  107237. export var gpuRenderParticlesVertexShader: {
  107238. name: string;
  107239. shader: string;
  107240. };
  107241. }
  107242. declare module BABYLON {
  107243. /**
  107244. * This represents a GPU particle system in Babylon
  107245. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  107246. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  107247. */
  107248. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  107249. /**
  107250. * The layer mask we are rendering the particles through.
  107251. */
  107252. layerMask: number;
  107253. private _capacity;
  107254. private _activeCount;
  107255. private _currentActiveCount;
  107256. private _accumulatedCount;
  107257. private _renderEffect;
  107258. private _updateEffect;
  107259. private _buffer0;
  107260. private _buffer1;
  107261. private _spriteBuffer;
  107262. private _updateVAO;
  107263. private _renderVAO;
  107264. private _targetIndex;
  107265. private _sourceBuffer;
  107266. private _targetBuffer;
  107267. private _engine;
  107268. private _currentRenderId;
  107269. private _started;
  107270. private _stopped;
  107271. private _timeDelta;
  107272. private _randomTexture;
  107273. private _randomTexture2;
  107274. private _attributesStrideSize;
  107275. private _updateEffectOptions;
  107276. private _randomTextureSize;
  107277. private _actualFrame;
  107278. private readonly _rawTextureWidth;
  107279. /**
  107280. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  107281. */
  107282. static readonly IsSupported: boolean;
  107283. /**
  107284. * An event triggered when the system is disposed.
  107285. */
  107286. onDisposeObservable: Observable<GPUParticleSystem>;
  107287. /**
  107288. * Gets the maximum number of particles active at the same time.
  107289. * @returns The max number of active particles.
  107290. */
  107291. getCapacity(): number;
  107292. /**
  107293. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107294. * to override the particles.
  107295. */
  107296. forceDepthWrite: boolean;
  107297. /**
  107298. * Gets or set the number of active particles
  107299. */
  107300. activeParticleCount: number;
  107301. private _preWarmDone;
  107302. /**
  107303. * Is this system ready to be used/rendered
  107304. * @return true if the system is ready
  107305. */
  107306. isReady(): boolean;
  107307. /**
  107308. * Gets if the system has been started. (Note: this will still be true after stop is called)
  107309. * @returns True if it has been started, otherwise false.
  107310. */
  107311. isStarted(): boolean;
  107312. /**
  107313. * Starts the particle system and begins to emit
  107314. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  107315. */
  107316. start(delay?: number): void;
  107317. /**
  107318. * Stops the particle system.
  107319. */
  107320. stop(): void;
  107321. /**
  107322. * Remove all active particles
  107323. */
  107324. reset(): void;
  107325. /**
  107326. * Returns the string "GPUParticleSystem"
  107327. * @returns a string containing the class name
  107328. */
  107329. getClassName(): string;
  107330. private _colorGradientsTexture;
  107331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  107332. /**
  107333. * Adds a new color gradient
  107334. * @param gradient defines the gradient to use (between 0 and 1)
  107335. * @param color1 defines the color to affect to the specified gradient
  107336. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107337. * @returns the current particle system
  107338. */
  107339. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  107340. /**
  107341. * Remove a specific color gradient
  107342. * @param gradient defines the gradient to remove
  107343. * @returns the current particle system
  107344. */
  107345. removeColorGradient(gradient: number): GPUParticleSystem;
  107346. private _angularSpeedGradientsTexture;
  107347. private _sizeGradientsTexture;
  107348. private _velocityGradientsTexture;
  107349. private _limitVelocityGradientsTexture;
  107350. private _dragGradientsTexture;
  107351. private _addFactorGradient;
  107352. /**
  107353. * Adds a new size gradient
  107354. * @param gradient defines the gradient to use (between 0 and 1)
  107355. * @param factor defines the size factor to affect to the specified gradient
  107356. * @returns the current particle system
  107357. */
  107358. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  107359. /**
  107360. * Remove a specific size gradient
  107361. * @param gradient defines the gradient to remove
  107362. * @returns the current particle system
  107363. */
  107364. removeSizeGradient(gradient: number): GPUParticleSystem;
  107365. /**
  107366. * Adds a new angular speed gradient
  107367. * @param gradient defines the gradient to use (between 0 and 1)
  107368. * @param factor defines the angular speed to affect to the specified gradient
  107369. * @returns the current particle system
  107370. */
  107371. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  107372. /**
  107373. * Remove a specific angular speed gradient
  107374. * @param gradient defines the gradient to remove
  107375. * @returns the current particle system
  107376. */
  107377. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  107378. /**
  107379. * Adds a new velocity gradient
  107380. * @param gradient defines the gradient to use (between 0 and 1)
  107381. * @param factor defines the velocity to affect to the specified gradient
  107382. * @returns the current particle system
  107383. */
  107384. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107385. /**
  107386. * Remove a specific velocity gradient
  107387. * @param gradient defines the gradient to remove
  107388. * @returns the current particle system
  107389. */
  107390. removeVelocityGradient(gradient: number): GPUParticleSystem;
  107391. /**
  107392. * Adds a new limit velocity gradient
  107393. * @param gradient defines the gradient to use (between 0 and 1)
  107394. * @param factor defines the limit velocity value to affect to the specified gradient
  107395. * @returns the current particle system
  107396. */
  107397. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107398. /**
  107399. * Remove a specific limit velocity gradient
  107400. * @param gradient defines the gradient to remove
  107401. * @returns the current particle system
  107402. */
  107403. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  107404. /**
  107405. * Adds a new drag gradient
  107406. * @param gradient defines the gradient to use (between 0 and 1)
  107407. * @param factor defines the drag value to affect to the specified gradient
  107408. * @returns the current particle system
  107409. */
  107410. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  107411. /**
  107412. * Remove a specific drag gradient
  107413. * @param gradient defines the gradient to remove
  107414. * @returns the current particle system
  107415. */
  107416. removeDragGradient(gradient: number): GPUParticleSystem;
  107417. /**
  107418. * Not supported by GPUParticleSystem
  107419. * @param gradient defines the gradient to use (between 0 and 1)
  107420. * @param factor defines the emit rate value to affect to the specified gradient
  107421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107422. * @returns the current particle system
  107423. */
  107424. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107425. /**
  107426. * Not supported by GPUParticleSystem
  107427. * @param gradient defines the gradient to remove
  107428. * @returns the current particle system
  107429. */
  107430. removeEmitRateGradient(gradient: number): IParticleSystem;
  107431. /**
  107432. * Not supported by GPUParticleSystem
  107433. * @param gradient defines the gradient to use (between 0 and 1)
  107434. * @param factor defines the start size value to affect to the specified gradient
  107435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107436. * @returns the current particle system
  107437. */
  107438. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107439. /**
  107440. * Not supported by GPUParticleSystem
  107441. * @param gradient defines the gradient to remove
  107442. * @returns the current particle system
  107443. */
  107444. removeStartSizeGradient(gradient: number): IParticleSystem;
  107445. /**
  107446. * Not supported by GPUParticleSystem
  107447. * @param gradient defines the gradient to use (between 0 and 1)
  107448. * @param min defines the color remap minimal range
  107449. * @param max defines the color remap maximal range
  107450. * @returns the current particle system
  107451. */
  107452. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107453. /**
  107454. * Not supported by GPUParticleSystem
  107455. * @param gradient defines the gradient to remove
  107456. * @returns the current particle system
  107457. */
  107458. removeColorRemapGradient(): IParticleSystem;
  107459. /**
  107460. * Not supported by GPUParticleSystem
  107461. * @param gradient defines the gradient to use (between 0 and 1)
  107462. * @param min defines the alpha remap minimal range
  107463. * @param max defines the alpha remap maximal range
  107464. * @returns the current particle system
  107465. */
  107466. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107467. /**
  107468. * Not supported by GPUParticleSystem
  107469. * @param gradient defines the gradient to remove
  107470. * @returns the current particle system
  107471. */
  107472. removeAlphaRemapGradient(): IParticleSystem;
  107473. /**
  107474. * Not supported by GPUParticleSystem
  107475. * @param gradient defines the gradient to use (between 0 and 1)
  107476. * @param color defines the color to affect to the specified gradient
  107477. * @returns the current particle system
  107478. */
  107479. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107480. /**
  107481. * Not supported by GPUParticleSystem
  107482. * @param gradient defines the gradient to remove
  107483. * @returns the current particle system
  107484. */
  107485. removeRampGradient(): IParticleSystem;
  107486. /**
  107487. * Not supported by GPUParticleSystem
  107488. * @returns the list of ramp gradients
  107489. */
  107490. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107491. /**
  107492. * Not supported by GPUParticleSystem
  107493. * Gets or sets a boolean indicating that ramp gradients must be used
  107494. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107495. */
  107496. useRampGradients: boolean;
  107497. /**
  107498. * Not supported by GPUParticleSystem
  107499. * @param gradient defines the gradient to use (between 0 and 1)
  107500. * @param factor defines the life time factor to affect to the specified gradient
  107501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107502. * @returns the current particle system
  107503. */
  107504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107505. /**
  107506. * Not supported by GPUParticleSystem
  107507. * @param gradient defines the gradient to remove
  107508. * @returns the current particle system
  107509. */
  107510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107511. /**
  107512. * Instantiates a GPU particle system.
  107513. * 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.
  107514. * @param name The name of the particle system
  107515. * @param options The options used to create the system
  107516. * @param scene The scene the particle system belongs to
  107517. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107518. */
  107519. constructor(name: string, options: Partial<{
  107520. capacity: number;
  107521. randomTextureSize: number;
  107522. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107523. protected _reset(): void;
  107524. private _createUpdateVAO;
  107525. private _createRenderVAO;
  107526. private _initialize;
  107527. /** @hidden */
  107528. _recreateUpdateEffect(): void;
  107529. /** @hidden */
  107530. _recreateRenderEffect(): void;
  107531. /**
  107532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107533. * @param preWarm defines if we are in the pre-warmimg phase
  107534. */
  107535. animate(preWarm?: boolean): void;
  107536. private _createFactorGradientTexture;
  107537. private _createSizeGradientTexture;
  107538. private _createAngularSpeedGradientTexture;
  107539. private _createVelocityGradientTexture;
  107540. private _createLimitVelocityGradientTexture;
  107541. private _createDragGradientTexture;
  107542. private _createColorGradientTexture;
  107543. /**
  107544. * Renders the particle system in its current state
  107545. * @param preWarm defines if the system should only update the particles but not render them
  107546. * @returns the current number of particles
  107547. */
  107548. render(preWarm?: boolean): number;
  107549. /**
  107550. * Rebuilds the particle system
  107551. */
  107552. rebuild(): void;
  107553. private _releaseBuffers;
  107554. private _releaseVAOs;
  107555. /**
  107556. * Disposes the particle system and free the associated resources
  107557. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107558. */
  107559. dispose(disposeTexture?: boolean): void;
  107560. /**
  107561. * Clones the particle system.
  107562. * @param name The name of the cloned object
  107563. * @param newEmitter The new emitter to use
  107564. * @returns the cloned particle system
  107565. */
  107566. clone(name: string, newEmitter: any): GPUParticleSystem;
  107567. /**
  107568. * Serializes the particle system to a JSON object.
  107569. * @returns the JSON object
  107570. */
  107571. serialize(): any;
  107572. /**
  107573. * Parses a JSON object to create a GPU particle system.
  107574. * @param parsedParticleSystem The JSON object to parse
  107575. * @param scene The scene to create the particle system in
  107576. * @param rootUrl The root url to use to load external dependencies like texture
  107577. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107578. * @returns the parsed GPU particle system
  107579. */
  107580. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107581. }
  107582. }
  107583. declare module BABYLON {
  107584. /**
  107585. * Represents a set of particle systems working together to create a specific effect
  107586. */
  107587. export class ParticleSystemSet implements IDisposable {
  107588. private _emitterCreationOptions;
  107589. private _emitterNode;
  107590. /**
  107591. * Gets the particle system list
  107592. */
  107593. systems: IParticleSystem[];
  107594. /**
  107595. * Gets the emitter node used with this set
  107596. */
  107597. readonly emitterNode: Nullable<TransformNode>;
  107598. /**
  107599. * Creates a new emitter mesh as a sphere
  107600. * @param options defines the options used to create the sphere
  107601. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107602. * @param scene defines the hosting scene
  107603. */
  107604. setEmitterAsSphere(options: {
  107605. diameter: number;
  107606. segments: number;
  107607. color: Color3;
  107608. }, renderingGroupId: number, scene: Scene): void;
  107609. /**
  107610. * Starts all particle systems of the set
  107611. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107612. */
  107613. start(emitter?: AbstractMesh): void;
  107614. /**
  107615. * Release all associated resources
  107616. */
  107617. dispose(): void;
  107618. /**
  107619. * Serialize the set into a JSON compatible object
  107620. * @returns a JSON compatible representation of the set
  107621. */
  107622. serialize(): any;
  107623. /**
  107624. * Parse a new ParticleSystemSet from a serialized source
  107625. * @param data defines a JSON compatible representation of the set
  107626. * @param scene defines the hosting scene
  107627. * @param gpu defines if we want GPU particles or CPU particles
  107628. * @returns a new ParticleSystemSet
  107629. */
  107630. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107631. }
  107632. }
  107633. declare module BABYLON {
  107634. /**
  107635. * This class is made for on one-liner static method to help creating particle system set.
  107636. */
  107637. export class ParticleHelper {
  107638. /**
  107639. * Gets or sets base Assets URL
  107640. */
  107641. static BaseAssetsUrl: string;
  107642. /**
  107643. * Create a default particle system that you can tweak
  107644. * @param emitter defines the emitter to use
  107645. * @param capacity defines the system capacity (default is 500 particles)
  107646. * @param scene defines the hosting scene
  107647. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107648. * @returns the new Particle system
  107649. */
  107650. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107651. /**
  107652. * This is the main static method (one-liner) of this helper to create different particle systems
  107653. * @param type This string represents the type to the particle system to create
  107654. * @param scene The scene where the particle system should live
  107655. * @param gpu If the system will use gpu
  107656. * @returns the ParticleSystemSet created
  107657. */
  107658. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107659. /**
  107660. * Static function used to export a particle system to a ParticleSystemSet variable.
  107661. * Please note that the emitter shape is not exported
  107662. * @param systems defines the particle systems to export
  107663. * @returns the created particle system set
  107664. */
  107665. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107666. }
  107667. }
  107668. declare module BABYLON {
  107669. interface Engine {
  107670. /**
  107671. * Create an effect to use with particle systems.
  107672. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107673. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107674. * @param uniformsNames defines a list of attribute names
  107675. * @param samplers defines an array of string used to represent textures
  107676. * @param defines defines the string containing the defines to use to compile the shaders
  107677. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107678. * @param onCompiled defines a function to call when the effect creation is successful
  107679. * @param onError defines a function to call when the effect creation has failed
  107680. * @returns the new Effect
  107681. */
  107682. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107683. }
  107684. interface Mesh {
  107685. /**
  107686. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107687. * @returns an array of IParticleSystem
  107688. */
  107689. getEmittedParticleSystems(): IParticleSystem[];
  107690. /**
  107691. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107692. * @returns an array of IParticleSystem
  107693. */
  107694. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107695. }
  107696. /**
  107697. * @hidden
  107698. */
  107699. export var _IDoNeedToBeInTheBuild: number;
  107700. }
  107701. declare module BABYLON {
  107702. interface Scene {
  107703. /** @hidden (Backing field) */
  107704. _physicsEngine: Nullable<IPhysicsEngine>;
  107705. /**
  107706. * Gets the current physics engine
  107707. * @returns a IPhysicsEngine or null if none attached
  107708. */
  107709. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107710. /**
  107711. * Enables physics to the current scene
  107712. * @param gravity defines the scene's gravity for the physics engine
  107713. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107714. * @return a boolean indicating if the physics engine was initialized
  107715. */
  107716. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107717. /**
  107718. * Disables and disposes the physics engine associated with the scene
  107719. */
  107720. disablePhysicsEngine(): void;
  107721. /**
  107722. * Gets a boolean indicating if there is an active physics engine
  107723. * @returns a boolean indicating if there is an active physics engine
  107724. */
  107725. isPhysicsEnabled(): boolean;
  107726. /**
  107727. * Deletes a physics compound impostor
  107728. * @param compound defines the compound to delete
  107729. */
  107730. deleteCompoundImpostor(compound: any): void;
  107731. /**
  107732. * An event triggered when physic simulation is about to be run
  107733. */
  107734. onBeforePhysicsObservable: Observable<Scene>;
  107735. /**
  107736. * An event triggered when physic simulation has been done
  107737. */
  107738. onAfterPhysicsObservable: Observable<Scene>;
  107739. }
  107740. interface AbstractMesh {
  107741. /** @hidden */
  107742. _physicsImpostor: Nullable<PhysicsImpostor>;
  107743. /**
  107744. * Gets or sets impostor used for physic simulation
  107745. * @see http://doc.babylonjs.com/features/physics_engine
  107746. */
  107747. physicsImpostor: Nullable<PhysicsImpostor>;
  107748. /**
  107749. * Gets the current physics impostor
  107750. * @see http://doc.babylonjs.com/features/physics_engine
  107751. * @returns a physics impostor or null
  107752. */
  107753. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107754. /** Apply a physic impulse to the mesh
  107755. * @param force defines the force to apply
  107756. * @param contactPoint defines where to apply the force
  107757. * @returns the current mesh
  107758. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107759. */
  107760. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107761. /**
  107762. * Creates a physic joint between two meshes
  107763. * @param otherMesh defines the other mesh to use
  107764. * @param pivot1 defines the pivot to use on this mesh
  107765. * @param pivot2 defines the pivot to use on the other mesh
  107766. * @param options defines additional options (can be plugin dependent)
  107767. * @returns the current mesh
  107768. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107769. */
  107770. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107771. /** @hidden */
  107772. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107773. }
  107774. /**
  107775. * Defines the physics engine scene component responsible to manage a physics engine
  107776. */
  107777. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107778. /**
  107779. * The component name helpful to identify the component in the list of scene components.
  107780. */
  107781. readonly name: string;
  107782. /**
  107783. * The scene the component belongs to.
  107784. */
  107785. scene: Scene;
  107786. /**
  107787. * Creates a new instance of the component for the given scene
  107788. * @param scene Defines the scene to register the component in
  107789. */
  107790. constructor(scene: Scene);
  107791. /**
  107792. * Registers the component in a given scene
  107793. */
  107794. register(): void;
  107795. /**
  107796. * Rebuilds the elements related to this component in case of
  107797. * context lost for instance.
  107798. */
  107799. rebuild(): void;
  107800. /**
  107801. * Disposes the component and the associated ressources
  107802. */
  107803. dispose(): void;
  107804. }
  107805. }
  107806. declare module BABYLON {
  107807. /**
  107808. * A helper for physics simulations
  107809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107810. */
  107811. export class PhysicsHelper {
  107812. private _scene;
  107813. private _physicsEngine;
  107814. /**
  107815. * Initializes the Physics helper
  107816. * @param scene Babylon.js scene
  107817. */
  107818. constructor(scene: Scene);
  107819. /**
  107820. * Applies a radial explosion impulse
  107821. * @param origin the origin of the explosion
  107822. * @param radius the explosion radius
  107823. * @param strength the explosion strength
  107824. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107825. * @returns A physics radial explosion event, or null
  107826. */
  107827. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107828. /**
  107829. * Applies a radial explosion force
  107830. * @param origin the origin of the explosion
  107831. * @param radius the explosion radius
  107832. * @param strength the explosion strength
  107833. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107834. * @returns A physics radial explosion event, or null
  107835. */
  107836. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107837. /**
  107838. * Creates a gravitational field
  107839. * @param origin the origin of the explosion
  107840. * @param radius the explosion radius
  107841. * @param strength the explosion strength
  107842. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107843. * @returns A physics gravitational field event, or null
  107844. */
  107845. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107846. /**
  107847. * Creates a physics updraft event
  107848. * @param origin the origin of the updraft
  107849. * @param radius the radius of the updraft
  107850. * @param strength the strength of the updraft
  107851. * @param height the height of the updraft
  107852. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107853. * @returns A physics updraft event, or null
  107854. */
  107855. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107856. /**
  107857. * Creates a physics vortex event
  107858. * @param origin the of the vortex
  107859. * @param radius the radius of the vortex
  107860. * @param strength the strength of the vortex
  107861. * @param height the height of the vortex
  107862. * @returns a Physics vortex event, or null
  107863. * A physics vortex event or null
  107864. */
  107865. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107866. }
  107867. /**
  107868. * Represents a physics radial explosion event
  107869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107870. */
  107871. export class PhysicsRadialExplosionEvent {
  107872. private _scene;
  107873. private _sphere;
  107874. private _sphereOptions;
  107875. private _rays;
  107876. private _dataFetched;
  107877. /**
  107878. * Initializes a radial explosioin event
  107879. * @param scene BabylonJS scene
  107880. */
  107881. constructor(scene: Scene);
  107882. /**
  107883. * Returns the data related to the radial explosion event (sphere & rays).
  107884. * @returns The radial explosion event data
  107885. */
  107886. getData(): PhysicsRadialExplosionEventData;
  107887. /**
  107888. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107889. * @param impostor A physics imposter
  107890. * @param origin the origin of the explosion
  107891. * @param radius the explosion radius
  107892. * @param strength the explosion strength
  107893. * @param falloff possible options: Constant & Linear
  107894. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107895. */
  107896. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107897. /**
  107898. * Disposes the sphere.
  107899. * @param force Specifies if the sphere should be disposed by force
  107900. */
  107901. dispose(force?: boolean): void;
  107902. /*** Helpers ***/
  107903. private _prepareSphere;
  107904. private _intersectsWithSphere;
  107905. }
  107906. /**
  107907. * Represents a gravitational field event
  107908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107909. */
  107910. export class PhysicsGravitationalFieldEvent {
  107911. private _physicsHelper;
  107912. private _scene;
  107913. private _origin;
  107914. private _radius;
  107915. private _strength;
  107916. private _falloff;
  107917. private _tickCallback;
  107918. private _sphere;
  107919. private _dataFetched;
  107920. /**
  107921. * Initializes the physics gravitational field event
  107922. * @param physicsHelper A physics helper
  107923. * @param scene BabylonJS scene
  107924. * @param origin The origin position of the gravitational field event
  107925. * @param radius The radius of the gravitational field event
  107926. * @param strength The strength of the gravitational field event
  107927. * @param falloff The falloff for the gravitational field event
  107928. */
  107929. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107930. /**
  107931. * Returns the data related to the gravitational field event (sphere).
  107932. * @returns A gravitational field event
  107933. */
  107934. getData(): PhysicsGravitationalFieldEventData;
  107935. /**
  107936. * Enables the gravitational field.
  107937. */
  107938. enable(): void;
  107939. /**
  107940. * Disables the gravitational field.
  107941. */
  107942. disable(): void;
  107943. /**
  107944. * Disposes the sphere.
  107945. * @param force The force to dispose from the gravitational field event
  107946. */
  107947. dispose(force?: boolean): void;
  107948. private _tick;
  107949. }
  107950. /**
  107951. * Represents a physics updraft event
  107952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107953. */
  107954. export class PhysicsUpdraftEvent {
  107955. private _scene;
  107956. private _origin;
  107957. private _radius;
  107958. private _strength;
  107959. private _height;
  107960. private _updraftMode;
  107961. private _physicsEngine;
  107962. private _originTop;
  107963. private _originDirection;
  107964. private _tickCallback;
  107965. private _cylinder;
  107966. private _cylinderPosition;
  107967. private _dataFetched;
  107968. /**
  107969. * Initializes the physics updraft event
  107970. * @param _scene BabylonJS scene
  107971. * @param _origin The origin position of the updraft
  107972. * @param _radius The radius of the updraft
  107973. * @param _strength The strength of the updraft
  107974. * @param _height The height of the updraft
  107975. * @param _updraftMode The mode of the updraft
  107976. */
  107977. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107978. /**
  107979. * Returns the data related to the updraft event (cylinder).
  107980. * @returns A physics updraft event
  107981. */
  107982. getData(): PhysicsUpdraftEventData;
  107983. /**
  107984. * Enables the updraft.
  107985. */
  107986. enable(): void;
  107987. /**
  107988. * Disables the cortex.
  107989. */
  107990. disable(): void;
  107991. /**
  107992. * Disposes the sphere.
  107993. * @param force Specifies if the updraft should be disposed by force
  107994. */
  107995. dispose(force?: boolean): void;
  107996. private getImpostorForceAndContactPoint;
  107997. private _tick;
  107998. /*** Helpers ***/
  107999. private _prepareCylinder;
  108000. private _intersectsWithCylinder;
  108001. }
  108002. /**
  108003. * Represents a physics vortex event
  108004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108005. */
  108006. export class PhysicsVortexEvent {
  108007. private _scene;
  108008. private _origin;
  108009. private _radius;
  108010. private _strength;
  108011. private _height;
  108012. private _physicsEngine;
  108013. private _originTop;
  108014. private _centripetalForceThreshold;
  108015. private _updraftMultiplier;
  108016. private _tickCallback;
  108017. private _cylinder;
  108018. private _cylinderPosition;
  108019. private _dataFetched;
  108020. /**
  108021. * Initializes the physics vortex event
  108022. * @param _scene The BabylonJS scene
  108023. * @param _origin The origin position of the vortex
  108024. * @param _radius The radius of the vortex
  108025. * @param _strength The strength of the vortex
  108026. * @param _height The height of the vortex
  108027. */
  108028. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  108029. /**
  108030. * Returns the data related to the vortex event (cylinder).
  108031. * @returns The physics vortex event data
  108032. */
  108033. getData(): PhysicsVortexEventData;
  108034. /**
  108035. * Enables the vortex.
  108036. */
  108037. enable(): void;
  108038. /**
  108039. * Disables the cortex.
  108040. */
  108041. disable(): void;
  108042. /**
  108043. * Disposes the sphere.
  108044. * @param force
  108045. */
  108046. dispose(force?: boolean): void;
  108047. private getImpostorForceAndContactPoint;
  108048. private _tick;
  108049. /*** Helpers ***/
  108050. private _prepareCylinder;
  108051. private _intersectsWithCylinder;
  108052. }
  108053. /**
  108054. * The strenght of the force in correspondence to the distance of the affected object
  108055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108056. */
  108057. export enum PhysicsRadialImpulseFalloff {
  108058. /** Defines that impulse is constant in strength across it's whole radius */
  108059. Constant = 0,
  108060. /** DEfines that impulse gets weaker if it's further from the origin */
  108061. Linear = 1
  108062. }
  108063. /**
  108064. * The strength of the force in correspondence to the distance of the affected object
  108065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108066. */
  108067. export enum PhysicsUpdraftMode {
  108068. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  108069. Center = 0,
  108070. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  108071. Perpendicular = 1
  108072. }
  108073. /**
  108074. * Interface for a physics force and contact point
  108075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108076. */
  108077. export interface PhysicsForceAndContactPoint {
  108078. /**
  108079. * The force applied at the contact point
  108080. */
  108081. force: Vector3;
  108082. /**
  108083. * The contact point
  108084. */
  108085. contactPoint: Vector3;
  108086. }
  108087. /**
  108088. * Interface for radial explosion event data
  108089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108090. */
  108091. export interface PhysicsRadialExplosionEventData {
  108092. /**
  108093. * A sphere used for the radial explosion event
  108094. */
  108095. sphere: Mesh;
  108096. /**
  108097. * An array of rays for the radial explosion event
  108098. */
  108099. rays: Array<Ray>;
  108100. }
  108101. /**
  108102. * Interface for gravitational field event data
  108103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108104. */
  108105. export interface PhysicsGravitationalFieldEventData {
  108106. /**
  108107. * A sphere mesh used for the gravitational field event
  108108. */
  108109. sphere: Mesh;
  108110. }
  108111. /**
  108112. * Interface for updraft event data
  108113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108114. */
  108115. export interface PhysicsUpdraftEventData {
  108116. /**
  108117. * A cylinder used for the updraft event
  108118. */
  108119. cylinder: Mesh;
  108120. }
  108121. /**
  108122. * Interface for vortex event data
  108123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108124. */
  108125. export interface PhysicsVortexEventData {
  108126. /**
  108127. * A cylinder used for the vortex event
  108128. */
  108129. cylinder: Mesh;
  108130. }
  108131. }
  108132. declare module BABYLON {
  108133. /**
  108134. * AmmoJS Physics plugin
  108135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108136. * @see https://github.com/kripken/ammo.js/
  108137. */
  108138. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108139. private _useDeltaForWorldStep;
  108140. /**
  108141. * Reference to the Ammo library
  108142. */
  108143. bjsAMMO: any;
  108144. /**
  108145. * Created ammoJS world which physics bodies are added to
  108146. */
  108147. world: any;
  108148. /**
  108149. * Name of the plugin
  108150. */
  108151. name: string;
  108152. private _timeStep;
  108153. private _fixedTimeStep;
  108154. private _maxSteps;
  108155. private _tmpQuaternion;
  108156. private _tmpAmmoTransform;
  108157. private _tmpAmmoQuaternion;
  108158. private _tmpAmmoConcreteContactResultCallback;
  108159. private _collisionConfiguration;
  108160. private _dispatcher;
  108161. private _overlappingPairCache;
  108162. private _solver;
  108163. private _tmpAmmoVectorA;
  108164. private _tmpAmmoVectorB;
  108165. private _tmpAmmoVectorC;
  108166. private _tmpContactCallbackResult;
  108167. private static readonly DISABLE_COLLISION_FLAG;
  108168. private static readonly KINEMATIC_FLAG;
  108169. private static readonly DISABLE_DEACTIVATION_FLAG;
  108170. /**
  108171. * Initializes the ammoJS plugin
  108172. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108173. * @param ammoInjection can be used to inject your own ammo reference
  108174. */
  108175. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108176. /**
  108177. * Sets the gravity of the physics world (m/(s^2))
  108178. * @param gravity Gravity to set
  108179. */
  108180. setGravity(gravity: Vector3): void;
  108181. /**
  108182. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108183. * @param timeStep timestep to use in seconds
  108184. */
  108185. setTimeStep(timeStep: number): void;
  108186. /**
  108187. * 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)
  108188. * @param fixedTimeStep fixedTimeStep to use in seconds
  108189. */
  108190. setFixedTimeStep(fixedTimeStep: number): void;
  108191. /**
  108192. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108193. * @param maxSteps the maximum number of steps by the physics engine per frame
  108194. */
  108195. setMaxSteps(maxSteps: number): void;
  108196. /**
  108197. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108198. * @returns the current timestep in seconds
  108199. */
  108200. getTimeStep(): number;
  108201. private _isImpostorInContact;
  108202. private _isImpostorPairInContact;
  108203. private _stepSimulation;
  108204. /**
  108205. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108206. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108207. * After the step the babylon meshes are set to the position of the physics imposters
  108208. * @param delta amount of time to step forward
  108209. * @param impostors array of imposters to update before/after the step
  108210. */
  108211. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108212. private _tmpVector;
  108213. private _tmpMatrix;
  108214. /**
  108215. * Applies an implulse on the imposter
  108216. * @param impostor imposter to apply impulse
  108217. * @param force amount of force to be applied to the imposter
  108218. * @param contactPoint the location to apply the impulse on the imposter
  108219. */
  108220. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108221. /**
  108222. * Applies a force on the imposter
  108223. * @param impostor imposter to apply force
  108224. * @param force amount of force to be applied to the imposter
  108225. * @param contactPoint the location to apply the force on the imposter
  108226. */
  108227. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108228. /**
  108229. * Creates a physics body using the plugin
  108230. * @param impostor the imposter to create the physics body on
  108231. */
  108232. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108233. /**
  108234. * Removes the physics body from the imposter and disposes of the body's memory
  108235. * @param impostor imposter to remove the physics body from
  108236. */
  108237. removePhysicsBody(impostor: PhysicsImpostor): void;
  108238. /**
  108239. * Generates a joint
  108240. * @param impostorJoint the imposter joint to create the joint with
  108241. */
  108242. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108243. /**
  108244. * Removes a joint
  108245. * @param impostorJoint the imposter joint to remove the joint from
  108246. */
  108247. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108248. private _addMeshVerts;
  108249. private _createShape;
  108250. /**
  108251. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108252. * @param impostor imposter containing the physics body and babylon object
  108253. */
  108254. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108255. /**
  108256. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108257. * @param impostor imposter containing the physics body and babylon object
  108258. * @param newPosition new position
  108259. * @param newRotation new rotation
  108260. */
  108261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108262. /**
  108263. * If this plugin is supported
  108264. * @returns true if its supported
  108265. */
  108266. isSupported(): boolean;
  108267. /**
  108268. * Sets the linear velocity of the physics body
  108269. * @param impostor imposter to set the velocity on
  108270. * @param velocity velocity to set
  108271. */
  108272. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108273. /**
  108274. * Sets the angular velocity of the physics body
  108275. * @param impostor imposter to set the velocity on
  108276. * @param velocity velocity to set
  108277. */
  108278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108279. /**
  108280. * gets the linear velocity
  108281. * @param impostor imposter to get linear velocity from
  108282. * @returns linear velocity
  108283. */
  108284. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108285. /**
  108286. * gets the angular velocity
  108287. * @param impostor imposter to get angular velocity from
  108288. * @returns angular velocity
  108289. */
  108290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108291. /**
  108292. * Sets the mass of physics body
  108293. * @param impostor imposter to set the mass on
  108294. * @param mass mass to set
  108295. */
  108296. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108297. /**
  108298. * Gets the mass of the physics body
  108299. * @param impostor imposter to get the mass from
  108300. * @returns mass
  108301. */
  108302. getBodyMass(impostor: PhysicsImpostor): number;
  108303. /**
  108304. * Gets friction of the impostor
  108305. * @param impostor impostor to get friction from
  108306. * @returns friction value
  108307. */
  108308. getBodyFriction(impostor: PhysicsImpostor): number;
  108309. /**
  108310. * Sets friction of the impostor
  108311. * @param impostor impostor to set friction on
  108312. * @param friction friction value
  108313. */
  108314. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108315. /**
  108316. * Gets restitution of the impostor
  108317. * @param impostor impostor to get restitution from
  108318. * @returns restitution value
  108319. */
  108320. getBodyRestitution(impostor: PhysicsImpostor): number;
  108321. /**
  108322. * Sets resitution of the impostor
  108323. * @param impostor impostor to set resitution on
  108324. * @param restitution resitution value
  108325. */
  108326. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108327. /**
  108328. * Sleeps the physics body and stops it from being active
  108329. * @param impostor impostor to sleep
  108330. */
  108331. sleepBody(impostor: PhysicsImpostor): void;
  108332. /**
  108333. * Activates the physics body
  108334. * @param impostor impostor to activate
  108335. */
  108336. wakeUpBody(impostor: PhysicsImpostor): void;
  108337. /**
  108338. * Updates the distance parameters of the joint
  108339. * @param joint joint to update
  108340. * @param maxDistance maximum distance of the joint
  108341. * @param minDistance minimum distance of the joint
  108342. */
  108343. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108344. /**
  108345. * Sets a motor on the joint
  108346. * @param joint joint to set motor on
  108347. * @param speed speed of the motor
  108348. * @param maxForce maximum force of the motor
  108349. * @param motorIndex index of the motor
  108350. */
  108351. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108352. /**
  108353. * Sets the motors limit
  108354. * @param joint joint to set limit on
  108355. * @param upperLimit upper limit
  108356. * @param lowerLimit lower limit
  108357. */
  108358. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108359. /**
  108360. * Syncs the position and rotation of a mesh with the impostor
  108361. * @param mesh mesh to sync
  108362. * @param impostor impostor to update the mesh with
  108363. */
  108364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108365. /**
  108366. * Gets the radius of the impostor
  108367. * @param impostor impostor to get radius from
  108368. * @returns the radius
  108369. */
  108370. getRadius(impostor: PhysicsImpostor): number;
  108371. /**
  108372. * Gets the box size of the impostor
  108373. * @param impostor impostor to get box size from
  108374. * @param result the resulting box size
  108375. */
  108376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108377. /**
  108378. * Disposes of the impostor
  108379. */
  108380. dispose(): void;
  108381. }
  108382. }
  108383. declare module BABYLON {
  108384. /** @hidden */
  108385. export var blackAndWhitePixelShader: {
  108386. name: string;
  108387. shader: string;
  108388. };
  108389. }
  108390. declare module BABYLON {
  108391. /**
  108392. * Post process used to render in black and white
  108393. */
  108394. export class BlackAndWhitePostProcess extends PostProcess {
  108395. /**
  108396. * Linear about to convert he result to black and white (default: 1)
  108397. */
  108398. degree: number;
  108399. /**
  108400. * Creates a black and white post process
  108401. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  108402. * @param name The name of the effect.
  108403. * @param options The required width/height ratio to downsize to before computing the render pass.
  108404. * @param camera The camera to apply the render pass to.
  108405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108406. * @param engine The engine which the post process will be applied. (default: current engine)
  108407. * @param reusable If the post process can be reused on the same frame. (default: false)
  108408. */
  108409. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108410. }
  108411. }
  108412. declare module BABYLON {
  108413. /**
  108414. * This represents a set of one or more post processes in Babylon.
  108415. * A post process can be used to apply a shader to a texture after it is rendered.
  108416. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108417. */
  108418. export class PostProcessRenderEffect {
  108419. private _postProcesses;
  108420. private _getPostProcesses;
  108421. private _singleInstance;
  108422. private _cameras;
  108423. private _indicesForCamera;
  108424. /**
  108425. * Name of the effect
  108426. * @hidden
  108427. */
  108428. _name: string;
  108429. /**
  108430. * Instantiates a post process render effect.
  108431. * A post process can be used to apply a shader to a texture after it is rendered.
  108432. * @param engine The engine the effect is tied to
  108433. * @param name The name of the effect
  108434. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108435. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108436. */
  108437. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108438. /**
  108439. * Checks if all the post processes in the effect are supported.
  108440. */
  108441. readonly isSupported: boolean;
  108442. /**
  108443. * Updates the current state of the effect
  108444. * @hidden
  108445. */
  108446. _update(): void;
  108447. /**
  108448. * Attaches the effect on cameras
  108449. * @param cameras The camera to attach to.
  108450. * @hidden
  108451. */
  108452. _attachCameras(cameras: Camera): void;
  108453. /**
  108454. * Attaches the effect on cameras
  108455. * @param cameras The camera to attach to.
  108456. * @hidden
  108457. */
  108458. _attachCameras(cameras: Camera[]): void;
  108459. /**
  108460. * Detatches the effect on cameras
  108461. * @param cameras The camera to detatch from.
  108462. * @hidden
  108463. */
  108464. _detachCameras(cameras: Camera): void;
  108465. /**
  108466. * Detatches the effect on cameras
  108467. * @param cameras The camera to detatch from.
  108468. * @hidden
  108469. */
  108470. _detachCameras(cameras: Camera[]): void;
  108471. /**
  108472. * Enables the effect on given cameras
  108473. * @param cameras The camera to enable.
  108474. * @hidden
  108475. */
  108476. _enable(cameras: Camera): void;
  108477. /**
  108478. * Enables the effect on given cameras
  108479. * @param cameras The camera to enable.
  108480. * @hidden
  108481. */
  108482. _enable(cameras: Nullable<Camera[]>): void;
  108483. /**
  108484. * Disables the effect on the given cameras
  108485. * @param cameras The camera to disable.
  108486. * @hidden
  108487. */
  108488. _disable(cameras: Camera): void;
  108489. /**
  108490. * Disables the effect on the given cameras
  108491. * @param cameras The camera to disable.
  108492. * @hidden
  108493. */
  108494. _disable(cameras: Nullable<Camera[]>): void;
  108495. /**
  108496. * Gets a list of the post processes contained in the effect.
  108497. * @param camera The camera to get the post processes on.
  108498. * @returns The list of the post processes in the effect.
  108499. */
  108500. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108501. }
  108502. }
  108503. declare module BABYLON {
  108504. /** @hidden */
  108505. export var extractHighlightsPixelShader: {
  108506. name: string;
  108507. shader: string;
  108508. };
  108509. }
  108510. declare module BABYLON {
  108511. /**
  108512. * 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.
  108513. */
  108514. export class ExtractHighlightsPostProcess extends PostProcess {
  108515. /**
  108516. * The luminance threshold, pixels below this value will be set to black.
  108517. */
  108518. threshold: number;
  108519. /** @hidden */
  108520. _exposure: number;
  108521. /**
  108522. * Post process which has the input texture to be used when performing highlight extraction
  108523. * @hidden
  108524. */
  108525. _inputPostProcess: Nullable<PostProcess>;
  108526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /** @hidden */
  108531. export var bloomMergePixelShader: {
  108532. name: string;
  108533. shader: string;
  108534. };
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108539. */
  108540. export class BloomMergePostProcess extends PostProcess {
  108541. /** Weight of the bloom to be added to the original input. */
  108542. weight: number;
  108543. /**
  108544. * Creates a new instance of @see BloomMergePostProcess
  108545. * @param name The name of the effect.
  108546. * @param originalFromInput Post process which's input will be used for the merge.
  108547. * @param blurred Blurred highlights post process which's output will be used.
  108548. * @param weight Weight of the bloom to be added to the original input.
  108549. * @param options The required width/height ratio to downsize to before computing the render pass.
  108550. * @param camera The camera to apply the render pass to.
  108551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108552. * @param engine The engine which the post process will be applied. (default: current engine)
  108553. * @param reusable If the post process can be reused on the same frame. (default: false)
  108554. * @param textureType Type of textures used when performing the post process. (default: 0)
  108555. * @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)
  108556. */
  108557. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108558. /** Weight of the bloom to be added to the original input. */
  108559. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108560. }
  108561. }
  108562. declare module BABYLON {
  108563. /**
  108564. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108565. */
  108566. export class BloomEffect extends PostProcessRenderEffect {
  108567. private bloomScale;
  108568. /**
  108569. * @hidden Internal
  108570. */
  108571. _effects: Array<PostProcess>;
  108572. /**
  108573. * @hidden Internal
  108574. */
  108575. _downscale: ExtractHighlightsPostProcess;
  108576. private _blurX;
  108577. private _blurY;
  108578. private _merge;
  108579. /**
  108580. * The luminance threshold to find bright areas of the image to bloom.
  108581. */
  108582. threshold: number;
  108583. /**
  108584. * The strength of the bloom.
  108585. */
  108586. weight: number;
  108587. /**
  108588. * Specifies the size of the bloom blur kernel, relative to the final output size
  108589. */
  108590. kernel: number;
  108591. /**
  108592. * Creates a new instance of @see BloomEffect
  108593. * @param scene The scene the effect belongs to.
  108594. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108595. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108596. * @param bloomWeight The the strength of bloom.
  108597. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108598. * @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)
  108599. */
  108600. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108601. /**
  108602. * Disposes each of the internal effects for a given camera.
  108603. * @param camera The camera to dispose the effect on.
  108604. */
  108605. disposeEffects(camera: Camera): void;
  108606. /**
  108607. * @hidden Internal
  108608. */
  108609. _updateEffects(): void;
  108610. /**
  108611. * Internal
  108612. * @returns if all the contained post processes are ready.
  108613. * @hidden
  108614. */
  108615. _isReady(): boolean;
  108616. }
  108617. }
  108618. declare module BABYLON {
  108619. /** @hidden */
  108620. export var chromaticAberrationPixelShader: {
  108621. name: string;
  108622. shader: string;
  108623. };
  108624. }
  108625. declare module BABYLON {
  108626. /**
  108627. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108628. */
  108629. export class ChromaticAberrationPostProcess extends PostProcess {
  108630. /**
  108631. * The amount of seperation of rgb channels (default: 30)
  108632. */
  108633. aberrationAmount: number;
  108634. /**
  108635. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108636. */
  108637. radialIntensity: number;
  108638. /**
  108639. * 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))
  108640. */
  108641. direction: Vector2;
  108642. /**
  108643. * 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))
  108644. */
  108645. centerPosition: Vector2;
  108646. /**
  108647. * Creates a new instance ChromaticAberrationPostProcess
  108648. * @param name The name of the effect.
  108649. * @param screenWidth The width of the screen to apply the effect on.
  108650. * @param screenHeight The height of the screen to apply the effect on.
  108651. * @param options The required width/height ratio to downsize to before computing the render pass.
  108652. * @param camera The camera to apply the render pass to.
  108653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108654. * @param engine The engine which the post process will be applied. (default: current engine)
  108655. * @param reusable If the post process can be reused on the same frame. (default: false)
  108656. * @param textureType Type of textures used when performing the post process. (default: 0)
  108657. * @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)
  108658. */
  108659. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108660. }
  108661. }
  108662. declare module BABYLON {
  108663. /** @hidden */
  108664. export var circleOfConfusionPixelShader: {
  108665. name: string;
  108666. shader: string;
  108667. };
  108668. }
  108669. declare module BABYLON {
  108670. /**
  108671. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108672. */
  108673. export class CircleOfConfusionPostProcess extends PostProcess {
  108674. /**
  108675. * 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.
  108676. */
  108677. lensSize: number;
  108678. /**
  108679. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108680. */
  108681. fStop: number;
  108682. /**
  108683. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108684. */
  108685. focusDistance: number;
  108686. /**
  108687. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108688. */
  108689. focalLength: number;
  108690. private _depthTexture;
  108691. /**
  108692. * Creates a new instance CircleOfConfusionPostProcess
  108693. * @param name The name of the effect.
  108694. * @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.
  108695. * @param options The required width/height ratio to downsize to before computing the render pass.
  108696. * @param camera The camera to apply the render pass to.
  108697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108698. * @param engine The engine which the post process will be applied. (default: current engine)
  108699. * @param reusable If the post process can be reused on the same frame. (default: false)
  108700. * @param textureType Type of textures used when performing the post process. (default: 0)
  108701. * @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)
  108702. */
  108703. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108704. /**
  108705. * 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.
  108706. */
  108707. depthTexture: RenderTargetTexture;
  108708. }
  108709. }
  108710. declare module BABYLON {
  108711. /** @hidden */
  108712. export var colorCorrectionPixelShader: {
  108713. name: string;
  108714. shader: string;
  108715. };
  108716. }
  108717. declare module BABYLON {
  108718. /**
  108719. *
  108720. * This post-process allows the modification of rendered colors by using
  108721. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108722. *
  108723. * The object needs to be provided an url to a texture containing the color
  108724. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108725. * Use an image editing software to tweak the LUT to match your needs.
  108726. *
  108727. * For an example of a color LUT, see here:
  108728. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108729. * For explanations on color grading, see here:
  108730. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108731. *
  108732. */
  108733. export class ColorCorrectionPostProcess extends PostProcess {
  108734. private _colorTableTexture;
  108735. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108736. }
  108737. }
  108738. declare module BABYLON {
  108739. /** @hidden */
  108740. export var convolutionPixelShader: {
  108741. name: string;
  108742. shader: string;
  108743. };
  108744. }
  108745. declare module BABYLON {
  108746. /**
  108747. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108748. * input texture to perform effects such as edge detection or sharpening
  108749. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108750. */
  108751. export class ConvolutionPostProcess extends PostProcess {
  108752. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108753. kernel: number[];
  108754. /**
  108755. * Creates a new instance ConvolutionPostProcess
  108756. * @param name The name of the effect.
  108757. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108758. * @param options The required width/height ratio to downsize to before computing the render pass.
  108759. * @param camera The camera to apply the render pass to.
  108760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108761. * @param engine The engine which the post process will be applied. (default: current engine)
  108762. * @param reusable If the post process can be reused on the same frame. (default: false)
  108763. * @param textureType Type of textures used when performing the post process. (default: 0)
  108764. */
  108765. constructor(name: string,
  108766. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108767. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108768. /**
  108769. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108770. */
  108771. static EdgeDetect0Kernel: number[];
  108772. /**
  108773. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108774. */
  108775. static EdgeDetect1Kernel: number[];
  108776. /**
  108777. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108778. */
  108779. static EdgeDetect2Kernel: number[];
  108780. /**
  108781. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108782. */
  108783. static SharpenKernel: number[];
  108784. /**
  108785. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108786. */
  108787. static EmbossKernel: number[];
  108788. /**
  108789. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108790. */
  108791. static GaussianKernel: number[];
  108792. }
  108793. }
  108794. declare module BABYLON {
  108795. /**
  108796. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108797. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108798. * based on samples that have a large difference in distance than the center pixel.
  108799. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108800. */
  108801. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108802. direction: Vector2;
  108803. /**
  108804. * Creates a new instance CircleOfConfusionPostProcess
  108805. * @param name The name of the effect.
  108806. * @param scene The scene the effect belongs to.
  108807. * @param direction The direction the blur should be applied.
  108808. * @param kernel The size of the kernel used to blur.
  108809. * @param options The required width/height ratio to downsize to before computing the render pass.
  108810. * @param camera The camera to apply the render pass to.
  108811. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108812. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108814. * @param engine The engine which the post process will be applied. (default: current engine)
  108815. * @param reusable If the post process can be reused on the same frame. (default: false)
  108816. * @param textureType Type of textures used when performing the post process. (default: 0)
  108817. * @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)
  108818. */
  108819. 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);
  108820. }
  108821. }
  108822. declare module BABYLON {
  108823. /** @hidden */
  108824. export var depthOfFieldMergePixelShader: {
  108825. name: string;
  108826. shader: string;
  108827. };
  108828. }
  108829. declare module BABYLON {
  108830. /**
  108831. * Options to be set when merging outputs from the default pipeline.
  108832. */
  108833. export class DepthOfFieldMergePostProcessOptions {
  108834. /**
  108835. * The original image to merge on top of
  108836. */
  108837. originalFromInput: PostProcess;
  108838. /**
  108839. * Parameters to perform the merge of the depth of field effect
  108840. */
  108841. depthOfField?: {
  108842. circleOfConfusion: PostProcess;
  108843. blurSteps: Array<PostProcess>;
  108844. };
  108845. /**
  108846. * Parameters to perform the merge of bloom effect
  108847. */
  108848. bloom?: {
  108849. blurred: PostProcess;
  108850. weight: number;
  108851. };
  108852. }
  108853. /**
  108854. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108855. */
  108856. export class DepthOfFieldMergePostProcess extends PostProcess {
  108857. private blurSteps;
  108858. /**
  108859. * Creates a new instance of DepthOfFieldMergePostProcess
  108860. * @param name The name of the effect.
  108861. * @param originalFromInput Post process which's input will be used for the merge.
  108862. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108863. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108864. * @param options The required width/height ratio to downsize to before computing the render pass.
  108865. * @param camera The camera to apply the render pass to.
  108866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108867. * @param engine The engine which the post process will be applied. (default: current engine)
  108868. * @param reusable If the post process can be reused on the same frame. (default: false)
  108869. * @param textureType Type of textures used when performing the post process. (default: 0)
  108870. * @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)
  108871. */
  108872. 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);
  108873. /**
  108874. * Updates the effect with the current post process compile time values and recompiles the shader.
  108875. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108876. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108877. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108878. * @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
  108879. * @param onCompiled Called when the shader has been compiled.
  108880. * @param onError Called if there is an error when compiling a shader.
  108881. */
  108882. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108883. }
  108884. }
  108885. declare module BABYLON {
  108886. /**
  108887. * Specifies the level of max blur that should be applied when using the depth of field effect
  108888. */
  108889. export enum DepthOfFieldEffectBlurLevel {
  108890. /**
  108891. * Subtle blur
  108892. */
  108893. Low = 0,
  108894. /**
  108895. * Medium blur
  108896. */
  108897. Medium = 1,
  108898. /**
  108899. * Large blur
  108900. */
  108901. High = 2
  108902. }
  108903. /**
  108904. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108905. */
  108906. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108907. private _circleOfConfusion;
  108908. /**
  108909. * @hidden Internal, blurs from high to low
  108910. */
  108911. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108912. private _depthOfFieldBlurY;
  108913. private _dofMerge;
  108914. /**
  108915. * @hidden Internal post processes in depth of field effect
  108916. */
  108917. _effects: Array<PostProcess>;
  108918. /**
  108919. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108920. */
  108921. focalLength: number;
  108922. /**
  108923. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108924. */
  108925. fStop: number;
  108926. /**
  108927. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108928. */
  108929. focusDistance: number;
  108930. /**
  108931. * 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.
  108932. */
  108933. lensSize: number;
  108934. /**
  108935. * Creates a new instance DepthOfFieldEffect
  108936. * @param scene The scene the effect belongs to.
  108937. * @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.
  108938. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108939. * @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)
  108940. */
  108941. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108942. /**
  108943. * 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.
  108944. */
  108945. depthTexture: RenderTargetTexture;
  108946. /**
  108947. * Disposes each of the internal effects for a given camera.
  108948. * @param camera The camera to dispose the effect on.
  108949. */
  108950. disposeEffects(camera: Camera): void;
  108951. /**
  108952. * @hidden Internal
  108953. */
  108954. _updateEffects(): void;
  108955. /**
  108956. * Internal
  108957. * @returns if all the contained post processes are ready.
  108958. * @hidden
  108959. */
  108960. _isReady(): boolean;
  108961. }
  108962. }
  108963. declare module BABYLON {
  108964. /** @hidden */
  108965. export var displayPassPixelShader: {
  108966. name: string;
  108967. shader: string;
  108968. };
  108969. }
  108970. declare module BABYLON {
  108971. /**
  108972. * DisplayPassPostProcess which produces an output the same as it's input
  108973. */
  108974. export class DisplayPassPostProcess extends PostProcess {
  108975. /**
  108976. * Creates the DisplayPassPostProcess
  108977. * @param name The name of the effect.
  108978. * @param options The required width/height ratio to downsize to before computing the render pass.
  108979. * @param camera The camera to apply the render pass to.
  108980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108981. * @param engine The engine which the post process will be applied. (default: current engine)
  108982. * @param reusable If the post process can be reused on the same frame. (default: false)
  108983. */
  108984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108985. }
  108986. }
  108987. declare module BABYLON {
  108988. /** @hidden */
  108989. export var filterPixelShader: {
  108990. name: string;
  108991. shader: string;
  108992. };
  108993. }
  108994. declare module BABYLON {
  108995. /**
  108996. * Applies a kernel filter to the image
  108997. */
  108998. export class FilterPostProcess extends PostProcess {
  108999. /** The matrix to be applied to the image */
  109000. kernelMatrix: Matrix;
  109001. /**
  109002. *
  109003. * @param name The name of the effect.
  109004. * @param kernelMatrix The matrix to be applied to the image
  109005. * @param options The required width/height ratio to downsize to before computing the render pass.
  109006. * @param camera The camera to apply the render pass to.
  109007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109008. * @param engine The engine which the post process will be applied. (default: current engine)
  109009. * @param reusable If the post process can be reused on the same frame. (default: false)
  109010. */
  109011. constructor(name: string,
  109012. /** The matrix to be applied to the image */
  109013. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109014. }
  109015. }
  109016. declare module BABYLON {
  109017. /** @hidden */
  109018. export var fxaaPixelShader: {
  109019. name: string;
  109020. shader: string;
  109021. };
  109022. }
  109023. declare module BABYLON {
  109024. /** @hidden */
  109025. export var fxaaVertexShader: {
  109026. name: string;
  109027. shader: string;
  109028. };
  109029. }
  109030. declare module BABYLON {
  109031. /**
  109032. * Fxaa post process
  109033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  109034. */
  109035. export class FxaaPostProcess extends PostProcess {
  109036. /** @hidden */
  109037. texelWidth: number;
  109038. /** @hidden */
  109039. texelHeight: number;
  109040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109041. private _getDefines;
  109042. }
  109043. }
  109044. declare module BABYLON {
  109045. /** @hidden */
  109046. export var grainPixelShader: {
  109047. name: string;
  109048. shader: string;
  109049. };
  109050. }
  109051. declare module BABYLON {
  109052. /**
  109053. * The GrainPostProcess adds noise to the image at mid luminance levels
  109054. */
  109055. export class GrainPostProcess extends PostProcess {
  109056. /**
  109057. * The intensity of the grain added (default: 30)
  109058. */
  109059. intensity: number;
  109060. /**
  109061. * If the grain should be randomized on every frame
  109062. */
  109063. animated: boolean;
  109064. /**
  109065. * Creates a new instance of @see GrainPostProcess
  109066. * @param name The name of the effect.
  109067. * @param options The required width/height ratio to downsize to before computing the render pass.
  109068. * @param camera The camera to apply the render pass to.
  109069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109070. * @param engine The engine which the post process will be applied. (default: current engine)
  109071. * @param reusable If the post process can be reused on the same frame. (default: false)
  109072. * @param textureType Type of textures used when performing the post process. (default: 0)
  109073. * @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)
  109074. */
  109075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109076. }
  109077. }
  109078. declare module BABYLON {
  109079. /** @hidden */
  109080. export var highlightsPixelShader: {
  109081. name: string;
  109082. shader: string;
  109083. };
  109084. }
  109085. declare module BABYLON {
  109086. /**
  109087. * Extracts highlights from the image
  109088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109089. */
  109090. export class HighlightsPostProcess extends PostProcess {
  109091. /**
  109092. * Extracts highlights from the image
  109093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109094. * @param name The name of the effect.
  109095. * @param options The required width/height ratio to downsize to before computing the render pass.
  109096. * @param camera The camera to apply the render pass to.
  109097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109098. * @param engine The engine which the post process will be applied. (default: current engine)
  109099. * @param reusable If the post process can be reused on the same frame. (default: false)
  109100. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  109101. */
  109102. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109103. }
  109104. }
  109105. declare module BABYLON {
  109106. /** @hidden */
  109107. export var mrtFragmentDeclaration: {
  109108. name: string;
  109109. shader: string;
  109110. };
  109111. }
  109112. declare module BABYLON {
  109113. /** @hidden */
  109114. export var geometryPixelShader: {
  109115. name: string;
  109116. shader: string;
  109117. };
  109118. }
  109119. declare module BABYLON {
  109120. /** @hidden */
  109121. export var geometryVertexShader: {
  109122. name: string;
  109123. shader: string;
  109124. };
  109125. }
  109126. declare module BABYLON {
  109127. /**
  109128. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  109129. */
  109130. export class GeometryBufferRenderer {
  109131. /**
  109132. * Constant used to retrieve the position texture index in the G-Buffer textures array
  109133. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  109134. */
  109135. static readonly POSITION_TEXTURE_TYPE: number;
  109136. /**
  109137. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  109138. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  109139. */
  109140. static readonly VELOCITY_TEXTURE_TYPE: number;
  109141. /**
  109142. * Dictionary used to store the previous transformation matrices of each rendered mesh
  109143. * in order to compute objects velocities when enableVelocity is set to "true"
  109144. * @hidden
  109145. */
  109146. _previousTransformationMatrices: {
  109147. [index: number]: Matrix;
  109148. };
  109149. private _scene;
  109150. private _multiRenderTarget;
  109151. private _ratio;
  109152. private _enablePosition;
  109153. private _enableVelocity;
  109154. private _positionIndex;
  109155. private _velocityIndex;
  109156. protected _effect: Effect;
  109157. protected _cachedDefines: string;
  109158. /**
  109159. * Set the render list (meshes to be rendered) used in the G buffer.
  109160. */
  109161. renderList: Mesh[];
  109162. /**
  109163. * Gets wether or not G buffer are supported by the running hardware.
  109164. * This requires draw buffer supports
  109165. */
  109166. readonly isSupported: boolean;
  109167. /**
  109168. * Returns the index of the given texture type in the G-Buffer textures array
  109169. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  109170. * @returns the index of the given texture type in the G-Buffer textures array
  109171. */
  109172. getTextureIndex(textureType: number): number;
  109173. /**
  109174. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  109175. */
  109176. /**
  109177. * Sets whether or not objects positions are enabled for the G buffer.
  109178. */
  109179. enablePosition: boolean;
  109180. /**
  109181. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  109182. */
  109183. /**
  109184. * Sets wether or not objects velocities are enabled for the G buffer.
  109185. */
  109186. enableVelocity: boolean;
  109187. /**
  109188. * Gets the scene associated with the buffer.
  109189. */
  109190. readonly scene: Scene;
  109191. /**
  109192. * Gets the ratio used by the buffer during its creation.
  109193. * How big is the buffer related to the main canvas.
  109194. */
  109195. readonly ratio: number;
  109196. /** @hidden */
  109197. static _SceneComponentInitialization: (scene: Scene) => void;
  109198. /**
  109199. * Creates a new G Buffer for the scene
  109200. * @param scene The scene the buffer belongs to
  109201. * @param ratio How big is the buffer related to the main canvas.
  109202. */
  109203. constructor(scene: Scene, ratio?: number);
  109204. /**
  109205. * Checks wether everything is ready to render a submesh to the G buffer.
  109206. * @param subMesh the submesh to check readiness for
  109207. * @param useInstances is the mesh drawn using instance or not
  109208. * @returns true if ready otherwise false
  109209. */
  109210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109211. /**
  109212. * Gets the current underlying G Buffer.
  109213. * @returns the buffer
  109214. */
  109215. getGBuffer(): MultiRenderTarget;
  109216. /**
  109217. * Gets the number of samples used to render the buffer (anti aliasing).
  109218. */
  109219. /**
  109220. * Sets the number of samples used to render the buffer (anti aliasing).
  109221. */
  109222. samples: number;
  109223. /**
  109224. * Disposes the renderer and frees up associated resources.
  109225. */
  109226. dispose(): void;
  109227. protected _createRenderTargets(): void;
  109228. }
  109229. }
  109230. declare module BABYLON {
  109231. interface Scene {
  109232. /** @hidden (Backing field) */
  109233. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109234. /**
  109235. * Gets or Sets the current geometry buffer associated to the scene.
  109236. */
  109237. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109238. /**
  109239. * Enables a GeometryBufferRender and associates it with the scene
  109240. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109241. * @returns the GeometryBufferRenderer
  109242. */
  109243. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109244. /**
  109245. * Disables the GeometryBufferRender associated with the scene
  109246. */
  109247. disableGeometryBufferRenderer(): void;
  109248. }
  109249. /**
  109250. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109251. * in several rendering techniques.
  109252. */
  109253. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109254. /**
  109255. * The component name helpful to identify the component in the list of scene components.
  109256. */
  109257. readonly name: string;
  109258. /**
  109259. * The scene the component belongs to.
  109260. */
  109261. scene: Scene;
  109262. /**
  109263. * Creates a new instance of the component for the given scene
  109264. * @param scene Defines the scene to register the component in
  109265. */
  109266. constructor(scene: Scene);
  109267. /**
  109268. * Registers the component in a given scene
  109269. */
  109270. register(): void;
  109271. /**
  109272. * Rebuilds the elements related to this component in case of
  109273. * context lost for instance.
  109274. */
  109275. rebuild(): void;
  109276. /**
  109277. * Disposes the component and the associated ressources
  109278. */
  109279. dispose(): void;
  109280. private _gatherRenderTargets;
  109281. }
  109282. }
  109283. declare module BABYLON {
  109284. /** @hidden */
  109285. export var motionBlurPixelShader: {
  109286. name: string;
  109287. shader: string;
  109288. };
  109289. }
  109290. declare module BABYLON {
  109291. /**
  109292. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  109293. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  109294. * As an example, all you have to do is to create the post-process:
  109295. * var mb = new BABYLON.MotionBlurPostProcess(
  109296. * 'mb', // The name of the effect.
  109297. * scene, // The scene containing the objects to blur according to their velocity.
  109298. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  109299. * camera // The camera to apply the render pass to.
  109300. * );
  109301. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  109302. */
  109303. export class MotionBlurPostProcess extends PostProcess {
  109304. /**
  109305. * Defines how much the image is blurred by the movement. Default value is equal to 1
  109306. */
  109307. motionStrength: number;
  109308. /**
  109309. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  109310. */
  109311. /**
  109312. * Sets the number of iterations to be used for motion blur quality
  109313. */
  109314. motionBlurSamples: number;
  109315. private _motionBlurSamples;
  109316. private _geometryBufferRenderer;
  109317. /**
  109318. * Creates a new instance MotionBlurPostProcess
  109319. * @param name The name of the effect.
  109320. * @param scene The scene containing the objects to blur according to their velocity.
  109321. * @param options The required width/height ratio to downsize to before computing the render pass.
  109322. * @param camera The camera to apply the render pass to.
  109323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109324. * @param engine The engine which the post process will be applied. (default: current engine)
  109325. * @param reusable If the post process can be reused on the same frame. (default: false)
  109326. * @param textureType Type of textures used when performing the post process. (default: 0)
  109327. * @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)
  109328. */
  109329. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109330. /**
  109331. * Disposes the post process.
  109332. * @param camera The camera to dispose the post process on.
  109333. */
  109334. dispose(camera?: Camera): void;
  109335. }
  109336. }
  109337. declare module BABYLON {
  109338. /** @hidden */
  109339. export var refractionPixelShader: {
  109340. name: string;
  109341. shader: string;
  109342. };
  109343. }
  109344. declare module BABYLON {
  109345. /**
  109346. * Post process which applies a refractin texture
  109347. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109348. */
  109349. export class RefractionPostProcess extends PostProcess {
  109350. /** the base color of the refraction (used to taint the rendering) */
  109351. color: Color3;
  109352. /** simulated refraction depth */
  109353. depth: number;
  109354. /** the coefficient of the base color (0 to remove base color tainting) */
  109355. colorLevel: number;
  109356. private _refTexture;
  109357. private _ownRefractionTexture;
  109358. /**
  109359. * Gets or sets the refraction texture
  109360. * Please note that you are responsible for disposing the texture if you set it manually
  109361. */
  109362. refractionTexture: Texture;
  109363. /**
  109364. * Initializes the RefractionPostProcess
  109365. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109366. * @param name The name of the effect.
  109367. * @param refractionTextureUrl Url of the refraction texture to use
  109368. * @param color the base color of the refraction (used to taint the rendering)
  109369. * @param depth simulated refraction depth
  109370. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  109371. * @param camera The camera to apply the render pass to.
  109372. * @param options The required width/height ratio to downsize to before computing the render pass.
  109373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109374. * @param engine The engine which the post process will be applied. (default: current engine)
  109375. * @param reusable If the post process can be reused on the same frame. (default: false)
  109376. */
  109377. constructor(name: string, refractionTextureUrl: string,
  109378. /** the base color of the refraction (used to taint the rendering) */
  109379. color: Color3,
  109380. /** simulated refraction depth */
  109381. depth: number,
  109382. /** the coefficient of the base color (0 to remove base color tainting) */
  109383. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109384. /**
  109385. * Disposes of the post process
  109386. * @param camera Camera to dispose post process on
  109387. */
  109388. dispose(camera: Camera): void;
  109389. }
  109390. }
  109391. declare module BABYLON {
  109392. /** @hidden */
  109393. export var sharpenPixelShader: {
  109394. name: string;
  109395. shader: string;
  109396. };
  109397. }
  109398. declare module BABYLON {
  109399. /**
  109400. * The SharpenPostProcess applies a sharpen kernel to every pixel
  109401. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109402. */
  109403. export class SharpenPostProcess extends PostProcess {
  109404. /**
  109405. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  109406. */
  109407. colorAmount: number;
  109408. /**
  109409. * How much sharpness should be applied (default: 0.3)
  109410. */
  109411. edgeAmount: number;
  109412. /**
  109413. * Creates a new instance ConvolutionPostProcess
  109414. * @param name The name of the effect.
  109415. * @param options The required width/height ratio to downsize to before computing the render pass.
  109416. * @param camera The camera to apply the render pass to.
  109417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109418. * @param engine The engine which the post process will be applied. (default: current engine)
  109419. * @param reusable If the post process can be reused on the same frame. (default: false)
  109420. * @param textureType Type of textures used when performing the post process. (default: 0)
  109421. * @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)
  109422. */
  109423. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109424. }
  109425. }
  109426. declare module BABYLON {
  109427. /**
  109428. * PostProcessRenderPipeline
  109429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109430. */
  109431. export class PostProcessRenderPipeline {
  109432. private engine;
  109433. private _renderEffects;
  109434. private _renderEffectsForIsolatedPass;
  109435. /**
  109436. * @hidden
  109437. */
  109438. protected _cameras: Camera[];
  109439. /** @hidden */
  109440. _name: string;
  109441. /**
  109442. * Gets pipeline name
  109443. */
  109444. readonly name: string;
  109445. /**
  109446. * Initializes a PostProcessRenderPipeline
  109447. * @param engine engine to add the pipeline to
  109448. * @param name name of the pipeline
  109449. */
  109450. constructor(engine: Engine, name: string);
  109451. /**
  109452. * Gets the class name
  109453. * @returns "PostProcessRenderPipeline"
  109454. */
  109455. getClassName(): string;
  109456. /**
  109457. * If all the render effects in the pipeline are supported
  109458. */
  109459. readonly isSupported: boolean;
  109460. /**
  109461. * Adds an effect to the pipeline
  109462. * @param renderEffect the effect to add
  109463. */
  109464. addEffect(renderEffect: PostProcessRenderEffect): void;
  109465. /** @hidden */
  109466. _rebuild(): void;
  109467. /** @hidden */
  109468. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109469. /** @hidden */
  109470. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109471. /** @hidden */
  109472. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109473. /** @hidden */
  109474. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109475. /** @hidden */
  109476. _attachCameras(cameras: Camera, unique: boolean): void;
  109477. /** @hidden */
  109478. _attachCameras(cameras: Camera[], unique: boolean): void;
  109479. /** @hidden */
  109480. _detachCameras(cameras: Camera): void;
  109481. /** @hidden */
  109482. _detachCameras(cameras: Nullable<Camera[]>): void;
  109483. /** @hidden */
  109484. _update(): void;
  109485. /** @hidden */
  109486. _reset(): void;
  109487. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109488. /**
  109489. * Disposes of the pipeline
  109490. */
  109491. dispose(): void;
  109492. }
  109493. }
  109494. declare module BABYLON {
  109495. /**
  109496. * PostProcessRenderPipelineManager class
  109497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109498. */
  109499. export class PostProcessRenderPipelineManager {
  109500. private _renderPipelines;
  109501. /**
  109502. * Initializes a PostProcessRenderPipelineManager
  109503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109504. */
  109505. constructor();
  109506. /**
  109507. * Gets the list of supported render pipelines
  109508. */
  109509. readonly supportedPipelines: PostProcessRenderPipeline[];
  109510. /**
  109511. * Adds a pipeline to the manager
  109512. * @param renderPipeline The pipeline to add
  109513. */
  109514. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109515. /**
  109516. * Attaches a camera to the pipeline
  109517. * @param renderPipelineName The name of the pipeline to attach to
  109518. * @param cameras the camera to attach
  109519. * @param unique if the camera can be attached multiple times to the pipeline
  109520. */
  109521. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109522. /**
  109523. * Detaches a camera from the pipeline
  109524. * @param renderPipelineName The name of the pipeline to detach from
  109525. * @param cameras the camera to detach
  109526. */
  109527. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109528. /**
  109529. * Enables an effect by name on a pipeline
  109530. * @param renderPipelineName the name of the pipeline to enable the effect in
  109531. * @param renderEffectName the name of the effect to enable
  109532. * @param cameras the cameras that the effect should be enabled on
  109533. */
  109534. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109535. /**
  109536. * Disables an effect by name on a pipeline
  109537. * @param renderPipelineName the name of the pipeline to disable the effect in
  109538. * @param renderEffectName the name of the effect to disable
  109539. * @param cameras the cameras that the effect should be disabled on
  109540. */
  109541. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109542. /**
  109543. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109544. */
  109545. update(): void;
  109546. /** @hidden */
  109547. _rebuild(): void;
  109548. /**
  109549. * Disposes of the manager and pipelines
  109550. */
  109551. dispose(): void;
  109552. }
  109553. }
  109554. declare module BABYLON {
  109555. interface Scene {
  109556. /** @hidden (Backing field) */
  109557. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109558. /**
  109559. * Gets the postprocess render pipeline manager
  109560. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109561. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109562. */
  109563. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109564. }
  109565. /**
  109566. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109567. */
  109568. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109569. /**
  109570. * The component name helpfull to identify the component in the list of scene components.
  109571. */
  109572. readonly name: string;
  109573. /**
  109574. * The scene the component belongs to.
  109575. */
  109576. scene: Scene;
  109577. /**
  109578. * Creates a new instance of the component for the given scene
  109579. * @param scene Defines the scene to register the component in
  109580. */
  109581. constructor(scene: Scene);
  109582. /**
  109583. * Registers the component in a given scene
  109584. */
  109585. register(): void;
  109586. /**
  109587. * Rebuilds the elements related to this component in case of
  109588. * context lost for instance.
  109589. */
  109590. rebuild(): void;
  109591. /**
  109592. * Disposes the component and the associated ressources
  109593. */
  109594. dispose(): void;
  109595. private _gatherRenderTargets;
  109596. }
  109597. }
  109598. declare module BABYLON {
  109599. /**
  109600. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109601. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109602. */
  109603. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109604. private _scene;
  109605. private _camerasToBeAttached;
  109606. /**
  109607. * ID of the sharpen post process,
  109608. */
  109609. private readonly SharpenPostProcessId;
  109610. /**
  109611. * @ignore
  109612. * ID of the image processing post process;
  109613. */
  109614. readonly ImageProcessingPostProcessId: string;
  109615. /**
  109616. * @ignore
  109617. * ID of the Fast Approximate Anti-Aliasing post process;
  109618. */
  109619. readonly FxaaPostProcessId: string;
  109620. /**
  109621. * ID of the chromatic aberration post process,
  109622. */
  109623. private readonly ChromaticAberrationPostProcessId;
  109624. /**
  109625. * ID of the grain post process
  109626. */
  109627. private readonly GrainPostProcessId;
  109628. /**
  109629. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109630. */
  109631. sharpen: SharpenPostProcess;
  109632. private _sharpenEffect;
  109633. private bloom;
  109634. /**
  109635. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109636. */
  109637. depthOfField: DepthOfFieldEffect;
  109638. /**
  109639. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109640. */
  109641. fxaa: FxaaPostProcess;
  109642. /**
  109643. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109644. */
  109645. imageProcessing: ImageProcessingPostProcess;
  109646. /**
  109647. * Chromatic aberration post process which will shift rgb colors in the image
  109648. */
  109649. chromaticAberration: ChromaticAberrationPostProcess;
  109650. private _chromaticAberrationEffect;
  109651. /**
  109652. * Grain post process which add noise to the image
  109653. */
  109654. grain: GrainPostProcess;
  109655. private _grainEffect;
  109656. /**
  109657. * Glow post process which adds a glow to emissive areas of the image
  109658. */
  109659. private _glowLayer;
  109660. /**
  109661. * Animations which can be used to tweak settings over a period of time
  109662. */
  109663. animations: Animation[];
  109664. private _imageProcessingConfigurationObserver;
  109665. private _sharpenEnabled;
  109666. private _bloomEnabled;
  109667. private _depthOfFieldEnabled;
  109668. private _depthOfFieldBlurLevel;
  109669. private _fxaaEnabled;
  109670. private _imageProcessingEnabled;
  109671. private _defaultPipelineTextureType;
  109672. private _bloomScale;
  109673. private _chromaticAberrationEnabled;
  109674. private _grainEnabled;
  109675. private _buildAllowed;
  109676. /**
  109677. * Gets active scene
  109678. */
  109679. readonly scene: Scene;
  109680. /**
  109681. * Enable or disable the sharpen process from the pipeline
  109682. */
  109683. sharpenEnabled: boolean;
  109684. private _resizeObserver;
  109685. private _hardwareScaleLevel;
  109686. private _bloomKernel;
  109687. /**
  109688. * Specifies the size of the bloom blur kernel, relative to the final output size
  109689. */
  109690. bloomKernel: number;
  109691. /**
  109692. * Specifies the weight of the bloom in the final rendering
  109693. */
  109694. private _bloomWeight;
  109695. /**
  109696. * Specifies the luma threshold for the area that will be blurred by the bloom
  109697. */
  109698. private _bloomThreshold;
  109699. private _hdr;
  109700. /**
  109701. * The strength of the bloom.
  109702. */
  109703. bloomWeight: number;
  109704. /**
  109705. * The strength of the bloom.
  109706. */
  109707. bloomThreshold: number;
  109708. /**
  109709. * The scale of the bloom, lower value will provide better performance.
  109710. */
  109711. bloomScale: number;
  109712. /**
  109713. * Enable or disable the bloom from the pipeline
  109714. */
  109715. bloomEnabled: boolean;
  109716. private _rebuildBloom;
  109717. /**
  109718. * If the depth of field is enabled.
  109719. */
  109720. depthOfFieldEnabled: boolean;
  109721. /**
  109722. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109723. */
  109724. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109725. /**
  109726. * If the anti aliasing is enabled.
  109727. */
  109728. fxaaEnabled: boolean;
  109729. private _samples;
  109730. /**
  109731. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109732. */
  109733. samples: number;
  109734. /**
  109735. * If image processing is enabled.
  109736. */
  109737. imageProcessingEnabled: boolean;
  109738. /**
  109739. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109740. */
  109741. glowLayerEnabled: boolean;
  109742. /**
  109743. * Enable or disable the chromaticAberration process from the pipeline
  109744. */
  109745. chromaticAberrationEnabled: boolean;
  109746. /**
  109747. * Enable or disable the grain process from the pipeline
  109748. */
  109749. grainEnabled: boolean;
  109750. /**
  109751. * @constructor
  109752. * @param name - The rendering pipeline name (default: "")
  109753. * @param hdr - If high dynamic range textures should be used (default: true)
  109754. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109755. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109756. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109757. */
  109758. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109759. /**
  109760. * Get the class name
  109761. * @returns "DefaultRenderingPipeline"
  109762. */
  109763. getClassName(): string;
  109764. /**
  109765. * Force the compilation of the entire pipeline.
  109766. */
  109767. prepare(): void;
  109768. private _hasCleared;
  109769. private _prevPostProcess;
  109770. private _prevPrevPostProcess;
  109771. private _setAutoClearAndTextureSharing;
  109772. private _depthOfFieldSceneObserver;
  109773. private _buildPipeline;
  109774. private _disposePostProcesses;
  109775. /**
  109776. * Adds a camera to the pipeline
  109777. * @param camera the camera to be added
  109778. */
  109779. addCamera(camera: Camera): void;
  109780. /**
  109781. * Removes a camera from the pipeline
  109782. * @param camera the camera to remove
  109783. */
  109784. removeCamera(camera: Camera): void;
  109785. /**
  109786. * Dispose of the pipeline and stop all post processes
  109787. */
  109788. dispose(): void;
  109789. /**
  109790. * Serialize the rendering pipeline (Used when exporting)
  109791. * @returns the serialized object
  109792. */
  109793. serialize(): any;
  109794. /**
  109795. * Parse the serialized pipeline
  109796. * @param source Source pipeline.
  109797. * @param scene The scene to load the pipeline to.
  109798. * @param rootUrl The URL of the serialized pipeline.
  109799. * @returns An instantiated pipeline from the serialized object.
  109800. */
  109801. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109802. }
  109803. }
  109804. declare module BABYLON {
  109805. /** @hidden */
  109806. export var lensHighlightsPixelShader: {
  109807. name: string;
  109808. shader: string;
  109809. };
  109810. }
  109811. declare module BABYLON {
  109812. /** @hidden */
  109813. export var depthOfFieldPixelShader: {
  109814. name: string;
  109815. shader: string;
  109816. };
  109817. }
  109818. declare module BABYLON {
  109819. /**
  109820. * BABYLON.JS Chromatic Aberration GLSL Shader
  109821. * Author: Olivier Guyot
  109822. * Separates very slightly R, G and B colors on the edges of the screen
  109823. * Inspired by Francois Tarlier & Martins Upitis
  109824. */
  109825. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109826. /**
  109827. * @ignore
  109828. * The chromatic aberration PostProcess id in the pipeline
  109829. */
  109830. LensChromaticAberrationEffect: string;
  109831. /**
  109832. * @ignore
  109833. * The highlights enhancing PostProcess id in the pipeline
  109834. */
  109835. HighlightsEnhancingEffect: string;
  109836. /**
  109837. * @ignore
  109838. * The depth-of-field PostProcess id in the pipeline
  109839. */
  109840. LensDepthOfFieldEffect: string;
  109841. private _scene;
  109842. private _depthTexture;
  109843. private _grainTexture;
  109844. private _chromaticAberrationPostProcess;
  109845. private _highlightsPostProcess;
  109846. private _depthOfFieldPostProcess;
  109847. private _edgeBlur;
  109848. private _grainAmount;
  109849. private _chromaticAberration;
  109850. private _distortion;
  109851. private _highlightsGain;
  109852. private _highlightsThreshold;
  109853. private _dofDistance;
  109854. private _dofAperture;
  109855. private _dofDarken;
  109856. private _dofPentagon;
  109857. private _blurNoise;
  109858. /**
  109859. * @constructor
  109860. *
  109861. * Effect parameters are as follow:
  109862. * {
  109863. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109864. * edge_blur: number; // from 0 to x (1 for realism)
  109865. * distortion: number; // from 0 to x (1 for realism)
  109866. * grain_amount: number; // from 0 to 1
  109867. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109868. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109869. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109870. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109871. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109872. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109873. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109874. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109875. * }
  109876. * Note: if an effect parameter is unset, effect is disabled
  109877. *
  109878. * @param name The rendering pipeline name
  109879. * @param parameters - An object containing all parameters (see above)
  109880. * @param scene The scene linked to this pipeline
  109881. * @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)
  109882. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109883. */
  109884. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109885. /**
  109886. * Get the class name
  109887. * @returns "LensRenderingPipeline"
  109888. */
  109889. getClassName(): string;
  109890. /**
  109891. * Gets associated scene
  109892. */
  109893. readonly scene: Scene;
  109894. /**
  109895. * Gets or sets the edge blur
  109896. */
  109897. edgeBlur: number;
  109898. /**
  109899. * Gets or sets the grain amount
  109900. */
  109901. grainAmount: number;
  109902. /**
  109903. * Gets or sets the chromatic aberration amount
  109904. */
  109905. chromaticAberration: number;
  109906. /**
  109907. * Gets or sets the depth of field aperture
  109908. */
  109909. dofAperture: number;
  109910. /**
  109911. * Gets or sets the edge distortion
  109912. */
  109913. edgeDistortion: number;
  109914. /**
  109915. * Gets or sets the depth of field distortion
  109916. */
  109917. dofDistortion: number;
  109918. /**
  109919. * Gets or sets the darken out of focus amount
  109920. */
  109921. darkenOutOfFocus: number;
  109922. /**
  109923. * Gets or sets a boolean indicating if blur noise is enabled
  109924. */
  109925. blurNoise: boolean;
  109926. /**
  109927. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  109928. */
  109929. pentagonBokeh: boolean;
  109930. /**
  109931. * Gets or sets the highlight grain amount
  109932. */
  109933. highlightsGain: number;
  109934. /**
  109935. * Gets or sets the highlight threshold
  109936. */
  109937. highlightsThreshold: number;
  109938. /**
  109939. * Sets the amount of blur at the edges
  109940. * @param amount blur amount
  109941. */
  109942. setEdgeBlur(amount: number): void;
  109943. /**
  109944. * Sets edge blur to 0
  109945. */
  109946. disableEdgeBlur(): void;
  109947. /**
  109948. * Sets the amout of grain
  109949. * @param amount Amount of grain
  109950. */
  109951. setGrainAmount(amount: number): void;
  109952. /**
  109953. * Set grain amount to 0
  109954. */
  109955. disableGrain(): void;
  109956. /**
  109957. * Sets the chromatic aberration amount
  109958. * @param amount amount of chromatic aberration
  109959. */
  109960. setChromaticAberration(amount: number): void;
  109961. /**
  109962. * Sets chromatic aberration amount to 0
  109963. */
  109964. disableChromaticAberration(): void;
  109965. /**
  109966. * Sets the EdgeDistortion amount
  109967. * @param amount amount of EdgeDistortion
  109968. */
  109969. setEdgeDistortion(amount: number): void;
  109970. /**
  109971. * Sets edge distortion to 0
  109972. */
  109973. disableEdgeDistortion(): void;
  109974. /**
  109975. * Sets the FocusDistance amount
  109976. * @param amount amount of FocusDistance
  109977. */
  109978. setFocusDistance(amount: number): void;
  109979. /**
  109980. * Disables depth of field
  109981. */
  109982. disableDepthOfField(): void;
  109983. /**
  109984. * Sets the Aperture amount
  109985. * @param amount amount of Aperture
  109986. */
  109987. setAperture(amount: number): void;
  109988. /**
  109989. * Sets the DarkenOutOfFocus amount
  109990. * @param amount amount of DarkenOutOfFocus
  109991. */
  109992. setDarkenOutOfFocus(amount: number): void;
  109993. private _pentagonBokehIsEnabled;
  109994. /**
  109995. * Creates a pentagon bokeh effect
  109996. */
  109997. enablePentagonBokeh(): void;
  109998. /**
  109999. * Disables the pentagon bokeh effect
  110000. */
  110001. disablePentagonBokeh(): void;
  110002. /**
  110003. * Enables noise blur
  110004. */
  110005. enableNoiseBlur(): void;
  110006. /**
  110007. * Disables noise blur
  110008. */
  110009. disableNoiseBlur(): void;
  110010. /**
  110011. * Sets the HighlightsGain amount
  110012. * @param amount amount of HighlightsGain
  110013. */
  110014. setHighlightsGain(amount: number): void;
  110015. /**
  110016. * Sets the HighlightsThreshold amount
  110017. * @param amount amount of HighlightsThreshold
  110018. */
  110019. setHighlightsThreshold(amount: number): void;
  110020. /**
  110021. * Disables highlights
  110022. */
  110023. disableHighlights(): void;
  110024. /**
  110025. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  110026. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  110027. */
  110028. dispose(disableDepthRender?: boolean): void;
  110029. private _createChromaticAberrationPostProcess;
  110030. private _createHighlightsPostProcess;
  110031. private _createDepthOfFieldPostProcess;
  110032. private _createGrainTexture;
  110033. }
  110034. }
  110035. declare module BABYLON {
  110036. /** @hidden */
  110037. export var ssao2PixelShader: {
  110038. name: string;
  110039. shader: string;
  110040. };
  110041. }
  110042. declare module BABYLON {
  110043. /** @hidden */
  110044. export var ssaoCombinePixelShader: {
  110045. name: string;
  110046. shader: string;
  110047. };
  110048. }
  110049. declare module BABYLON {
  110050. /**
  110051. * Render pipeline to produce ssao effect
  110052. */
  110053. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  110054. /**
  110055. * @ignore
  110056. * The PassPostProcess id in the pipeline that contains the original scene color
  110057. */
  110058. SSAOOriginalSceneColorEffect: string;
  110059. /**
  110060. * @ignore
  110061. * The SSAO PostProcess id in the pipeline
  110062. */
  110063. SSAORenderEffect: string;
  110064. /**
  110065. * @ignore
  110066. * The horizontal blur PostProcess id in the pipeline
  110067. */
  110068. SSAOBlurHRenderEffect: string;
  110069. /**
  110070. * @ignore
  110071. * The vertical blur PostProcess id in the pipeline
  110072. */
  110073. SSAOBlurVRenderEffect: string;
  110074. /**
  110075. * @ignore
  110076. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  110077. */
  110078. SSAOCombineRenderEffect: string;
  110079. /**
  110080. * The output strength of the SSAO post-process. Default value is 1.0.
  110081. */
  110082. totalStrength: number;
  110083. /**
  110084. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  110085. */
  110086. maxZ: number;
  110087. /**
  110088. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  110089. */
  110090. minZAspect: number;
  110091. private _samples;
  110092. /**
  110093. * Number of samples used for the SSAO calculations. Default value is 8
  110094. */
  110095. samples: number;
  110096. private _textureSamples;
  110097. /**
  110098. * Number of samples to use for antialiasing
  110099. */
  110100. textureSamples: number;
  110101. /**
  110102. * Ratio object used for SSAO ratio and blur ratio
  110103. */
  110104. private _ratio;
  110105. /**
  110106. * Dynamically generated sphere sampler.
  110107. */
  110108. private _sampleSphere;
  110109. /**
  110110. * Blur filter offsets
  110111. */
  110112. private _samplerOffsets;
  110113. private _expensiveBlur;
  110114. /**
  110115. * If bilateral blur should be used
  110116. */
  110117. expensiveBlur: boolean;
  110118. /**
  110119. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  110120. */
  110121. radius: number;
  110122. /**
  110123. * The base color of the SSAO post-process
  110124. * The final result is "base + ssao" between [0, 1]
  110125. */
  110126. base: number;
  110127. /**
  110128. * Support test.
  110129. */
  110130. static readonly IsSupported: boolean;
  110131. private _scene;
  110132. private _depthTexture;
  110133. private _normalTexture;
  110134. private _randomTexture;
  110135. private _originalColorPostProcess;
  110136. private _ssaoPostProcess;
  110137. private _blurHPostProcess;
  110138. private _blurVPostProcess;
  110139. private _ssaoCombinePostProcess;
  110140. private _firstUpdate;
  110141. /**
  110142. * Gets active scene
  110143. */
  110144. readonly scene: Scene;
  110145. /**
  110146. * @constructor
  110147. * @param name The rendering pipeline name
  110148. * @param scene The scene linked to this pipeline
  110149. * @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 }
  110150. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110151. */
  110152. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  110153. /**
  110154. * Get the class name
  110155. * @returns "SSAO2RenderingPipeline"
  110156. */
  110157. getClassName(): string;
  110158. /**
  110159. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  110160. */
  110161. dispose(disableGeometryBufferRenderer?: boolean): void;
  110162. private _createBlurPostProcess;
  110163. /** @hidden */
  110164. _rebuild(): void;
  110165. private _bits;
  110166. private _radicalInverse_VdC;
  110167. private _hammersley;
  110168. private _hemisphereSample_uniform;
  110169. private _generateHemisphere;
  110170. private _createSSAOPostProcess;
  110171. private _createSSAOCombinePostProcess;
  110172. private _createRandomTexture;
  110173. /**
  110174. * Serialize the rendering pipeline (Used when exporting)
  110175. * @returns the serialized object
  110176. */
  110177. serialize(): any;
  110178. /**
  110179. * Parse the serialized pipeline
  110180. * @param source Source pipeline.
  110181. * @param scene The scene to load the pipeline to.
  110182. * @param rootUrl The URL of the serialized pipeline.
  110183. * @returns An instantiated pipeline from the serialized object.
  110184. */
  110185. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  110186. }
  110187. }
  110188. declare module BABYLON {
  110189. /** @hidden */
  110190. export var ssaoPixelShader: {
  110191. name: string;
  110192. shader: string;
  110193. };
  110194. }
  110195. declare module BABYLON {
  110196. /**
  110197. * Render pipeline to produce ssao effect
  110198. */
  110199. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  110200. /**
  110201. * @ignore
  110202. * The PassPostProcess id in the pipeline that contains the original scene color
  110203. */
  110204. SSAOOriginalSceneColorEffect: string;
  110205. /**
  110206. * @ignore
  110207. * The SSAO PostProcess id in the pipeline
  110208. */
  110209. SSAORenderEffect: string;
  110210. /**
  110211. * @ignore
  110212. * The horizontal blur PostProcess id in the pipeline
  110213. */
  110214. SSAOBlurHRenderEffect: string;
  110215. /**
  110216. * @ignore
  110217. * The vertical blur PostProcess id in the pipeline
  110218. */
  110219. SSAOBlurVRenderEffect: string;
  110220. /**
  110221. * @ignore
  110222. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  110223. */
  110224. SSAOCombineRenderEffect: string;
  110225. /**
  110226. * The output strength of the SSAO post-process. Default value is 1.0.
  110227. */
  110228. totalStrength: number;
  110229. /**
  110230. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  110231. */
  110232. radius: number;
  110233. /**
  110234. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  110235. * Must not be equal to fallOff and superior to fallOff.
  110236. * Default value is 0.0075
  110237. */
  110238. area: number;
  110239. /**
  110240. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  110241. * Must not be equal to area and inferior to area.
  110242. * Default value is 0.000001
  110243. */
  110244. fallOff: number;
  110245. /**
  110246. * The base color of the SSAO post-process
  110247. * The final result is "base + ssao" between [0, 1]
  110248. */
  110249. base: number;
  110250. private _scene;
  110251. private _depthTexture;
  110252. private _randomTexture;
  110253. private _originalColorPostProcess;
  110254. private _ssaoPostProcess;
  110255. private _blurHPostProcess;
  110256. private _blurVPostProcess;
  110257. private _ssaoCombinePostProcess;
  110258. private _firstUpdate;
  110259. /**
  110260. * Gets active scene
  110261. */
  110262. readonly scene: Scene;
  110263. /**
  110264. * @constructor
  110265. * @param name - The rendering pipeline name
  110266. * @param scene - The scene linked to this pipeline
  110267. * @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 }
  110268. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  110269. */
  110270. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  110271. /**
  110272. * Get the class name
  110273. * @returns "SSAORenderingPipeline"
  110274. */
  110275. getClassName(): string;
  110276. /**
  110277. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  110278. */
  110279. dispose(disableDepthRender?: boolean): void;
  110280. private _createBlurPostProcess;
  110281. /** @hidden */
  110282. _rebuild(): void;
  110283. private _createSSAOPostProcess;
  110284. private _createSSAOCombinePostProcess;
  110285. private _createRandomTexture;
  110286. }
  110287. }
  110288. declare module BABYLON {
  110289. /** @hidden */
  110290. export var standardPixelShader: {
  110291. name: string;
  110292. shader: string;
  110293. };
  110294. }
  110295. declare module BABYLON {
  110296. /**
  110297. * Standard rendering pipeline
  110298. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110299. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  110300. */
  110301. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110302. /**
  110303. * Public members
  110304. */
  110305. /**
  110306. * Post-process which contains the original scene color before the pipeline applies all the effects
  110307. */
  110308. originalPostProcess: Nullable<PostProcess>;
  110309. /**
  110310. * Post-process used to down scale an image x4
  110311. */
  110312. downSampleX4PostProcess: Nullable<PostProcess>;
  110313. /**
  110314. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  110315. */
  110316. brightPassPostProcess: Nullable<PostProcess>;
  110317. /**
  110318. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  110319. */
  110320. blurHPostProcesses: PostProcess[];
  110321. /**
  110322. * Post-process array storing all the vertical blur post-processes used by the pipeline
  110323. */
  110324. blurVPostProcesses: PostProcess[];
  110325. /**
  110326. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  110327. */
  110328. textureAdderPostProcess: Nullable<PostProcess>;
  110329. /**
  110330. * Post-process used to create volumetric lighting effect
  110331. */
  110332. volumetricLightPostProcess: Nullable<PostProcess>;
  110333. /**
  110334. * Post-process used to smooth the previous volumetric light post-process on the X axis
  110335. */
  110336. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  110337. /**
  110338. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  110339. */
  110340. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  110341. /**
  110342. * Post-process used to merge the volumetric light effect and the real scene color
  110343. */
  110344. volumetricLightMergePostProces: Nullable<PostProcess>;
  110345. /**
  110346. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  110347. */
  110348. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  110349. /**
  110350. * Base post-process used to calculate the average luminance of the final image for HDR
  110351. */
  110352. luminancePostProcess: Nullable<PostProcess>;
  110353. /**
  110354. * Post-processes used to create down sample post-processes in order to get
  110355. * the average luminance of the final image for HDR
  110356. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  110357. */
  110358. luminanceDownSamplePostProcesses: PostProcess[];
  110359. /**
  110360. * Post-process used to create a HDR effect (light adaptation)
  110361. */
  110362. hdrPostProcess: Nullable<PostProcess>;
  110363. /**
  110364. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  110365. */
  110366. textureAdderFinalPostProcess: Nullable<PostProcess>;
  110367. /**
  110368. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  110369. */
  110370. lensFlareFinalPostProcess: Nullable<PostProcess>;
  110371. /**
  110372. * Post-process used to merge the final HDR post-process and the real scene color
  110373. */
  110374. hdrFinalPostProcess: Nullable<PostProcess>;
  110375. /**
  110376. * Post-process used to create a lens flare effect
  110377. */
  110378. lensFlarePostProcess: Nullable<PostProcess>;
  110379. /**
  110380. * Post-process that merges the result of the lens flare post-process and the real scene color
  110381. */
  110382. lensFlareComposePostProcess: Nullable<PostProcess>;
  110383. /**
  110384. * Post-process used to create a motion blur effect
  110385. */
  110386. motionBlurPostProcess: Nullable<PostProcess>;
  110387. /**
  110388. * Post-process used to create a depth of field effect
  110389. */
  110390. depthOfFieldPostProcess: Nullable<PostProcess>;
  110391. /**
  110392. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110393. */
  110394. fxaaPostProcess: Nullable<FxaaPostProcess>;
  110395. /**
  110396. * Represents the brightness threshold in order to configure the illuminated surfaces
  110397. */
  110398. brightThreshold: number;
  110399. /**
  110400. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  110401. */
  110402. blurWidth: number;
  110403. /**
  110404. * Sets if the blur for highlighted surfaces must be only horizontal
  110405. */
  110406. horizontalBlur: boolean;
  110407. /**
  110408. * Sets the overall exposure used by the pipeline
  110409. */
  110410. exposure: number;
  110411. /**
  110412. * Texture used typically to simulate "dirty" on camera lens
  110413. */
  110414. lensTexture: Nullable<Texture>;
  110415. /**
  110416. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  110417. */
  110418. volumetricLightCoefficient: number;
  110419. /**
  110420. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  110421. */
  110422. volumetricLightPower: number;
  110423. /**
  110424. * Used the set the blur intensity to smooth the volumetric lights
  110425. */
  110426. volumetricLightBlurScale: number;
  110427. /**
  110428. * Light (spot or directional) used to generate the volumetric lights rays
  110429. * The source light must have a shadow generate so the pipeline can get its
  110430. * depth map
  110431. */
  110432. sourceLight: Nullable<SpotLight | DirectionalLight>;
  110433. /**
  110434. * For eye adaptation, represents the minimum luminance the eye can see
  110435. */
  110436. hdrMinimumLuminance: number;
  110437. /**
  110438. * For eye adaptation, represents the decrease luminance speed
  110439. */
  110440. hdrDecreaseRate: number;
  110441. /**
  110442. * For eye adaptation, represents the increase luminance speed
  110443. */
  110444. hdrIncreaseRate: number;
  110445. /**
  110446. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  110447. */
  110448. lensColorTexture: Nullable<Texture>;
  110449. /**
  110450. * The overall strengh for the lens flare effect
  110451. */
  110452. lensFlareStrength: number;
  110453. /**
  110454. * Dispersion coefficient for lens flare ghosts
  110455. */
  110456. lensFlareGhostDispersal: number;
  110457. /**
  110458. * Main lens flare halo width
  110459. */
  110460. lensFlareHaloWidth: number;
  110461. /**
  110462. * Based on the lens distortion effect, defines how much the lens flare result
  110463. * is distorted
  110464. */
  110465. lensFlareDistortionStrength: number;
  110466. /**
  110467. * Lens star texture must be used to simulate rays on the flares and is available
  110468. * in the documentation
  110469. */
  110470. lensStarTexture: Nullable<Texture>;
  110471. /**
  110472. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  110473. * flare effect by taking account of the dirt texture
  110474. */
  110475. lensFlareDirtTexture: Nullable<Texture>;
  110476. /**
  110477. * Represents the focal length for the depth of field effect
  110478. */
  110479. depthOfFieldDistance: number;
  110480. /**
  110481. * Represents the blur intensity for the blurred part of the depth of field effect
  110482. */
  110483. depthOfFieldBlurWidth: number;
  110484. /**
  110485. * For motion blur, defines how much the image is blurred by the movement
  110486. */
  110487. motionStrength: number;
  110488. /**
  110489. * List of animations for the pipeline (IAnimatable implementation)
  110490. */
  110491. animations: Animation[];
  110492. /**
  110493. * Private members
  110494. */
  110495. private _scene;
  110496. private _currentDepthOfFieldSource;
  110497. private _basePostProcess;
  110498. private _hdrCurrentLuminance;
  110499. private _floatTextureType;
  110500. private _ratio;
  110501. private _bloomEnabled;
  110502. private _depthOfFieldEnabled;
  110503. private _vlsEnabled;
  110504. private _lensFlareEnabled;
  110505. private _hdrEnabled;
  110506. private _motionBlurEnabled;
  110507. private _fxaaEnabled;
  110508. private _motionBlurSamples;
  110509. private _volumetricLightStepsCount;
  110510. private _samples;
  110511. /**
  110512. * @ignore
  110513. * Specifies if the bloom pipeline is enabled
  110514. */
  110515. BloomEnabled: boolean;
  110516. /**
  110517. * @ignore
  110518. * Specifies if the depth of field pipeline is enabed
  110519. */
  110520. DepthOfFieldEnabled: boolean;
  110521. /**
  110522. * @ignore
  110523. * Specifies if the lens flare pipeline is enabed
  110524. */
  110525. LensFlareEnabled: boolean;
  110526. /**
  110527. * @ignore
  110528. * Specifies if the HDR pipeline is enabled
  110529. */
  110530. HDREnabled: boolean;
  110531. /**
  110532. * @ignore
  110533. * Specifies if the volumetric lights scattering effect is enabled
  110534. */
  110535. VLSEnabled: boolean;
  110536. /**
  110537. * @ignore
  110538. * Specifies if the motion blur effect is enabled
  110539. */
  110540. MotionBlurEnabled: boolean;
  110541. /**
  110542. * Specifies if anti-aliasing is enabled
  110543. */
  110544. fxaaEnabled: boolean;
  110545. /**
  110546. * Specifies the number of steps used to calculate the volumetric lights
  110547. * Typically in interval [50, 200]
  110548. */
  110549. volumetricLightStepsCount: number;
  110550. /**
  110551. * Specifies the number of samples used for the motion blur effect
  110552. * Typically in interval [16, 64]
  110553. */
  110554. motionBlurSamples: number;
  110555. /**
  110556. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110557. */
  110558. samples: number;
  110559. /**
  110560. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110561. * @constructor
  110562. * @param name The rendering pipeline name
  110563. * @param scene The scene linked to this pipeline
  110564. * @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)
  110565. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110566. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110567. */
  110568. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110569. private _buildPipeline;
  110570. private _createDownSampleX4PostProcess;
  110571. private _createBrightPassPostProcess;
  110572. private _createBlurPostProcesses;
  110573. private _createTextureAdderPostProcess;
  110574. private _createVolumetricLightPostProcess;
  110575. private _createLuminancePostProcesses;
  110576. private _createHdrPostProcess;
  110577. private _createLensFlarePostProcess;
  110578. private _createDepthOfFieldPostProcess;
  110579. private _createMotionBlurPostProcess;
  110580. private _getDepthTexture;
  110581. private _disposePostProcesses;
  110582. /**
  110583. * Dispose of the pipeline and stop all post processes
  110584. */
  110585. dispose(): void;
  110586. /**
  110587. * Serialize the rendering pipeline (Used when exporting)
  110588. * @returns the serialized object
  110589. */
  110590. serialize(): any;
  110591. /**
  110592. * Parse the serialized pipeline
  110593. * @param source Source pipeline.
  110594. * @param scene The scene to load the pipeline to.
  110595. * @param rootUrl The URL of the serialized pipeline.
  110596. * @returns An instantiated pipeline from the serialized object.
  110597. */
  110598. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110599. /**
  110600. * Luminance steps
  110601. */
  110602. static LuminanceSteps: number;
  110603. }
  110604. }
  110605. declare module BABYLON {
  110606. /** @hidden */
  110607. export var tonemapPixelShader: {
  110608. name: string;
  110609. shader: string;
  110610. };
  110611. }
  110612. declare module BABYLON {
  110613. /** Defines operator used for tonemapping */
  110614. export enum TonemappingOperator {
  110615. /** Hable */
  110616. Hable = 0,
  110617. /** Reinhard */
  110618. Reinhard = 1,
  110619. /** HejiDawson */
  110620. HejiDawson = 2,
  110621. /** Photographic */
  110622. Photographic = 3
  110623. }
  110624. /**
  110625. * Defines a post process to apply tone mapping
  110626. */
  110627. export class TonemapPostProcess extends PostProcess {
  110628. private _operator;
  110629. /** Defines the required exposure adjustement */
  110630. exposureAdjustment: number;
  110631. /**
  110632. * Creates a new TonemapPostProcess
  110633. * @param name defines the name of the postprocess
  110634. * @param _operator defines the operator to use
  110635. * @param exposureAdjustment defines the required exposure adjustement
  110636. * @param camera defines the camera to use (can be null)
  110637. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110638. * @param engine defines the hosting engine (can be ignore if camera is set)
  110639. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110640. */
  110641. constructor(name: string, _operator: TonemappingOperator,
  110642. /** Defines the required exposure adjustement */
  110643. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110644. }
  110645. }
  110646. declare module BABYLON {
  110647. /** @hidden */
  110648. export var depthVertexShader: {
  110649. name: string;
  110650. shader: string;
  110651. };
  110652. }
  110653. declare module BABYLON {
  110654. /** @hidden */
  110655. export var volumetricLightScatteringPixelShader: {
  110656. name: string;
  110657. shader: string;
  110658. };
  110659. }
  110660. declare module BABYLON {
  110661. /** @hidden */
  110662. export var volumetricLightScatteringPassPixelShader: {
  110663. name: string;
  110664. shader: string;
  110665. };
  110666. }
  110667. declare module BABYLON {
  110668. /**
  110669. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110670. */
  110671. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110672. private _volumetricLightScatteringPass;
  110673. private _volumetricLightScatteringRTT;
  110674. private _viewPort;
  110675. private _screenCoordinates;
  110676. private _cachedDefines;
  110677. /**
  110678. * If not undefined, the mesh position is computed from the attached node position
  110679. */
  110680. attachedNode: {
  110681. position: Vector3;
  110682. };
  110683. /**
  110684. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110685. */
  110686. customMeshPosition: Vector3;
  110687. /**
  110688. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110689. */
  110690. useCustomMeshPosition: boolean;
  110691. /**
  110692. * If the post-process should inverse the light scattering direction
  110693. */
  110694. invert: boolean;
  110695. /**
  110696. * The internal mesh used by the post-process
  110697. */
  110698. mesh: Mesh;
  110699. /**
  110700. * @hidden
  110701. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110702. */
  110703. useDiffuseColor: boolean;
  110704. /**
  110705. * Array containing the excluded meshes not rendered in the internal pass
  110706. */
  110707. excludedMeshes: AbstractMesh[];
  110708. /**
  110709. * Controls the overall intensity of the post-process
  110710. */
  110711. exposure: number;
  110712. /**
  110713. * Dissipates each sample's contribution in range [0, 1]
  110714. */
  110715. decay: number;
  110716. /**
  110717. * Controls the overall intensity of each sample
  110718. */
  110719. weight: number;
  110720. /**
  110721. * Controls the density of each sample
  110722. */
  110723. density: number;
  110724. /**
  110725. * @constructor
  110726. * @param name The post-process name
  110727. * @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)
  110728. * @param camera The camera that the post-process will be attached to
  110729. * @param mesh The mesh used to create the light scattering
  110730. * @param samples The post-process quality, default 100
  110731. * @param samplingModeThe post-process filtering mode
  110732. * @param engine The babylon engine
  110733. * @param reusable If the post-process is reusable
  110734. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110735. */
  110736. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110737. /**
  110738. * Returns the string "VolumetricLightScatteringPostProcess"
  110739. * @returns "VolumetricLightScatteringPostProcess"
  110740. */
  110741. getClassName(): string;
  110742. private _isReady;
  110743. /**
  110744. * Sets the new light position for light scattering effect
  110745. * @param position The new custom light position
  110746. */
  110747. setCustomMeshPosition(position: Vector3): void;
  110748. /**
  110749. * Returns the light position for light scattering effect
  110750. * @return Vector3 The custom light position
  110751. */
  110752. getCustomMeshPosition(): Vector3;
  110753. /**
  110754. * Disposes the internal assets and detaches the post-process from the camera
  110755. */
  110756. dispose(camera: Camera): void;
  110757. /**
  110758. * Returns the render target texture used by the post-process
  110759. * @return the render target texture used by the post-process
  110760. */
  110761. getPass(): RenderTargetTexture;
  110762. private _meshExcluded;
  110763. private _createPass;
  110764. private _updateMeshScreenCoordinates;
  110765. /**
  110766. * Creates a default mesh for the Volumeric Light Scattering post-process
  110767. * @param name The mesh name
  110768. * @param scene The scene where to create the mesh
  110769. * @return the default mesh
  110770. */
  110771. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110772. }
  110773. }
  110774. declare module BABYLON {
  110775. interface Scene {
  110776. /** @hidden (Backing field) */
  110777. _boundingBoxRenderer: BoundingBoxRenderer;
  110778. /** @hidden (Backing field) */
  110779. _forceShowBoundingBoxes: boolean;
  110780. /**
  110781. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110782. */
  110783. forceShowBoundingBoxes: boolean;
  110784. /**
  110785. * Gets the bounding box renderer associated with the scene
  110786. * @returns a BoundingBoxRenderer
  110787. */
  110788. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110789. }
  110790. interface AbstractMesh {
  110791. /** @hidden (Backing field) */
  110792. _showBoundingBox: boolean;
  110793. /**
  110794. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110795. */
  110796. showBoundingBox: boolean;
  110797. }
  110798. /**
  110799. * Component responsible of rendering the bounding box of the meshes in a scene.
  110800. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110801. */
  110802. export class BoundingBoxRenderer implements ISceneComponent {
  110803. /**
  110804. * The component name helpfull to identify the component in the list of scene components.
  110805. */
  110806. readonly name: string;
  110807. /**
  110808. * The scene the component belongs to.
  110809. */
  110810. scene: Scene;
  110811. /**
  110812. * Color of the bounding box lines placed in front of an object
  110813. */
  110814. frontColor: Color3;
  110815. /**
  110816. * Color of the bounding box lines placed behind an object
  110817. */
  110818. backColor: Color3;
  110819. /**
  110820. * Defines if the renderer should show the back lines or not
  110821. */
  110822. showBackLines: boolean;
  110823. /**
  110824. * @hidden
  110825. */
  110826. renderList: SmartArray<BoundingBox>;
  110827. private _colorShader;
  110828. private _vertexBuffers;
  110829. private _indexBuffer;
  110830. /**
  110831. * Instantiates a new bounding box renderer in a scene.
  110832. * @param scene the scene the renderer renders in
  110833. */
  110834. constructor(scene: Scene);
  110835. /**
  110836. * Registers the component in a given scene
  110837. */
  110838. register(): void;
  110839. private _evaluateSubMesh;
  110840. private _activeMesh;
  110841. private _prepareRessources;
  110842. private _createIndexBuffer;
  110843. /**
  110844. * Rebuilds the elements related to this component in case of
  110845. * context lost for instance.
  110846. */
  110847. rebuild(): void;
  110848. /**
  110849. * @hidden
  110850. */
  110851. reset(): void;
  110852. /**
  110853. * Render the bounding boxes of a specific rendering group
  110854. * @param renderingGroupId defines the rendering group to render
  110855. */
  110856. render(renderingGroupId: number): void;
  110857. /**
  110858. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110859. * @param mesh Define the mesh to render the occlusion bounding box for
  110860. */
  110861. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110862. /**
  110863. * Dispose and release the resources attached to this renderer.
  110864. */
  110865. dispose(): void;
  110866. }
  110867. }
  110868. declare module BABYLON {
  110869. /** @hidden */
  110870. export var depthPixelShader: {
  110871. name: string;
  110872. shader: string;
  110873. };
  110874. }
  110875. declare module BABYLON {
  110876. /**
  110877. * This represents a depth renderer in Babylon.
  110878. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110879. */
  110880. export class DepthRenderer {
  110881. private _scene;
  110882. private _depthMap;
  110883. private _effect;
  110884. private _cachedDefines;
  110885. private _camera;
  110886. /**
  110887. * Specifiess that the depth renderer will only be used within
  110888. * the camera it is created for.
  110889. * This can help forcing its rendering during the camera processing.
  110890. */
  110891. useOnlyInActiveCamera: boolean;
  110892. /** @hidden */
  110893. static _SceneComponentInitialization: (scene: Scene) => void;
  110894. /**
  110895. * Instantiates a depth renderer
  110896. * @param scene The scene the renderer belongs to
  110897. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110898. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110899. */
  110900. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110901. /**
  110902. * Creates the depth rendering effect and checks if the effect is ready.
  110903. * @param subMesh The submesh to be used to render the depth map of
  110904. * @param useInstances If multiple world instances should be used
  110905. * @returns if the depth renderer is ready to render the depth map
  110906. */
  110907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110908. /**
  110909. * Gets the texture which the depth map will be written to.
  110910. * @returns The depth map texture
  110911. */
  110912. getDepthMap(): RenderTargetTexture;
  110913. /**
  110914. * Disposes of the depth renderer.
  110915. */
  110916. dispose(): void;
  110917. }
  110918. }
  110919. declare module BABYLON {
  110920. interface Scene {
  110921. /** @hidden (Backing field) */
  110922. _depthRenderer: {
  110923. [id: string]: DepthRenderer;
  110924. };
  110925. /**
  110926. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110927. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110928. * @returns the created depth renderer
  110929. */
  110930. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110931. /**
  110932. * Disables a depth renderer for a given camera
  110933. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110934. */
  110935. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110936. }
  110937. /**
  110938. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110939. * in several rendering techniques.
  110940. */
  110941. export class DepthRendererSceneComponent implements ISceneComponent {
  110942. /**
  110943. * The component name helpfull to identify the component in the list of scene components.
  110944. */
  110945. readonly name: string;
  110946. /**
  110947. * The scene the component belongs to.
  110948. */
  110949. scene: Scene;
  110950. /**
  110951. * Creates a new instance of the component for the given scene
  110952. * @param scene Defines the scene to register the component in
  110953. */
  110954. constructor(scene: Scene);
  110955. /**
  110956. * Registers the component in a given scene
  110957. */
  110958. register(): void;
  110959. /**
  110960. * Rebuilds the elements related to this component in case of
  110961. * context lost for instance.
  110962. */
  110963. rebuild(): void;
  110964. /**
  110965. * Disposes the component and the associated ressources
  110966. */
  110967. dispose(): void;
  110968. private _gatherRenderTargets;
  110969. private _gatherActiveCameraRenderTargets;
  110970. }
  110971. }
  110972. declare module BABYLON {
  110973. /** @hidden */
  110974. export var outlinePixelShader: {
  110975. name: string;
  110976. shader: string;
  110977. };
  110978. }
  110979. declare module BABYLON {
  110980. /** @hidden */
  110981. export var outlineVertexShader: {
  110982. name: string;
  110983. shader: string;
  110984. };
  110985. }
  110986. declare module BABYLON {
  110987. interface Scene {
  110988. /** @hidden */
  110989. _outlineRenderer: OutlineRenderer;
  110990. /**
  110991. * Gets the outline renderer associated with the scene
  110992. * @returns a OutlineRenderer
  110993. */
  110994. getOutlineRenderer(): OutlineRenderer;
  110995. }
  110996. interface AbstractMesh {
  110997. /** @hidden (Backing field) */
  110998. _renderOutline: boolean;
  110999. /**
  111000. * Gets or sets a boolean indicating if the outline must be rendered as well
  111001. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  111002. */
  111003. renderOutline: boolean;
  111004. /** @hidden (Backing field) */
  111005. _renderOverlay: boolean;
  111006. /**
  111007. * Gets or sets a boolean indicating if the overlay must be rendered as well
  111008. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  111009. */
  111010. renderOverlay: boolean;
  111011. }
  111012. /**
  111013. * This class is responsible to draw bothe outline/overlay of meshes.
  111014. * It should not be used directly but through the available method on mesh.
  111015. */
  111016. export class OutlineRenderer implements ISceneComponent {
  111017. /**
  111018. * The name of the component. Each component must have a unique name.
  111019. */
  111020. name: string;
  111021. /**
  111022. * The scene the component belongs to.
  111023. */
  111024. scene: Scene;
  111025. /**
  111026. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  111027. */
  111028. zOffset: number;
  111029. private _engine;
  111030. private _effect;
  111031. private _cachedDefines;
  111032. private _savedDepthWrite;
  111033. /**
  111034. * Instantiates a new outline renderer. (There could be only one per scene).
  111035. * @param scene Defines the scene it belongs to
  111036. */
  111037. constructor(scene: Scene);
  111038. /**
  111039. * Register the component to one instance of a scene.
  111040. */
  111041. register(): void;
  111042. /**
  111043. * Rebuilds the elements related to this component in case of
  111044. * context lost for instance.
  111045. */
  111046. rebuild(): void;
  111047. /**
  111048. * Disposes the component and the associated ressources.
  111049. */
  111050. dispose(): void;
  111051. /**
  111052. * Renders the outline in the canvas.
  111053. * @param subMesh Defines the sumesh to render
  111054. * @param batch Defines the batch of meshes in case of instances
  111055. * @param useOverlay Defines if the rendering is for the overlay or the outline
  111056. */
  111057. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  111058. /**
  111059. * Returns whether or not the outline renderer is ready for a given submesh.
  111060. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  111061. * @param subMesh Defines the submesh to check readyness for
  111062. * @param useInstances Defines wheter wee are trying to render instances or not
  111063. * @returns true if ready otherwise false
  111064. */
  111065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111066. private _beforeRenderingMesh;
  111067. private _afterRenderingMesh;
  111068. }
  111069. }
  111070. declare module BABYLON {
  111071. /**
  111072. * Defines the list of states available for a task inside a AssetsManager
  111073. */
  111074. export enum AssetTaskState {
  111075. /**
  111076. * Initialization
  111077. */
  111078. INIT = 0,
  111079. /**
  111080. * Running
  111081. */
  111082. RUNNING = 1,
  111083. /**
  111084. * Done
  111085. */
  111086. DONE = 2,
  111087. /**
  111088. * Error
  111089. */
  111090. ERROR = 3
  111091. }
  111092. /**
  111093. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  111094. */
  111095. export abstract class AbstractAssetTask {
  111096. /**
  111097. * Task name
  111098. */ name: string;
  111099. /**
  111100. * Callback called when the task is successful
  111101. */
  111102. onSuccess: (task: any) => void;
  111103. /**
  111104. * Callback called when the task is not successful
  111105. */
  111106. onError: (task: any, message?: string, exception?: any) => void;
  111107. /**
  111108. * Creates a new AssetsManager
  111109. * @param name defines the name of the task
  111110. */
  111111. constructor(
  111112. /**
  111113. * Task name
  111114. */ name: string);
  111115. private _isCompleted;
  111116. private _taskState;
  111117. private _errorObject;
  111118. /**
  111119. * Get if the task is completed
  111120. */
  111121. readonly isCompleted: boolean;
  111122. /**
  111123. * Gets the current state of the task
  111124. */
  111125. readonly taskState: AssetTaskState;
  111126. /**
  111127. * Gets the current error object (if task is in error)
  111128. */
  111129. readonly errorObject: {
  111130. message?: string;
  111131. exception?: any;
  111132. };
  111133. /**
  111134. * Internal only
  111135. * @hidden
  111136. */
  111137. _setErrorObject(message?: string, exception?: any): void;
  111138. /**
  111139. * Execute the current task
  111140. * @param scene defines the scene where you want your assets to be loaded
  111141. * @param onSuccess is a callback called when the task is successfully executed
  111142. * @param onError is a callback called if an error occurs
  111143. */
  111144. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111145. /**
  111146. * Execute the current task
  111147. * @param scene defines the scene where you want your assets to be loaded
  111148. * @param onSuccess is a callback called when the task is successfully executed
  111149. * @param onError is a callback called if an error occurs
  111150. */
  111151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111152. /**
  111153. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  111154. * This can be used with failed tasks that have the reason for failure fixed.
  111155. */
  111156. reset(): void;
  111157. private onErrorCallback;
  111158. private onDoneCallback;
  111159. }
  111160. /**
  111161. * Define the interface used by progress events raised during assets loading
  111162. */
  111163. export interface IAssetsProgressEvent {
  111164. /**
  111165. * Defines the number of remaining tasks to process
  111166. */
  111167. remainingCount: number;
  111168. /**
  111169. * Defines the total number of tasks
  111170. */
  111171. totalCount: number;
  111172. /**
  111173. * Defines the task that was just processed
  111174. */
  111175. task: AbstractAssetTask;
  111176. }
  111177. /**
  111178. * Class used to share progress information about assets loading
  111179. */
  111180. export class AssetsProgressEvent implements IAssetsProgressEvent {
  111181. /**
  111182. * Defines the number of remaining tasks to process
  111183. */
  111184. remainingCount: number;
  111185. /**
  111186. * Defines the total number of tasks
  111187. */
  111188. totalCount: number;
  111189. /**
  111190. * Defines the task that was just processed
  111191. */
  111192. task: AbstractAssetTask;
  111193. /**
  111194. * Creates a AssetsProgressEvent
  111195. * @param remainingCount defines the number of remaining tasks to process
  111196. * @param totalCount defines the total number of tasks
  111197. * @param task defines the task that was just processed
  111198. */
  111199. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  111200. }
  111201. /**
  111202. * Define a task used by AssetsManager to load meshes
  111203. */
  111204. export class MeshAssetTask extends AbstractAssetTask {
  111205. /**
  111206. * Defines the name of the task
  111207. */
  111208. name: string;
  111209. /**
  111210. * Defines the list of mesh's names you want to load
  111211. */
  111212. meshesNames: any;
  111213. /**
  111214. * Defines the root url to use as a base to load your meshes and associated resources
  111215. */
  111216. rootUrl: string;
  111217. /**
  111218. * Defines the filename of the scene to load from
  111219. */
  111220. sceneFilename: string;
  111221. /**
  111222. * Gets the list of loaded meshes
  111223. */
  111224. loadedMeshes: Array<AbstractMesh>;
  111225. /**
  111226. * Gets the list of loaded particle systems
  111227. */
  111228. loadedParticleSystems: Array<IParticleSystem>;
  111229. /**
  111230. * Gets the list of loaded skeletons
  111231. */
  111232. loadedSkeletons: Array<Skeleton>;
  111233. /**
  111234. * Gets the list of loaded animation groups
  111235. */
  111236. loadedAnimationGroups: Array<AnimationGroup>;
  111237. /**
  111238. * Callback called when the task is successful
  111239. */
  111240. onSuccess: (task: MeshAssetTask) => void;
  111241. /**
  111242. * Callback called when the task is successful
  111243. */
  111244. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  111245. /**
  111246. * Creates a new MeshAssetTask
  111247. * @param name defines the name of the task
  111248. * @param meshesNames defines the list of mesh's names you want to load
  111249. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  111250. * @param sceneFilename defines the filename of the scene to load from
  111251. */
  111252. constructor(
  111253. /**
  111254. * Defines the name of the task
  111255. */
  111256. name: string,
  111257. /**
  111258. * Defines the list of mesh's names you want to load
  111259. */
  111260. meshesNames: any,
  111261. /**
  111262. * Defines the root url to use as a base to load your meshes and associated resources
  111263. */
  111264. rootUrl: string,
  111265. /**
  111266. * Defines the filename of the scene to load from
  111267. */
  111268. sceneFilename: string);
  111269. /**
  111270. * Execute the current task
  111271. * @param scene defines the scene where you want your assets to be loaded
  111272. * @param onSuccess is a callback called when the task is successfully executed
  111273. * @param onError is a callback called if an error occurs
  111274. */
  111275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111276. }
  111277. /**
  111278. * Define a task used by AssetsManager to load text content
  111279. */
  111280. export class TextFileAssetTask extends AbstractAssetTask {
  111281. /**
  111282. * Defines the name of the task
  111283. */
  111284. name: string;
  111285. /**
  111286. * Defines the location of the file to load
  111287. */
  111288. url: string;
  111289. /**
  111290. * Gets the loaded text string
  111291. */
  111292. text: string;
  111293. /**
  111294. * Callback called when the task is successful
  111295. */
  111296. onSuccess: (task: TextFileAssetTask) => void;
  111297. /**
  111298. * Callback called when the task is successful
  111299. */
  111300. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  111301. /**
  111302. * Creates a new TextFileAssetTask object
  111303. * @param name defines the name of the task
  111304. * @param url defines the location of the file to load
  111305. */
  111306. constructor(
  111307. /**
  111308. * Defines the name of the task
  111309. */
  111310. name: string,
  111311. /**
  111312. * Defines the location of the file to load
  111313. */
  111314. url: string);
  111315. /**
  111316. * Execute the current task
  111317. * @param scene defines the scene where you want your assets to be loaded
  111318. * @param onSuccess is a callback called when the task is successfully executed
  111319. * @param onError is a callback called if an error occurs
  111320. */
  111321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111322. }
  111323. /**
  111324. * Define a task used by AssetsManager to load binary data
  111325. */
  111326. export class BinaryFileAssetTask extends AbstractAssetTask {
  111327. /**
  111328. * Defines the name of the task
  111329. */
  111330. name: string;
  111331. /**
  111332. * Defines the location of the file to load
  111333. */
  111334. url: string;
  111335. /**
  111336. * Gets the lodaded data (as an array buffer)
  111337. */
  111338. data: ArrayBuffer;
  111339. /**
  111340. * Callback called when the task is successful
  111341. */
  111342. onSuccess: (task: BinaryFileAssetTask) => void;
  111343. /**
  111344. * Callback called when the task is successful
  111345. */
  111346. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  111347. /**
  111348. * Creates a new BinaryFileAssetTask object
  111349. * @param name defines the name of the new task
  111350. * @param url defines the location of the file to load
  111351. */
  111352. constructor(
  111353. /**
  111354. * Defines the name of the task
  111355. */
  111356. name: string,
  111357. /**
  111358. * Defines the location of the file to load
  111359. */
  111360. url: string);
  111361. /**
  111362. * Execute the current task
  111363. * @param scene defines the scene where you want your assets to be loaded
  111364. * @param onSuccess is a callback called when the task is successfully executed
  111365. * @param onError is a callback called if an error occurs
  111366. */
  111367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111368. }
  111369. /**
  111370. * Define a task used by AssetsManager to load images
  111371. */
  111372. export class ImageAssetTask extends AbstractAssetTask {
  111373. /**
  111374. * Defines the name of the task
  111375. */
  111376. name: string;
  111377. /**
  111378. * Defines the location of the image to load
  111379. */
  111380. url: string;
  111381. /**
  111382. * Gets the loaded images
  111383. */
  111384. image: HTMLImageElement;
  111385. /**
  111386. * Callback called when the task is successful
  111387. */
  111388. onSuccess: (task: ImageAssetTask) => void;
  111389. /**
  111390. * Callback called when the task is successful
  111391. */
  111392. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  111393. /**
  111394. * Creates a new ImageAssetTask
  111395. * @param name defines the name of the task
  111396. * @param url defines the location of the image to load
  111397. */
  111398. constructor(
  111399. /**
  111400. * Defines the name of the task
  111401. */
  111402. name: string,
  111403. /**
  111404. * Defines the location of the image to load
  111405. */
  111406. url: string);
  111407. /**
  111408. * Execute the current task
  111409. * @param scene defines the scene where you want your assets to be loaded
  111410. * @param onSuccess is a callback called when the task is successfully executed
  111411. * @param onError is a callback called if an error occurs
  111412. */
  111413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111414. }
  111415. /**
  111416. * Defines the interface used by texture loading tasks
  111417. */
  111418. export interface ITextureAssetTask<TEX extends BaseTexture> {
  111419. /**
  111420. * Gets the loaded texture
  111421. */
  111422. texture: TEX;
  111423. }
  111424. /**
  111425. * Define a task used by AssetsManager to load 2D textures
  111426. */
  111427. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  111428. /**
  111429. * Defines the name of the task
  111430. */
  111431. name: string;
  111432. /**
  111433. * Defines the location of the file to load
  111434. */
  111435. url: string;
  111436. /**
  111437. * Defines if mipmap should not be generated (default is false)
  111438. */
  111439. noMipmap?: boolean | undefined;
  111440. /**
  111441. * Defines if texture must be inverted on Y axis (default is false)
  111442. */
  111443. invertY?: boolean | undefined;
  111444. /**
  111445. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111446. */
  111447. samplingMode: number;
  111448. /**
  111449. * Gets the loaded texture
  111450. */
  111451. texture: Texture;
  111452. /**
  111453. * Callback called when the task is successful
  111454. */
  111455. onSuccess: (task: TextureAssetTask) => void;
  111456. /**
  111457. * Callback called when the task is successful
  111458. */
  111459. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  111460. /**
  111461. * Creates a new TextureAssetTask object
  111462. * @param name defines the name of the task
  111463. * @param url defines the location of the file to load
  111464. * @param noMipmap defines if mipmap should not be generated (default is false)
  111465. * @param invertY defines if texture must be inverted on Y axis (default is false)
  111466. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111467. */
  111468. constructor(
  111469. /**
  111470. * Defines the name of the task
  111471. */
  111472. name: string,
  111473. /**
  111474. * Defines the location of the file to load
  111475. */
  111476. url: string,
  111477. /**
  111478. * Defines if mipmap should not be generated (default is false)
  111479. */
  111480. noMipmap?: boolean | undefined,
  111481. /**
  111482. * Defines if texture must be inverted on Y axis (default is false)
  111483. */
  111484. invertY?: boolean | undefined,
  111485. /**
  111486. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111487. */
  111488. samplingMode?: number);
  111489. /**
  111490. * Execute the current task
  111491. * @param scene defines the scene where you want your assets to be loaded
  111492. * @param onSuccess is a callback called when the task is successfully executed
  111493. * @param onError is a callback called if an error occurs
  111494. */
  111495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111496. }
  111497. /**
  111498. * Define a task used by AssetsManager to load cube textures
  111499. */
  111500. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111501. /**
  111502. * Defines the name of the task
  111503. */
  111504. name: string;
  111505. /**
  111506. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111507. */
  111508. url: string;
  111509. /**
  111510. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111511. */
  111512. extensions?: string[] | undefined;
  111513. /**
  111514. * Defines if mipmaps should not be generated (default is false)
  111515. */
  111516. noMipmap?: boolean | undefined;
  111517. /**
  111518. * Defines the explicit list of files (undefined by default)
  111519. */
  111520. files?: string[] | undefined;
  111521. /**
  111522. * Gets the loaded texture
  111523. */
  111524. texture: CubeTexture;
  111525. /**
  111526. * Callback called when the task is successful
  111527. */
  111528. onSuccess: (task: CubeTextureAssetTask) => void;
  111529. /**
  111530. * Callback called when the task is successful
  111531. */
  111532. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111533. /**
  111534. * Creates a new CubeTextureAssetTask
  111535. * @param name defines the name of the task
  111536. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111537. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111538. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111539. * @param files defines the explicit list of files (undefined by default)
  111540. */
  111541. constructor(
  111542. /**
  111543. * Defines the name of the task
  111544. */
  111545. name: string,
  111546. /**
  111547. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111548. */
  111549. url: string,
  111550. /**
  111551. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111552. */
  111553. extensions?: string[] | undefined,
  111554. /**
  111555. * Defines if mipmaps should not be generated (default is false)
  111556. */
  111557. noMipmap?: boolean | undefined,
  111558. /**
  111559. * Defines the explicit list of files (undefined by default)
  111560. */
  111561. files?: string[] | undefined);
  111562. /**
  111563. * Execute the current task
  111564. * @param scene defines the scene where you want your assets to be loaded
  111565. * @param onSuccess is a callback called when the task is successfully executed
  111566. * @param onError is a callback called if an error occurs
  111567. */
  111568. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111569. }
  111570. /**
  111571. * Define a task used by AssetsManager to load HDR cube textures
  111572. */
  111573. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111574. /**
  111575. * Defines the name of the task
  111576. */
  111577. name: string;
  111578. /**
  111579. * Defines the location of the file to load
  111580. */
  111581. url: string;
  111582. /**
  111583. * Defines the desired size (the more it increases the longer the generation will be)
  111584. */
  111585. size: number;
  111586. /**
  111587. * Defines if mipmaps should not be generated (default is false)
  111588. */
  111589. noMipmap: boolean;
  111590. /**
  111591. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111592. */
  111593. generateHarmonics: boolean;
  111594. /**
  111595. * 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)
  111596. */
  111597. gammaSpace: boolean;
  111598. /**
  111599. * Internal Use Only
  111600. */
  111601. reserved: boolean;
  111602. /**
  111603. * Gets the loaded texture
  111604. */
  111605. texture: HDRCubeTexture;
  111606. /**
  111607. * Callback called when the task is successful
  111608. */
  111609. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111610. /**
  111611. * Callback called when the task is successful
  111612. */
  111613. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111614. /**
  111615. * Creates a new HDRCubeTextureAssetTask object
  111616. * @param name defines the name of the task
  111617. * @param url defines the location of the file to load
  111618. * @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.
  111619. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111620. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111621. * @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)
  111622. * @param reserved Internal use only
  111623. */
  111624. constructor(
  111625. /**
  111626. * Defines the name of the task
  111627. */
  111628. name: string,
  111629. /**
  111630. * Defines the location of the file to load
  111631. */
  111632. url: string,
  111633. /**
  111634. * Defines the desired size (the more it increases the longer the generation will be)
  111635. */
  111636. size: number,
  111637. /**
  111638. * Defines if mipmaps should not be generated (default is false)
  111639. */
  111640. noMipmap?: boolean,
  111641. /**
  111642. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111643. */
  111644. generateHarmonics?: boolean,
  111645. /**
  111646. * 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)
  111647. */
  111648. gammaSpace?: boolean,
  111649. /**
  111650. * Internal Use Only
  111651. */
  111652. reserved?: boolean);
  111653. /**
  111654. * Execute the current task
  111655. * @param scene defines the scene where you want your assets to be loaded
  111656. * @param onSuccess is a callback called when the task is successfully executed
  111657. * @param onError is a callback called if an error occurs
  111658. */
  111659. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111660. }
  111661. /**
  111662. * This class can be used to easily import assets into a scene
  111663. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111664. */
  111665. export class AssetsManager {
  111666. private _scene;
  111667. private _isLoading;
  111668. protected _tasks: AbstractAssetTask[];
  111669. protected _waitingTasksCount: number;
  111670. protected _totalTasksCount: number;
  111671. /**
  111672. * Callback called when all tasks are processed
  111673. */
  111674. onFinish: (tasks: AbstractAssetTask[]) => void;
  111675. /**
  111676. * Callback called when a task is successful
  111677. */
  111678. onTaskSuccess: (task: AbstractAssetTask) => void;
  111679. /**
  111680. * Callback called when a task had an error
  111681. */
  111682. onTaskError: (task: AbstractAssetTask) => void;
  111683. /**
  111684. * Callback called when a task is done (whatever the result is)
  111685. */
  111686. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111687. /**
  111688. * Observable called when all tasks are processed
  111689. */
  111690. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111691. /**
  111692. * Observable called when a task had an error
  111693. */
  111694. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111695. /**
  111696. * Observable called when all tasks were executed
  111697. */
  111698. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111699. /**
  111700. * Observable called when a task is done (whatever the result is)
  111701. */
  111702. onProgressObservable: Observable<IAssetsProgressEvent>;
  111703. /**
  111704. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111705. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111706. */
  111707. useDefaultLoadingScreen: boolean;
  111708. /**
  111709. * Creates a new AssetsManager
  111710. * @param scene defines the scene to work on
  111711. */
  111712. constructor(scene: Scene);
  111713. /**
  111714. * Add a MeshAssetTask to the list of active tasks
  111715. * @param taskName defines the name of the new task
  111716. * @param meshesNames defines the name of meshes to load
  111717. * @param rootUrl defines the root url to use to locate files
  111718. * @param sceneFilename defines the filename of the scene file
  111719. * @returns a new MeshAssetTask object
  111720. */
  111721. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111722. /**
  111723. * Add a TextFileAssetTask to the list of active tasks
  111724. * @param taskName defines the name of the new task
  111725. * @param url defines the url of the file to load
  111726. * @returns a new TextFileAssetTask object
  111727. */
  111728. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111729. /**
  111730. * Add a BinaryFileAssetTask to the list of active tasks
  111731. * @param taskName defines the name of the new task
  111732. * @param url defines the url of the file to load
  111733. * @returns a new BinaryFileAssetTask object
  111734. */
  111735. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111736. /**
  111737. * Add a ImageAssetTask to the list of active tasks
  111738. * @param taskName defines the name of the new task
  111739. * @param url defines the url of the file to load
  111740. * @returns a new ImageAssetTask object
  111741. */
  111742. addImageTask(taskName: string, url: string): ImageAssetTask;
  111743. /**
  111744. * Add a TextureAssetTask to the list of active tasks
  111745. * @param taskName defines the name of the new task
  111746. * @param url defines the url of the file to load
  111747. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111748. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111749. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111750. * @returns a new TextureAssetTask object
  111751. */
  111752. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111753. /**
  111754. * Add a CubeTextureAssetTask to the list of active tasks
  111755. * @param taskName defines the name of the new task
  111756. * @param url defines the url of the file to load
  111757. * @param extensions defines the extension to use to load the cube map (can be null)
  111758. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111759. * @param files defines the list of files to load (can be null)
  111760. * @returns a new CubeTextureAssetTask object
  111761. */
  111762. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111763. /**
  111764. *
  111765. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111766. * @param taskName defines the name of the new task
  111767. * @param url defines the url of the file to load
  111768. * @param size defines the size you want for the cubemap (can be null)
  111769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111770. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111771. * @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)
  111772. * @param reserved Internal use only
  111773. * @returns a new HDRCubeTextureAssetTask object
  111774. */
  111775. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111776. /**
  111777. * Remove a task from the assets manager.
  111778. * @param task the task to remove
  111779. */
  111780. removeTask(task: AbstractAssetTask): void;
  111781. private _decreaseWaitingTasksCount;
  111782. private _runTask;
  111783. /**
  111784. * Reset the AssetsManager and remove all tasks
  111785. * @return the current instance of the AssetsManager
  111786. */
  111787. reset(): AssetsManager;
  111788. /**
  111789. * Start the loading process
  111790. * @return the current instance of the AssetsManager
  111791. */
  111792. load(): AssetsManager;
  111793. /**
  111794. * Start the loading process as an async operation
  111795. * @return a promise returning the list of failed tasks
  111796. */
  111797. loadAsync(): Promise<void>;
  111798. }
  111799. }
  111800. declare module BABYLON {
  111801. /**
  111802. * Wrapper class for promise with external resolve and reject.
  111803. */
  111804. export class Deferred<T> {
  111805. /**
  111806. * The promise associated with this deferred object.
  111807. */
  111808. readonly promise: Promise<T>;
  111809. private _resolve;
  111810. private _reject;
  111811. /**
  111812. * The resolve method of the promise associated with this deferred object.
  111813. */
  111814. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111815. /**
  111816. * The reject method of the promise associated with this deferred object.
  111817. */
  111818. readonly reject: (reason?: any) => void;
  111819. /**
  111820. * Constructor for this deferred object.
  111821. */
  111822. constructor();
  111823. }
  111824. }
  111825. declare module BABYLON {
  111826. /**
  111827. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  111828. */
  111829. export class MeshExploder {
  111830. private _centerMesh;
  111831. private _meshes;
  111832. private _meshesOrigins;
  111833. private _toCenterVectors;
  111834. private _scaledDirection;
  111835. private _newPosition;
  111836. private _centerPosition;
  111837. /**
  111838. * Explodes meshes from a center mesh.
  111839. * @param meshes The meshes to explode.
  111840. * @param centerMesh The mesh to be center of explosion.
  111841. */
  111842. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  111843. private _setCenterMesh;
  111844. /**
  111845. * Get class name
  111846. * @returns "MeshExploder"
  111847. */
  111848. getClassName(): string;
  111849. /**
  111850. * "Exploded meshes"
  111851. * @returns Array of meshes with the centerMesh at index 0.
  111852. */
  111853. getMeshes(): Array<Mesh>;
  111854. /**
  111855. * Explodes meshes giving a specific direction
  111856. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  111857. */
  111858. explode(direction?: number): void;
  111859. }
  111860. }
  111861. declare module BABYLON {
  111862. /**
  111863. * Class used to help managing file picking and drag'n'drop
  111864. */
  111865. export class FilesInput {
  111866. /**
  111867. * List of files ready to be loaded
  111868. */
  111869. static readonly FilesToLoad: {
  111870. [key: string]: File;
  111871. };
  111872. /**
  111873. * Callback called when a file is processed
  111874. */
  111875. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111876. private _engine;
  111877. private _currentScene;
  111878. private _sceneLoadedCallback;
  111879. private _progressCallback;
  111880. private _additionalRenderLoopLogicCallback;
  111881. private _textureLoadingCallback;
  111882. private _startingProcessingFilesCallback;
  111883. private _onReloadCallback;
  111884. private _errorCallback;
  111885. private _elementToMonitor;
  111886. private _sceneFileToLoad;
  111887. private _filesToLoad;
  111888. /**
  111889. * Creates a new FilesInput
  111890. * @param engine defines the rendering engine
  111891. * @param scene defines the hosting scene
  111892. * @param sceneLoadedCallback callback called when scene is loaded
  111893. * @param progressCallback callback called to track progress
  111894. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111895. * @param textureLoadingCallback callback called when a texture is loading
  111896. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111897. * @param onReloadCallback callback called when a reload is requested
  111898. * @param errorCallback callback call if an error occurs
  111899. */
  111900. 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);
  111901. private _dragEnterHandler;
  111902. private _dragOverHandler;
  111903. private _dropHandler;
  111904. /**
  111905. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111906. * @param elementToMonitor defines the DOM element to track
  111907. */
  111908. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111909. /**
  111910. * Release all associated resources
  111911. */
  111912. dispose(): void;
  111913. private renderFunction;
  111914. private drag;
  111915. private drop;
  111916. private _traverseFolder;
  111917. private _processFiles;
  111918. /**
  111919. * Load files from a drop event
  111920. * @param event defines the drop event to use as source
  111921. */
  111922. loadFiles(event: any): void;
  111923. private _processReload;
  111924. /**
  111925. * Reload the current scene from the loaded files
  111926. */
  111927. reload(): void;
  111928. }
  111929. }
  111930. declare module BABYLON {
  111931. /**
  111932. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111934. */
  111935. export class SceneOptimization {
  111936. /**
  111937. * Defines the priority of this optimization (0 by default which means first in the list)
  111938. */
  111939. priority: number;
  111940. /**
  111941. * Gets a string describing the action executed by the current optimization
  111942. * @returns description string
  111943. */
  111944. getDescription(): string;
  111945. /**
  111946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111947. * @param scene defines the current scene where to apply this optimization
  111948. * @param optimizer defines the current optimizer
  111949. * @returns true if everything that can be done was applied
  111950. */
  111951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111952. /**
  111953. * Creates the SceneOptimization object
  111954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111955. * @param desc defines the description associated with the optimization
  111956. */
  111957. constructor(
  111958. /**
  111959. * Defines the priority of this optimization (0 by default which means first in the list)
  111960. */
  111961. priority?: number);
  111962. }
  111963. /**
  111964. * Defines an optimization used to reduce the size of render target textures
  111965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111966. */
  111967. export class TextureOptimization extends SceneOptimization {
  111968. /**
  111969. * Defines the priority of this optimization (0 by default which means first in the list)
  111970. */
  111971. priority: number;
  111972. /**
  111973. * 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
  111974. */
  111975. maximumSize: number;
  111976. /**
  111977. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111978. */
  111979. step: number;
  111980. /**
  111981. * Gets a string describing the action executed by the current optimization
  111982. * @returns description string
  111983. */
  111984. getDescription(): string;
  111985. /**
  111986. * Creates the TextureOptimization object
  111987. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111988. * @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
  111989. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111990. */
  111991. constructor(
  111992. /**
  111993. * Defines the priority of this optimization (0 by default which means first in the list)
  111994. */
  111995. priority?: number,
  111996. /**
  111997. * 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
  111998. */
  111999. maximumSize?: number,
  112000. /**
  112001. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112002. */
  112003. step?: number);
  112004. /**
  112005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112006. * @param scene defines the current scene where to apply this optimization
  112007. * @param optimizer defines the current optimizer
  112008. * @returns true if everything that can be done was applied
  112009. */
  112010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112011. }
  112012. /**
  112013. * Defines an optimization used to increase or decrease the rendering resolution
  112014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112015. */
  112016. export class HardwareScalingOptimization extends SceneOptimization {
  112017. /**
  112018. * Defines the priority of this optimization (0 by default which means first in the list)
  112019. */
  112020. priority: number;
  112021. /**
  112022. * Defines the maximum scale to use (2 by default)
  112023. */
  112024. maximumScale: number;
  112025. /**
  112026. * Defines the step to use between two passes (0.5 by default)
  112027. */
  112028. step: number;
  112029. private _currentScale;
  112030. private _directionOffset;
  112031. /**
  112032. * Gets a string describing the action executed by the current optimization
  112033. * @return description string
  112034. */
  112035. getDescription(): string;
  112036. /**
  112037. * Creates the HardwareScalingOptimization object
  112038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112039. * @param maximumScale defines the maximum scale to use (2 by default)
  112040. * @param step defines the step to use between two passes (0.5 by default)
  112041. */
  112042. constructor(
  112043. /**
  112044. * Defines the priority of this optimization (0 by default which means first in the list)
  112045. */
  112046. priority?: number,
  112047. /**
  112048. * Defines the maximum scale to use (2 by default)
  112049. */
  112050. maximumScale?: number,
  112051. /**
  112052. * Defines the step to use between two passes (0.5 by default)
  112053. */
  112054. step?: number);
  112055. /**
  112056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112057. * @param scene defines the current scene where to apply this optimization
  112058. * @param optimizer defines the current optimizer
  112059. * @returns true if everything that can be done was applied
  112060. */
  112061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112062. }
  112063. /**
  112064. * Defines an optimization used to remove shadows
  112065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112066. */
  112067. export class ShadowsOptimization extends SceneOptimization {
  112068. /**
  112069. * Gets a string describing the action executed by the current optimization
  112070. * @return description string
  112071. */
  112072. getDescription(): string;
  112073. /**
  112074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112075. * @param scene defines the current scene where to apply this optimization
  112076. * @param optimizer defines the current optimizer
  112077. * @returns true if everything that can be done was applied
  112078. */
  112079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112080. }
  112081. /**
  112082. * Defines an optimization used to turn post-processes off
  112083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112084. */
  112085. export class PostProcessesOptimization extends SceneOptimization {
  112086. /**
  112087. * Gets a string describing the action executed by the current optimization
  112088. * @return description string
  112089. */
  112090. getDescription(): string;
  112091. /**
  112092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112093. * @param scene defines the current scene where to apply this optimization
  112094. * @param optimizer defines the current optimizer
  112095. * @returns true if everything that can be done was applied
  112096. */
  112097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112098. }
  112099. /**
  112100. * Defines an optimization used to turn lens flares off
  112101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112102. */
  112103. export class LensFlaresOptimization extends SceneOptimization {
  112104. /**
  112105. * Gets a string describing the action executed by the current optimization
  112106. * @return description string
  112107. */
  112108. getDescription(): string;
  112109. /**
  112110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112111. * @param scene defines the current scene where to apply this optimization
  112112. * @param optimizer defines the current optimizer
  112113. * @returns true if everything that can be done was applied
  112114. */
  112115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112116. }
  112117. /**
  112118. * Defines an optimization based on user defined callback.
  112119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112120. */
  112121. export class CustomOptimization extends SceneOptimization {
  112122. /**
  112123. * Callback called to apply the custom optimization.
  112124. */
  112125. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  112126. /**
  112127. * Callback called to get custom description
  112128. */
  112129. onGetDescription: () => string;
  112130. /**
  112131. * Gets a string describing the action executed by the current optimization
  112132. * @returns description string
  112133. */
  112134. getDescription(): string;
  112135. /**
  112136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112137. * @param scene defines the current scene where to apply this optimization
  112138. * @param optimizer defines the current optimizer
  112139. * @returns true if everything that can be done was applied
  112140. */
  112141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112142. }
  112143. /**
  112144. * Defines an optimization used to turn particles off
  112145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112146. */
  112147. export class ParticlesOptimization extends SceneOptimization {
  112148. /**
  112149. * Gets a string describing the action executed by the current optimization
  112150. * @return description string
  112151. */
  112152. getDescription(): string;
  112153. /**
  112154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112155. * @param scene defines the current scene where to apply this optimization
  112156. * @param optimizer defines the current optimizer
  112157. * @returns true if everything that can be done was applied
  112158. */
  112159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112160. }
  112161. /**
  112162. * Defines an optimization used to turn render targets off
  112163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112164. */
  112165. export class RenderTargetsOptimization extends SceneOptimization {
  112166. /**
  112167. * Gets a string describing the action executed by the current optimization
  112168. * @return description string
  112169. */
  112170. getDescription(): string;
  112171. /**
  112172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112173. * @param scene defines the current scene where to apply this optimization
  112174. * @param optimizer defines the current optimizer
  112175. * @returns true if everything that can be done was applied
  112176. */
  112177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112178. }
  112179. /**
  112180. * Defines an optimization used to merge meshes with compatible materials
  112181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112182. */
  112183. export class MergeMeshesOptimization extends SceneOptimization {
  112184. private static _UpdateSelectionTree;
  112185. /**
  112186. * Gets or sets a boolean which defines if optimization octree has to be updated
  112187. */
  112188. /**
  112189. * Gets or sets a boolean which defines if optimization octree has to be updated
  112190. */
  112191. static UpdateSelectionTree: boolean;
  112192. /**
  112193. * Gets a string describing the action executed by the current optimization
  112194. * @return description string
  112195. */
  112196. getDescription(): string;
  112197. private _canBeMerged;
  112198. /**
  112199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112200. * @param scene defines the current scene where to apply this optimization
  112201. * @param optimizer defines the current optimizer
  112202. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  112203. * @returns true if everything that can be done was applied
  112204. */
  112205. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  112206. }
  112207. /**
  112208. * Defines a list of options used by SceneOptimizer
  112209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112210. */
  112211. export class SceneOptimizerOptions {
  112212. /**
  112213. * Defines the target frame rate to reach (60 by default)
  112214. */
  112215. targetFrameRate: number;
  112216. /**
  112217. * Defines the interval between two checkes (2000ms by default)
  112218. */
  112219. trackerDuration: number;
  112220. /**
  112221. * Gets the list of optimizations to apply
  112222. */
  112223. optimizations: SceneOptimization[];
  112224. /**
  112225. * Creates a new list of options used by SceneOptimizer
  112226. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  112227. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  112228. */
  112229. constructor(
  112230. /**
  112231. * Defines the target frame rate to reach (60 by default)
  112232. */
  112233. targetFrameRate?: number,
  112234. /**
  112235. * Defines the interval between two checkes (2000ms by default)
  112236. */
  112237. trackerDuration?: number);
  112238. /**
  112239. * Add a new optimization
  112240. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  112241. * @returns the current SceneOptimizerOptions
  112242. */
  112243. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  112244. /**
  112245. * Add a new custom optimization
  112246. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  112247. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  112248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112249. * @returns the current SceneOptimizerOptions
  112250. */
  112251. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  112252. /**
  112253. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  112254. * @param targetFrameRate defines the target frame rate (60 by default)
  112255. * @returns a SceneOptimizerOptions object
  112256. */
  112257. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112258. /**
  112259. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  112260. * @param targetFrameRate defines the target frame rate (60 by default)
  112261. * @returns a SceneOptimizerOptions object
  112262. */
  112263. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112264. /**
  112265. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  112266. * @param targetFrameRate defines the target frame rate (60 by default)
  112267. * @returns a SceneOptimizerOptions object
  112268. */
  112269. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112270. }
  112271. /**
  112272. * Class used to run optimizations in order to reach a target frame rate
  112273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112274. */
  112275. export class SceneOptimizer implements IDisposable {
  112276. private _isRunning;
  112277. private _options;
  112278. private _scene;
  112279. private _currentPriorityLevel;
  112280. private _targetFrameRate;
  112281. private _trackerDuration;
  112282. private _currentFrameRate;
  112283. private _sceneDisposeObserver;
  112284. private _improvementMode;
  112285. /**
  112286. * Defines an observable called when the optimizer reaches the target frame rate
  112287. */
  112288. onSuccessObservable: Observable<SceneOptimizer>;
  112289. /**
  112290. * Defines an observable called when the optimizer enables an optimization
  112291. */
  112292. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  112293. /**
  112294. * Defines an observable called when the optimizer is not able to reach the target frame rate
  112295. */
  112296. onFailureObservable: Observable<SceneOptimizer>;
  112297. /**
  112298. * Gets a boolean indicating if the optimizer is in improvement mode
  112299. */
  112300. readonly isInImprovementMode: boolean;
  112301. /**
  112302. * Gets the current priority level (0 at start)
  112303. */
  112304. readonly currentPriorityLevel: number;
  112305. /**
  112306. * Gets the current frame rate checked by the SceneOptimizer
  112307. */
  112308. readonly currentFrameRate: number;
  112309. /**
  112310. * Gets or sets the current target frame rate (60 by default)
  112311. */
  112312. /**
  112313. * Gets or sets the current target frame rate (60 by default)
  112314. */
  112315. targetFrameRate: number;
  112316. /**
  112317. * Gets or sets the current interval between two checks (every 2000ms by default)
  112318. */
  112319. /**
  112320. * Gets or sets the current interval between two checks (every 2000ms by default)
  112321. */
  112322. trackerDuration: number;
  112323. /**
  112324. * Gets the list of active optimizations
  112325. */
  112326. readonly optimizations: SceneOptimization[];
  112327. /**
  112328. * Creates a new SceneOptimizer
  112329. * @param scene defines the scene to work on
  112330. * @param options defines the options to use with the SceneOptimizer
  112331. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  112332. * @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)
  112333. */
  112334. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  112335. /**
  112336. * Stops the current optimizer
  112337. */
  112338. stop(): void;
  112339. /**
  112340. * Reset the optimizer to initial step (current priority level = 0)
  112341. */
  112342. reset(): void;
  112343. /**
  112344. * Start the optimizer. By default it will try to reach a specific framerate
  112345. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  112346. */
  112347. start(): void;
  112348. private _checkCurrentState;
  112349. /**
  112350. * Release all resources
  112351. */
  112352. dispose(): void;
  112353. /**
  112354. * Helper function to create a SceneOptimizer with one single line of code
  112355. * @param scene defines the scene to work on
  112356. * @param options defines the options to use with the SceneOptimizer
  112357. * @param onSuccess defines a callback to call on success
  112358. * @param onFailure defines a callback to call on failure
  112359. * @returns the new SceneOptimizer object
  112360. */
  112361. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  112362. }
  112363. }
  112364. declare module BABYLON {
  112365. /**
  112366. * Class used to serialize a scene into a string
  112367. */
  112368. export class SceneSerializer {
  112369. /**
  112370. * Clear cache used by a previous serialization
  112371. */
  112372. static ClearCache(): void;
  112373. /**
  112374. * Serialize a scene into a JSON compatible object
  112375. * @param scene defines the scene to serialize
  112376. * @returns a JSON compatible object
  112377. */
  112378. static Serialize(scene: Scene): any;
  112379. /**
  112380. * Serialize a mesh into a JSON compatible object
  112381. * @param toSerialize defines the mesh to serialize
  112382. * @param withParents defines if parents must be serialized as well
  112383. * @param withChildren defines if children must be serialized as well
  112384. * @returns a JSON compatible object
  112385. */
  112386. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  112387. }
  112388. }
  112389. declare module BABYLON {
  112390. /**
  112391. * This represents the different options avilable for the video capture.
  112392. */
  112393. export interface VideoRecorderOptions {
  112394. /** Defines the mime type of the video */
  112395. mimeType: string;
  112396. /** Defines the video the video should be recorded at */
  112397. fps: number;
  112398. /** Defines the chunk size for the recording data */
  112399. recordChunckSize: number;
  112400. /** The audio tracks to attach to the record */
  112401. audioTracks?: MediaStreamTrack[];
  112402. }
  112403. /**
  112404. * This can helps recording videos from BabylonJS.
  112405. * This is based on the available WebRTC functionalities of the browser.
  112406. *
  112407. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  112408. */
  112409. export class VideoRecorder {
  112410. private static readonly _defaultOptions;
  112411. /**
  112412. * Returns wehther or not the VideoRecorder is available in your browser.
  112413. * @param engine Defines the Babylon Engine to check the support for
  112414. * @returns true if supported otherwise false
  112415. */
  112416. static IsSupported(engine: Engine): boolean;
  112417. private readonly _options;
  112418. private _canvas;
  112419. private _mediaRecorder;
  112420. private _recordedChunks;
  112421. private _fileName;
  112422. private _resolve;
  112423. private _reject;
  112424. /**
  112425. * True wether a recording is already in progress.
  112426. */
  112427. readonly isRecording: boolean;
  112428. /**
  112429. * Create a new VideoCapture object which can help converting what you see in Babylon to
  112430. * a video file.
  112431. * @param engine Defines the BabylonJS Engine you wish to record
  112432. * @param options Defines options that can be used to customized the capture
  112433. */
  112434. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  112435. /**
  112436. * Stops the current recording before the default capture timeout passed in the startRecording
  112437. * functions.
  112438. */
  112439. stopRecording(): void;
  112440. /**
  112441. * Starts recording the canvas for a max duration specified in parameters.
  112442. * @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.
  112443. * @param maxDuration Defines the maximum recording time in seconds.
  112444. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  112445. * @return a promise callback at the end of the recording with the video data in Blob.
  112446. */
  112447. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  112448. /**
  112449. * Releases internal resources used during the recording.
  112450. */
  112451. dispose(): void;
  112452. private _handleDataAvailable;
  112453. private _handleError;
  112454. private _handleStop;
  112455. }
  112456. }
  112457. declare module BABYLON {
  112458. /**
  112459. * Helper class to push actions to a pool of workers.
  112460. */
  112461. export class WorkerPool implements IDisposable {
  112462. private _workerInfos;
  112463. private _pendingActions;
  112464. /**
  112465. * Constructor
  112466. * @param workers Array of workers to use for actions
  112467. */
  112468. constructor(workers: Array<Worker>);
  112469. /**
  112470. * Terminates all workers and clears any pending actions.
  112471. */
  112472. dispose(): void;
  112473. /**
  112474. * Pushes an action to the worker pool. If all the workers are active, the action will be
  112475. * pended until a worker has completed its action.
  112476. * @param action The action to perform. Call onComplete when the action is complete.
  112477. */
  112478. push(action: (worker: Worker, onComplete: () => void) => void): void;
  112479. private _execute;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * Class containing a set of static utilities functions for screenshots
  112485. */
  112486. export class ScreenshotTools {
  112487. /**
  112488. * Captures a screenshot of the current rendering
  112489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112490. * @param engine defines the rendering engine
  112491. * @param camera defines the source camera
  112492. * @param size This parameter can be set to a single number or to an object with the
  112493. * following (optional) properties: precision, width, height. If a single number is passed,
  112494. * it will be used for both width and height. If an object is passed, the screenshot size
  112495. * will be derived from the parameters. The precision property is a multiplier allowing
  112496. * rendering at a higher or lower resolution
  112497. * @param successCallback defines the callback receives a single parameter which contains the
  112498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112499. * src parameter of an <img> to display it
  112500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  112501. * Check your browser for supported MIME types
  112502. */
  112503. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  112504. /**
  112505. * Generates an image screenshot from the specified camera.
  112506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112507. * @param engine The engine to use for rendering
  112508. * @param camera The camera to use for rendering
  112509. * @param size This parameter can be set to a single number or to an object with the
  112510. * following (optional) properties: precision, width, height. If a single number is passed,
  112511. * it will be used for both width and height. If an object is passed, the screenshot size
  112512. * will be derived from the parameters. The precision property is a multiplier allowing
  112513. * rendering at a higher or lower resolution
  112514. * @param successCallback The callback receives a single parameter which contains the
  112515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112516. * src parameter of an <img> to display it
  112517. * @param mimeType The MIME type of the screenshot image (default: image/png).
  112518. * Check your browser for supported MIME types
  112519. * @param samples Texture samples (default: 1)
  112520. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112521. * @param fileName A name for for the downloaded file.
  112522. */
  112523. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112524. }
  112525. }
  112526. declare module BABYLON {
  112527. /**
  112528. * A cursor which tracks a point on a path
  112529. */
  112530. export class PathCursor {
  112531. private path;
  112532. /**
  112533. * Stores path cursor callbacks for when an onchange event is triggered
  112534. */
  112535. private _onchange;
  112536. /**
  112537. * The value of the path cursor
  112538. */
  112539. value: number;
  112540. /**
  112541. * The animation array of the path cursor
  112542. */
  112543. animations: Animation[];
  112544. /**
  112545. * Initializes the path cursor
  112546. * @param path The path to track
  112547. */
  112548. constructor(path: Path2);
  112549. /**
  112550. * Gets the cursor point on the path
  112551. * @returns A point on the path cursor at the cursor location
  112552. */
  112553. getPoint(): Vector3;
  112554. /**
  112555. * Moves the cursor ahead by the step amount
  112556. * @param step The amount to move the cursor forward
  112557. * @returns This path cursor
  112558. */
  112559. moveAhead(step?: number): PathCursor;
  112560. /**
  112561. * Moves the cursor behind by the step amount
  112562. * @param step The amount to move the cursor back
  112563. * @returns This path cursor
  112564. */
  112565. moveBack(step?: number): PathCursor;
  112566. /**
  112567. * Moves the cursor by the step amount
  112568. * If the step amount is greater than one, an exception is thrown
  112569. * @param step The amount to move the cursor
  112570. * @returns This path cursor
  112571. */
  112572. move(step: number): PathCursor;
  112573. /**
  112574. * Ensures that the value is limited between zero and one
  112575. * @returns This path cursor
  112576. */
  112577. private ensureLimits;
  112578. /**
  112579. * Runs onchange callbacks on change (used by the animation engine)
  112580. * @returns This path cursor
  112581. */
  112582. private raiseOnChange;
  112583. /**
  112584. * Executes a function on change
  112585. * @param f A path cursor onchange callback
  112586. * @returns This path cursor
  112587. */
  112588. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112589. }
  112590. }
  112591. declare module BABYLON {
  112592. /** @hidden */
  112593. export var blurPixelShader: {
  112594. name: string;
  112595. shader: string;
  112596. };
  112597. }
  112598. declare module BABYLON {
  112599. /** @hidden */
  112600. export var bones300Declaration: {
  112601. name: string;
  112602. shader: string;
  112603. };
  112604. }
  112605. declare module BABYLON {
  112606. /** @hidden */
  112607. export var instances300Declaration: {
  112608. name: string;
  112609. shader: string;
  112610. };
  112611. }
  112612. declare module BABYLON {
  112613. /** @hidden */
  112614. export var pointCloudVertexDeclaration: {
  112615. name: string;
  112616. shader: string;
  112617. };
  112618. }
  112619. // Mixins
  112620. interface Window {
  112621. mozIndexedDB: IDBFactory;
  112622. webkitIndexedDB: IDBFactory;
  112623. msIndexedDB: IDBFactory;
  112624. webkitURL: typeof URL;
  112625. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112626. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112627. WebGLRenderingContext: WebGLRenderingContext;
  112628. MSGesture: MSGesture;
  112629. CANNON: any;
  112630. AudioContext: AudioContext;
  112631. webkitAudioContext: AudioContext;
  112632. PointerEvent: any;
  112633. Math: Math;
  112634. Uint8Array: Uint8ArrayConstructor;
  112635. Float32Array: Float32ArrayConstructor;
  112636. mozURL: typeof URL;
  112637. msURL: typeof URL;
  112638. VRFrameData: any; // WebVR, from specs 1.1
  112639. DracoDecoderModule: any;
  112640. setImmediate(handler: (...args: any[]) => void): number;
  112641. }
  112642. interface HTMLCanvasElement {
  112643. requestPointerLock(): void;
  112644. msRequestPointerLock?(): void;
  112645. mozRequestPointerLock?(): void;
  112646. webkitRequestPointerLock?(): void;
  112647. /** Track wether a record is in progress */
  112648. isRecording: boolean;
  112649. /** Capture Stream method defined by some browsers */
  112650. captureStream(fps?: number): MediaStream;
  112651. }
  112652. interface CanvasRenderingContext2D {
  112653. msImageSmoothingEnabled: boolean;
  112654. }
  112655. interface MouseEvent {
  112656. mozMovementX: number;
  112657. mozMovementY: number;
  112658. webkitMovementX: number;
  112659. webkitMovementY: number;
  112660. msMovementX: number;
  112661. msMovementY: number;
  112662. }
  112663. interface Navigator {
  112664. mozGetVRDevices: (any: any) => any;
  112665. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112666. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112667. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112668. webkitGetGamepads(): Gamepad[];
  112669. msGetGamepads(): Gamepad[];
  112670. webkitGamepads(): Gamepad[];
  112671. }
  112672. interface HTMLVideoElement {
  112673. mozSrcObject: any;
  112674. }
  112675. interface Math {
  112676. fround(x: number): number;
  112677. imul(a: number, b: number): number;
  112678. }
  112679. interface WebGLProgram {
  112680. context?: WebGLRenderingContext;
  112681. vertexShader?: WebGLShader;
  112682. fragmentShader?: WebGLShader;
  112683. isParallelCompiled: boolean;
  112684. onCompiled?: () => void;
  112685. }
  112686. interface WebGLRenderingContext {
  112687. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112688. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112689. vertexAttribDivisor(index: number, divisor: number): void;
  112690. createVertexArray(): any;
  112691. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112692. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112693. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112694. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112695. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112696. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112697. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112698. // Queries
  112699. createQuery(): WebGLQuery;
  112700. deleteQuery(query: WebGLQuery): void;
  112701. beginQuery(target: number, query: WebGLQuery): void;
  112702. endQuery(target: number): void;
  112703. getQueryParameter(query: WebGLQuery, pname: number): any;
  112704. getQuery(target: number, pname: number): any;
  112705. MAX_SAMPLES: number;
  112706. RGBA8: number;
  112707. READ_FRAMEBUFFER: number;
  112708. DRAW_FRAMEBUFFER: number;
  112709. UNIFORM_BUFFER: number;
  112710. HALF_FLOAT_OES: number;
  112711. RGBA16F: number;
  112712. RGBA32F: number;
  112713. R32F: number;
  112714. RG32F: number;
  112715. RGB32F: number;
  112716. R16F: number;
  112717. RG16F: number;
  112718. RGB16F: number;
  112719. RED: number;
  112720. RG: number;
  112721. R8: number;
  112722. RG8: number;
  112723. UNSIGNED_INT_24_8: number;
  112724. DEPTH24_STENCIL8: number;
  112725. /* Multiple Render Targets */
  112726. drawBuffers(buffers: number[]): void;
  112727. readBuffer(src: number): void;
  112728. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112729. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112730. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112731. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112732. // Occlusion Query
  112733. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112734. ANY_SAMPLES_PASSED: number;
  112735. QUERY_RESULT_AVAILABLE: number;
  112736. QUERY_RESULT: number;
  112737. }
  112738. interface WebGLBuffer {
  112739. references: number;
  112740. capacity: number;
  112741. is32Bits: boolean;
  112742. }
  112743. interface WebGLProgram {
  112744. transformFeedback?: WebGLTransformFeedback | null;
  112745. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112746. }
  112747. interface EXT_disjoint_timer_query {
  112748. QUERY_COUNTER_BITS_EXT: number;
  112749. TIME_ELAPSED_EXT: number;
  112750. TIMESTAMP_EXT: number;
  112751. GPU_DISJOINT_EXT: number;
  112752. QUERY_RESULT_EXT: number;
  112753. QUERY_RESULT_AVAILABLE_EXT: number;
  112754. queryCounterEXT(query: WebGLQuery, target: number): void;
  112755. createQueryEXT(): WebGLQuery;
  112756. beginQueryEXT(target: number, query: WebGLQuery): void;
  112757. endQueryEXT(target: number): void;
  112758. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112759. deleteQueryEXT(query: WebGLQuery): void;
  112760. }
  112761. interface WebGLUniformLocation {
  112762. _currentState: any;
  112763. }
  112764. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112765. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112766. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112767. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112768. interface WebGLRenderingContext {
  112769. readonly RASTERIZER_DISCARD: number;
  112770. readonly DEPTH_COMPONENT24: number;
  112771. readonly TEXTURE_3D: number;
  112772. readonly TEXTURE_2D_ARRAY: number;
  112773. readonly TEXTURE_COMPARE_FUNC: number;
  112774. readonly TEXTURE_COMPARE_MODE: number;
  112775. readonly COMPARE_REF_TO_TEXTURE: number;
  112776. readonly TEXTURE_WRAP_R: number;
  112777. readonly HALF_FLOAT: number;
  112778. readonly RGB8: number;
  112779. readonly RED_INTEGER: number;
  112780. readonly RG_INTEGER: number;
  112781. readonly RGB_INTEGER: number;
  112782. readonly RGBA_INTEGER: number;
  112783. readonly R8_SNORM: number;
  112784. readonly RG8_SNORM: number;
  112785. readonly RGB8_SNORM: number;
  112786. readonly RGBA8_SNORM: number;
  112787. readonly R8I: number;
  112788. readonly RG8I: number;
  112789. readonly RGB8I: number;
  112790. readonly RGBA8I: number;
  112791. readonly R8UI: number;
  112792. readonly RG8UI: number;
  112793. readonly RGB8UI: number;
  112794. readonly RGBA8UI: number;
  112795. readonly R16I: number;
  112796. readonly RG16I: number;
  112797. readonly RGB16I: number;
  112798. readonly RGBA16I: number;
  112799. readonly R16UI: number;
  112800. readonly RG16UI: number;
  112801. readonly RGB16UI: number;
  112802. readonly RGBA16UI: number;
  112803. readonly R32I: number;
  112804. readonly RG32I: number;
  112805. readonly RGB32I: number;
  112806. readonly RGBA32I: number;
  112807. readonly R32UI: number;
  112808. readonly RG32UI: number;
  112809. readonly RGB32UI: number;
  112810. readonly RGBA32UI: number;
  112811. readonly RGB10_A2UI: number;
  112812. readonly R11F_G11F_B10F: number;
  112813. readonly RGB9_E5: number;
  112814. readonly RGB10_A2: number;
  112815. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112816. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112817. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112818. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112819. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112820. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112821. 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;
  112822. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112823. readonly TRANSFORM_FEEDBACK: number;
  112824. readonly INTERLEAVED_ATTRIBS: number;
  112825. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112826. createTransformFeedback(): WebGLTransformFeedback;
  112827. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112828. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112829. beginTransformFeedback(primitiveMode: number): void;
  112830. endTransformFeedback(): void;
  112831. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112832. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112833. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112834. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112835. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112836. }
  112837. interface ImageBitmap {
  112838. readonly width: number;
  112839. readonly height: number;
  112840. close(): void;
  112841. }
  112842. interface WebGLQuery extends WebGLObject {
  112843. }
  112844. declare var WebGLQuery: {
  112845. prototype: WebGLQuery;
  112846. new(): WebGLQuery;
  112847. };
  112848. interface WebGLSampler extends WebGLObject {
  112849. }
  112850. declare var WebGLSampler: {
  112851. prototype: WebGLSampler;
  112852. new(): WebGLSampler;
  112853. };
  112854. interface WebGLSync extends WebGLObject {
  112855. }
  112856. declare var WebGLSync: {
  112857. prototype: WebGLSync;
  112858. new(): WebGLSync;
  112859. };
  112860. interface WebGLTransformFeedback extends WebGLObject {
  112861. }
  112862. declare var WebGLTransformFeedback: {
  112863. prototype: WebGLTransformFeedback;
  112864. new(): WebGLTransformFeedback;
  112865. };
  112866. interface WebGLVertexArrayObject extends WebGLObject {
  112867. }
  112868. declare var WebGLVertexArrayObject: {
  112869. prototype: WebGLVertexArrayObject;
  112870. new(): WebGLVertexArrayObject;
  112871. };
  112872. // Type definitions for WebVR API
  112873. // Project: https://w3c.github.io/webvr/
  112874. // Definitions by: six a <https://github.com/lostfictions>
  112875. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112876. interface VRDisplay extends EventTarget {
  112877. /**
  112878. * Dictionary of capabilities describing the VRDisplay.
  112879. */
  112880. readonly capabilities: VRDisplayCapabilities;
  112881. /**
  112882. * z-depth defining the far plane of the eye view frustum
  112883. * enables mapping of values in the render target depth
  112884. * attachment to scene coordinates. Initially set to 10000.0.
  112885. */
  112886. depthFar: number;
  112887. /**
  112888. * z-depth defining the near plane of the eye view frustum
  112889. * enables mapping of values in the render target depth
  112890. * attachment to scene coordinates. Initially set to 0.01.
  112891. */
  112892. depthNear: number;
  112893. /**
  112894. * An identifier for this distinct VRDisplay. Used as an
  112895. * association point in the Gamepad API.
  112896. */
  112897. readonly displayId: number;
  112898. /**
  112899. * A display name, a user-readable name identifying it.
  112900. */
  112901. readonly displayName: string;
  112902. readonly isConnected: boolean;
  112903. readonly isPresenting: boolean;
  112904. /**
  112905. * If this VRDisplay supports room-scale experiences, the optional
  112906. * stage attribute contains details on the room-scale parameters.
  112907. */
  112908. readonly stageParameters: VRStageParameters | null;
  112909. /**
  112910. * Passing the value returned by `requestAnimationFrame` to
  112911. * `cancelAnimationFrame` will unregister the callback.
  112912. * @param handle Define the hanle of the request to cancel
  112913. */
  112914. cancelAnimationFrame(handle: number): void;
  112915. /**
  112916. * Stops presenting to the VRDisplay.
  112917. * @returns a promise to know when it stopped
  112918. */
  112919. exitPresent(): Promise<void>;
  112920. /**
  112921. * Return the current VREyeParameters for the given eye.
  112922. * @param whichEye Define the eye we want the parameter for
  112923. * @returns the eye parameters
  112924. */
  112925. getEyeParameters(whichEye: string): VREyeParameters;
  112926. /**
  112927. * Populates the passed VRFrameData with the information required to render
  112928. * the current frame.
  112929. * @param frameData Define the data structure to populate
  112930. * @returns true if ok otherwise false
  112931. */
  112932. getFrameData(frameData: VRFrameData): boolean;
  112933. /**
  112934. * Get the layers currently being presented.
  112935. * @returns the list of VR layers
  112936. */
  112937. getLayers(): VRLayer[];
  112938. /**
  112939. * Return a VRPose containing the future predicted pose of the VRDisplay
  112940. * when the current frame will be presented. The value returned will not
  112941. * change until JavaScript has returned control to the browser.
  112942. *
  112943. * The VRPose will contain the position, orientation, velocity,
  112944. * and acceleration of each of these properties.
  112945. * @returns the pose object
  112946. */
  112947. getPose(): VRPose;
  112948. /**
  112949. * Return the current instantaneous pose of the VRDisplay, with no
  112950. * prediction applied.
  112951. * @returns the current instantaneous pose
  112952. */
  112953. getImmediatePose(): VRPose;
  112954. /**
  112955. * The callback passed to `requestAnimationFrame` will be called
  112956. * any time a new frame should be rendered. When the VRDisplay is
  112957. * presenting the callback will be called at the native refresh
  112958. * rate of the HMD. When not presenting this function acts
  112959. * identically to how window.requestAnimationFrame acts. Content should
  112960. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112961. * asynchronously from other displays and at differing refresh rates.
  112962. * @param callback Define the eaction to run next frame
  112963. * @returns the request handle it
  112964. */
  112965. requestAnimationFrame(callback: FrameRequestCallback): number;
  112966. /**
  112967. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112968. * Repeat calls while already presenting will update the VRLayers being displayed.
  112969. * @param layers Define the list of layer to present
  112970. * @returns a promise to know when the request has been fulfilled
  112971. */
  112972. requestPresent(layers: VRLayer[]): Promise<void>;
  112973. /**
  112974. * Reset the pose for this display, treating its current position and
  112975. * orientation as the "origin/zero" values. VRPose.position,
  112976. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112977. * updated when calling resetPose(). This should be called in only
  112978. * sitting-space experiences.
  112979. */
  112980. resetPose(): void;
  112981. /**
  112982. * The VRLayer provided to the VRDisplay will be captured and presented
  112983. * in the HMD. Calling this function has the same effect on the source
  112984. * canvas as any other operation that uses its source image, and canvases
  112985. * created without preserveDrawingBuffer set to true will be cleared.
  112986. * @param pose Define the pose to submit
  112987. */
  112988. submitFrame(pose?: VRPose): void;
  112989. }
  112990. declare var VRDisplay: {
  112991. prototype: VRDisplay;
  112992. new(): VRDisplay;
  112993. };
  112994. interface VRLayer {
  112995. leftBounds?: number[] | Float32Array | null;
  112996. rightBounds?: number[] | Float32Array | null;
  112997. source?: HTMLCanvasElement | null;
  112998. }
  112999. interface VRDisplayCapabilities {
  113000. readonly canPresent: boolean;
  113001. readonly hasExternalDisplay: boolean;
  113002. readonly hasOrientation: boolean;
  113003. readonly hasPosition: boolean;
  113004. readonly maxLayers: number;
  113005. }
  113006. interface VREyeParameters {
  113007. /** @deprecated */
  113008. readonly fieldOfView: VRFieldOfView;
  113009. readonly offset: Float32Array;
  113010. readonly renderHeight: number;
  113011. readonly renderWidth: number;
  113012. }
  113013. interface VRFieldOfView {
  113014. readonly downDegrees: number;
  113015. readonly leftDegrees: number;
  113016. readonly rightDegrees: number;
  113017. readonly upDegrees: number;
  113018. }
  113019. interface VRFrameData {
  113020. readonly leftProjectionMatrix: Float32Array;
  113021. readonly leftViewMatrix: Float32Array;
  113022. readonly pose: VRPose;
  113023. readonly rightProjectionMatrix: Float32Array;
  113024. readonly rightViewMatrix: Float32Array;
  113025. readonly timestamp: number;
  113026. }
  113027. interface VRPose {
  113028. readonly angularAcceleration: Float32Array | null;
  113029. readonly angularVelocity: Float32Array | null;
  113030. readonly linearAcceleration: Float32Array | null;
  113031. readonly linearVelocity: Float32Array | null;
  113032. readonly orientation: Float32Array | null;
  113033. readonly position: Float32Array | null;
  113034. readonly timestamp: number;
  113035. }
  113036. interface VRStageParameters {
  113037. sittingToStandingTransform?: Float32Array;
  113038. sizeX?: number;
  113039. sizeY?: number;
  113040. }
  113041. interface Navigator {
  113042. getVRDisplays(): Promise<VRDisplay[]>;
  113043. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  113044. }
  113045. interface Window {
  113046. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  113047. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  113048. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  113049. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113050. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113051. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  113052. }
  113053. interface Gamepad {
  113054. readonly displayId: number;
  113055. }
  113056. interface XRDevice {
  113057. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  113058. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  113059. }
  113060. interface XRSession {
  113061. getInputSources(): Array<any>;
  113062. baseLayer: XRWebGLLayer;
  113063. requestFrameOfReference(type: string): Promise<void>;
  113064. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  113065. end(): Promise<void>;
  113066. requestAnimationFrame: Function;
  113067. addEventListener: Function;
  113068. }
  113069. interface XRSessionCreationOptions {
  113070. outputContext?: WebGLRenderingContext | null;
  113071. immersive?: boolean;
  113072. environmentIntegration?: boolean;
  113073. }
  113074. interface XRLayer {
  113075. getViewport: Function;
  113076. framebufferWidth: number;
  113077. framebufferHeight: number;
  113078. }
  113079. interface XRView {
  113080. projectionMatrix: Float32Array;
  113081. }
  113082. interface XRFrame {
  113083. getDevicePose: Function;
  113084. getInputPose: Function;
  113085. views: Array<XRView>;
  113086. baseLayer: XRLayer;
  113087. }
  113088. interface XRFrameOfReference {
  113089. }
  113090. interface XRWebGLLayer extends XRLayer {
  113091. framebuffer: WebGLFramebuffer;
  113092. }
  113093. declare var XRWebGLLayer: {
  113094. prototype: XRWebGLLayer;
  113095. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  113096. };